大家好,我对 NS audio 有疑问插件:
我的 js 文件的代码
const audio = require('nativescript-audio');
const player = new audio.TNSPlayer();
function play(){
const playerOptions = {
audioFile: url, // url is variable where file is located
loop: false,
completeCallback() {
console.log("playback completed");
},
errorCallback(errorObject) {
console.log("Error");
},
infoCallback(args) {
},
}
if (player.isAudioPlaying()) {
player.dispose();
playIt(playerOptions);
}
} else {
playIt(playerOptions);
}
}
function playIt(playerOptions){
player.playFromUrl(playerOptions)
.then((res) => {
}).catch(() => {
});
}
和我的 xml:
<Button text="play" tap="play"></Button>
所以当我尝试像这样在我的模拟器上发送短信时,问题就发生了 https://ibb.co/dsZLkx
当我在该页面上时,或者如果我在该页面上并将 USB 插入我的真实手机时。我的应用程序崩溃并显示以下消息: Error message
我认为当设备上同时出现其他一些声音时会发生冲突,并且在插件中没有正确处理, 但我对 android 很弱,所以有人可以帮助我或提供一些信息我会尝试自己修复它。
最佳答案
关于android - Nativescript 音频问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49005286/