serversideup / amplitudejs

AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.
https://521dimensions.com/open-source/amplitudejs
MIT License
4.19k stars 424 forks source link

Callbacks is not initialized after stream reconnection with a live source #451

Open alexeevit opened 4 years ago

alexeevit commented 4 years ago

Issue description

If I use a source with the live: true param it doesn't initialize Callbacks after the config.audio redefining during stream reconnection.

Environment

Steps to reproduce the issue

let playCallback = function() {
    console.log('play');
};

Amplitude.init({
    songs: [{ url: "http://igor.torontocast.com:1870/stream", live: true }],
    callbacks: { play: playCallback }
});

Amplitude.play();

What is expected?

play in the console

Link to where the issue can be reproduced

https://jsfiddle.net/alexeevdev/0oazpu51/1/

alexeevit commented 4 years ago

Actually I'd be glad to add Callbacks.initialize() right after config.audio = new Audio(); but I don't get how to test it with jest 🤣