const Ice = require('../player/old/clsIceCast').clsIceCast;
const ice = new Ice();
const moment = require('moment');
const appRoot = require('app-root-path');
let song = appRoot.path + '/test.mp3';


ice.basslib.BASS_Init(-1, 44100, ice.basslib.BASS_DEVICE_STEREO);

let mixer = ice.basslib.BASS_Mixer_StreamCreate(44100, 2, ice.basslib.BASS_SAMPLE_DEFAULT);
let chan = ice.basslib.BASS_StreamCreateFile(0, song, 0, 0, ice.basslib.BASS_STREAM_DECODE | ice.basslib.BASS_SAMPLE_FLOAT);
let add = ice.basslib.BASS_Mixer_StreamAddChannel(mixer, chan, ice.basslib.BASS_SAMPLE_DEFAULT);
ice.basslib.BASS_ChannelPlay(mixer, 0);
let duration = ice.basslib.BASS_ChannelBytes2Seconds(chan, ice.basslib.BASS_ChannelGetLength(chan, 0));
ice.iceCastStream(mixer);
console.log('enc chan: ', ice.encoderChannel);

setInterval(() => {
    let position = ice.basslib.BASS_ChannelBytes2Seconds(chan, ice.basslib.BASS_ChannelGetPosition(chan, 0));
    let pos = moment({hour: 0, minute: 0, second: 0}).second(position).format("mm:ss");
    let dur = moment({hour: 0, minute: 0, second: 0}).second(duration).format("mm:ss");

    console.log('pos: ', pos, '/', dur);
}, 1000);


