我正在使用来自phonegap的媒体在我的APP中播放一些音频。
function playSnd(url) {
// Play the audio file at url
var my_media = new Media(url,
// success callback
function() {
console.log("playAudio():Audio Success");
},
// error callback
function(err) {
console.log("playAudio():Audio Error: " + err);
});
// Play audio
my_media.play();
}
在我的控制台中调用playSnd('audio.mp3')之后,
Uncaught ReferenceError: Media is not defined index.js:54
LE:我安装了https://github.com/apache/cordova-plugin-media。
最佳答案
您必须等待ondeviceready
事件。document.addEventListener('deviceready', function () {/* your code goes here */});
关于javascript - Phonegap使用媒体插件播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28726129/