let rootpath=__dirname
let path=require('path')
let _ = require('lodash');
const Player = require('../playerCan/basswrapper').basswrapper
let player = new Player(rootpath);
const sutils = require('../utils/smgutils');
const u = new sutils();
if(player.BASS_Init(-1,44100, player.BASS_DEVICE_SPEAKERS)){
    console.log('bass loaded')
}
let q = u.readConfig();
let q1 = _.fromPairs(q.Plugins);
console.log(q1);

player.loadPlugin('aac');

let fname=path.join(rootpath,'test.mp3');
let channel = player.BASS_StreamCreateFile(0, fname, 0, 0, 0);

player.BASS_ChannelPlay(channel,true);
console.log(channel);

setInterval(()=>{
    let duration=player.BASS_ChannelBytes2Seconds(channel, player.BASS_ChannelGetLength(channel, 0)) ;
    let position=player.BASS_ChannelBytes2Seconds(channel, player.BASS_ChannelGetPosition(channel, 0)) ;
    console.log(`${position}-${duration}`)
},1000)
