JavaScript Audio 对象在 Android API 19 中不起作用
JavaScript Audio object not working in Android API 19
我使用ionic/Cordova框架从html5和JavaScript创建了一个Android应用程序。 在那里,我创建并播放一个音频对象,如下所示:
var myAudio = new Audio("myfile.mp3") ;
myAudio.play();
如果我在安卓 API 21 上安装生成的 apk,音频播放正常。如果我在 API 19 上安装它,它将无法播放。
对此的任何帮助都非常感谢。
嗨,
你安装了科尔多瓦媒体插件吗?
我过去在 cordova 4.0.0 上做过类似的事情(肯定适用于 android 19(准确地说是 4.4.2)):
AckSound:function(){
try{
var pathMedia;
if(device.platform ==='iOS'){
pathMedia ='';
} else {
pathMedia = app.getCordovaPath();
}
var snd =new Media(pathMedia+'mySound.mp3');
// Update media position every second
var mediaTimer = null;
mediaDuration = snd.getDuration();
console.log("mediaDuration is " + mediaDuration);
snd.play();
if(mediaTimer==null){
mediaTimer = setInterval(function () {
// get media position
snd.getCurrentPosition(
// success callback
function (position) {
if (position > 0) {
console.log((position) + " sec");
} else {
//if position isn t > 0, the file is over
snd.stop();
clearInterval(mediaTimer);
mediaTimer = null;
snd.release();
delete snd;
}
},
// error callback
function (e) {
console.log("Error getting pos=" + e);
}
);
}, 100);
};
delete snd;
} catch(err){
console.log("Error: in AudioManagement.AckSound(), Error is " + err);
}
console.log("AudioManagement.AckSound() stops");
}
},
下面是一个完整的示例:https://github.com/nyluje/TestMediaPluginCordova
相关文章:
- 谷歌地图API-InfoBubble赢得't关闭-关闭()不会'不起作用
- Google Maps API OverlayView()在AngularJS指令中不起作用
- 谷歌地图API JS V3包含但不起作用
- MediaSource API demo不起作用(Chrome)
- 科尔多瓦脸书登录FB.api调用不起作用
- 谷歌地图Javascript API在部署到设备时不起作用
- JavaScript Audio 对象在 Android API 19 中不起作用
- 谷歌地图融合表API SQL“;“喜欢”;命令不起作用
- YouTube V3 API——按持续时间过滤相关视频信息,不;似乎不起作用
- Yandex Maps Api示例没有'不起作用
- 谷歌地图API v3-缩放参数don'不起作用
- YouTube Javascript API:加载在 Firefox 中不起作用
- 节点 Webkit 文本到语音 API 不起作用
- 使用 ajax 的 API 调用不起作用
- Google Map API v3 在 Wordpress 中不起作用
- 谷歌地图 JS API v3:使用 containsLocation() 获取圆圈标记不起作用 - 为什么
- 使用 API 下载文件不起作用
- Google Maps API V3 setCenter 不起作用
- Vimeo 播放器 JS API 在 iOS 中不起作用
- Jenkins/Hudson API Access with API Key 不起作用