也許你可以幫幫我,我一直在尋找所有資訊,以解決我的這個問題,但是沒有,我無法使用cordova的播放器......
在實踐中,我無法加載 mp3 檔案,無論它們是本地還是遠程,我總是收到此錯誤:“錯誤:緩沖區未設定或未加載”,路徑中的檔案在那里。
我嘗試使用 Tone 的示波器來查看是否在加載 Tone 時遇到問題,但這作業正常。
它可能取決于一些授權,特別是我可能會丟失嗎?
例如使用科爾多瓦媒體插件我可以重現音頻,但我需要使用 Tonejs。
你有什么想法嗎,這可能取決于什么。或者我可以嘗試做什么?...
即使是這個簡單的例子,在設備準備好之后也不去:
const player = new Tone.Player("https://tonejs.github.io/audio/berklee/gong_1.mp3") .toDestination();
Tone.loaded().Then(() => {
player.start ();
});
已經與 Tone 和 Cordova 合作過的你,給我希望它可以以某種方式使用,如果你有任何想法,請提前告訴我!
- - 更新:
目前,當應用程式啟動時,我的行為是這樣的(我宣告它是為網站開發的代碼的移植,并且一切正常加載它等等):
let myLoader_File = function functionOne(test) {
var androidFixPath = cordova.file.applicationDirectory
console.log("Entered function");
return new Promise((resolve, reject) => {
let CaricatorePlayers = new Tone.Players({
Beep: androidFixPath "sample/Beep.mp3",
Clave: androidFixPath "sample/Clave.mp3",
}).toDestination();
resolve(
CaricatorePlayers
//"ok tutti i file sono stati caricati!"
);
reject("si è verificato un errore!");
});
};
function onDeviceReady() {
$('#fade-wrapper-flash').fadeOut(1000);
$('#fade-wrapper').fadeIn();
//attach a click listener to a start button
document.querySelector('#fade-wrapper').addEventListener('click', async () => {
await Tone.start();
console.log('audio is ready');
myLoader_File().then((res) => {
console.log(`The function recieved with value ${res}`)
MultiPlayers = res;
console.log(MultiPlayers)
try {
// Play
MultiPlayers.player("Beep").start();
$('#fade-wrapper').fadeOut();
preLoad();
} catch (error) {
console.log(error);
console.log("IN ERRORE RICARICO");
}
}).catch((error) => {
console.log(`Handling error as we received ${error}`);
console.log("IN ERRORE RICARICO");
$('#fade-wrapper').fadeIn();
});
});
}
uj5u.com熱心網友回復:
我在這里發布了一個答案,它也解決了這個問題。
我不知道該解決方案是否是唯一可能的方法,還是最好的方法,為了在本地訪問檔案夾,我對呼叫進行了這些更改。使用可用于從 Web 服務器請求資料的 XMLHttpRequest 物件,我得到了一個 Blob 物件,然后將其傳遞給 Tone 播放器。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/412360.html
標籤:
