【发布时间】:2015-05-29 07:34:11
【问题描述】:
我刚开始学习phonegap,但是当我点击播放按钮播放assets 文件夹中的mp3 时,我收到了错误alert('no audio support!');。我搜索了很多播放 mp3 的代码,到目前为止我所拥有的内容如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script
src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<title>Hello World</title>
<script type="text/javascript" src="js/Toast.js"></script>
<script>
function playStream() {
try {
var myaudio = new Media('/android_asset/www/audio/limelight.mp3');
//alert ("ffff");
myaudio.id = 'playerMyAdio';
myaudio.play();
} catch (e) {
alert('no audio support!');
}
}
function getMediaURL(s) {
if (device.platform.toLowerCase() === "android")
return "/android/assets/www/" + s;
return s;
}
function stopStream() {
try {
myaudio.pause();
} catch (e) {
alert('no audio support!');
}
}
</script>
</head>
<body>
<div data-role="page">
<div data-role="header" data-position="fixed" data-theme="b">
<h1>Play AUdio</h1>
</div>
<div data-role="content">
<button onClick="playStream()">play</button>
<br />
<button onClick="stopStream()">stop</button>
<br />
</div>
</div>
</body>
</html>
【问题讨论】:
-
我改进了您的措辞并添加了您之前遗漏的细节。这应该可以帮助您获得答案。
-
对不起,我错了。如果你曾经以浮动视图服务的名义,我可以很快得到。
-
别担心,感谢:),你也可以给我发电子邮件
标签: android cordova phonegap-plugins phonegap-build