const AudioPlayer = require('./index').AudioPlayer;

let count = 0;
async function run()
{
    var obj = new AudioPlayer();
    obj.setEventCallback((status, msg) => {
        if (status === 2)
        {
            count++;
            console.log('Got playback completed, let\'s start again (' + count + ')');
            obj.play();
        }
        console.log('Got event ' + status);
    });
    console.log('Loading..');
    await obj.load('C:\\Users\\Tom\\Downloads\\test.wav');
    console.log('Play..');
    await obj.play();
    console.log('Done');
}
run().then(() =>
{
    console.log('Done all!');
}).catch((err) =>
{
    console.error(err);
})