我的JavaScript技能也開始提高(我認爲),但我在與科爾多瓦 - 插件媒體一個非常奇怪的問題科爾多瓦 - 插件 - 媒體沒有發射成功或失敗的事件
我已經加入了插件到科爾多瓦,但是當我定義媒體對象時,沒有成功或失敗事件觸發。
我已經把大量的控制檯提示到我的代碼:
$scope.testSound = function() {
console.log("!!!!!!! DEFINING THE PATH");
var src = "snd/emergency.wav";
console.log("!!!!!!! DEFINING THE MEDIA OBJECT");
var emergencySound = new Media(src, mediaSuccess, mediaError);
console.log("WE SHOULD BE FIRING THE SUCCESS OR FAIL METHODS NOW");
function mediaSuccess(){
console.log("!!!!!!!!!!!!!!!!!!!Success");
alert("Media loaded");
}
function mediaError(err){
console.log("!!!!!!!!!!!!!!!!!!!!!!FAIL");
alert("Media failed to load");
}
console.log("!!!!!!!!!!!!!!!!!!!!!!METHOD COMPLETE");
}
})
,輸出如下:
I/chromium(2978): [INFO:CONSOLE(173)] "!!!!!!! DEFINING THE PATH", source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
I/chromium(2978): [INFO:CONSOLE(173)] "!!!!!!! DEFINING THE MEDIA OBJECT", source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
I/chromium(2978): [INFO:CONSOLE(173)] "WE SHOULD BE FIRING THE SUCCESS OR FAILMETHODS NOW", source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
I/chromium(2978): [INFO:CONSOLE(173)] "!!!!!!!!!!!!!!!!!!!!!!METHOD COMPLETE",source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
我期待失敗的方法滅火,因爲我不認爲我的媒體文件路徑的語法是正確的,但不僅是失敗不觸發,而且也沒有跡象表明代碼存在問題(Android 4.4.2)。
結果是STATUS:-0.001 – PeterBiggerstaff
emergencySound.getCurrentPosition(statusSuccess,mediaError); \t \t \t 功能\t statusSuccess(統計){ \t \t \t的console.log( 「STATUS:」 +統計); \t \t \t} – PeterBiggerstaff
有趣的。我做了一個「mymedia.play()」,它確實發揮了..所以不知道爲什麼這些事件不會開火。 – PeterBiggerstaff