前提・実現したいこと
Monacaで2つ重ねて音を出すために、cordova-plugin-nativeaudioを利用したい
エラーメッセージ
Error1: (NATIVE AUDIO)Asset not found.(audio/jump.mp3)
該当のソースコード
javascript
1document.addEventListener("deviceready", onDeviceReady, false); 2function onDeviceReady() { app.initialize(); } 3var app = { 4 // Application Constructor 5 initialize: function() { 6 this.bindEvents(); 7 }, 8 // Bind Event Listeners 9 // 10 // Bind any events that are required on startup. Common events are: 11 // 'load', 'deviceready', 'offline', and 'online'. 12 bindEvents: function() { 13 document.addEventListener('deviceready', this.onDeviceReady, false); 14 }, 15 // deviceready Event Handler 16 // 17 // The scope of 'this' is the event. In order to call the 'receivedEvent' 18 // function, we must explicitly call 'app.receivedEvent(...);' 19 onDeviceReady: function() { 20 app.receivedEvent('deviceready'); 21 console.log('deviceready'); 22 }, 23 // Update DOM on a Received Event 24 receivedEvent: function(id) { 25 26 if( window.plugins && window.plugins.NativeAudio ) { 27 28 window.plugins.NativeAudio 29 .preloadSimple( 30 'jump', 31 'audio/jump.mp3', 32 function(msg){console.log('preloadSimple ok')}, 33 function(msg){ console.log( 'Error1: ' + msg ); }); 34 } 35 36 }, 37 38 play: function(drum) { 39 // document.getElementById(drum).classList.add('touched'); 40 window.plugins.NativeAudio.play('jump', 41 function(msg){console.info(msg)}, 42 function(msg){ console.error( 'Error2: ' + msg ); }); 43 } 44};
試したこと
音声ファイル(jump.mp3)の場所がwww/audio/であることは間違いありません。
解決法を探るため英語のサイトなども見て来たのですが、多くの人が同じ問題に陥っている!ということだけ判明しました。現在使っているMonacaのcordova-plugin-mediaではオーディオを2つ重ねて出すことはできないようですし、クッリクと同時にラグタイムなく音声が出る!といったことも難しい...諦めるしかないのでしょうか?
諦めたくない!よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/22 17:27