我正在测试nativescript-audio插件,但无法使其适用于vanilla js。 这是我的代码......
var ns_audio = require("nativescript-audio");
var player = new ns_audio.TNSPlayer();
var playerOptions = {
audioFile: "http://www.noiseaddicts.com/samples_1w72b820/2514.mp3",
loop: false,
completeCallback: function () {
console.log('completePlayer')
},
errorCallback: function (errorObject) {
console.log(JSON.stringify(errorObject));
},
infoCallback: function (args) {
console.log(JSON.stringify(args));
}
};
player.playFromUrl(playerOptions)
.then(function (res) {
console.log(res);
})
.catch(function () {
console.log("didn't work...");
})
我收到以下错误:
JS ERROR TypeError: null is not an object (evaluating '_this._player.delegate = _this')
我做错了什么? 谢谢!
答案 0 :(得分:0)
好的,上面的代码是正确的,可能错误是由于插件构建错误......