Nativescript audio plugin error

plugins

#1

Hello

I am testing the nativescript-audio plugin but can’t make it work for vanilla js.
Here is my code…

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...");
        })

and I am getting the following error:

JS ERROR TypeError: null is not an object (evaluating '_this._player.delegate = _this')

What I am doing wrong?
Thanks!


#2

Ok, the code above is correct, probably the error was due to a wrong plugin building…