从资产文件夹phonegap(Cordova)播放mp3时出错

时间:2015-05-29 07:34:11

标签: android cordova phonegap-plugins phonegap-build

我刚刚开始学习alert('no audio support!');,但当我点击播放按钮播放assets文件夹中的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> 。我已经搜索了很多代码来播放mp3,到目前为止我已经在这里显示了:

angular.element($("#someThing")).scope();

1 个答案:

答案 0 :(得分:0)

@quick learner,你在做什么操作系统?哪个操作系统有问题?您的代码显示Windows,iOS和Android。此代码可能适用于Android。我有working examples for iOS and Android。 --Jesse