android - Nativescript 音频问题

标签 android nativescript

大家好,我对 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 很弱,所以有人可以帮助我或提供一些信息我会尝试自己修复它。

Link to github issue I created

最佳答案

此问题已由插件开发人员修复, 只需将插件更新到最新版本..

这里还有一个问题的链接:

Github Link

关于android - Nativescript 音频问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49005286/

相关文章:

ios - NativeScript 扩展了 UNUserNotificationCenter 委托(delegate)

Android,使用拖放在pdf上附加电子签名

java - 如何使用 css Selector Appium java 运行自动化测试

ios - NativeScript Sidekick Publishing IOS 一直提示输入密码

html - 如何将 GridLayout cols 设置为不同的宽度

javascript - 使用 NativeScript 中的通用参数扩展 Android 类

android - setListAdapter的使用

安卓数据库。提供数据或代码?

java - Instagram 主题标签搜索查询出现 'filenotfound' 异常

javascript - 用于开源 NativeScript 的 AppBuilder VS 插件