recreateNode method
void
recreateNode()
Implementation
void recreateNode() {
if (currentUrl == null) {
return;
}
Duration toDuration(num jsNum) => Duration(
milliseconds:
(1000 * (jsNum.toString() == 'NaN' ? 0 : jsNum)).round(),
);
final p = player = AudioElement(currentUrl);
p.loop = shouldLoop();
p.volume = currentVolume;
p.playbackRate = currentPlaybackRate;
playerLoadedDataSubscription = p.onLoadedData.listen((event) {
streamsInterface.emitDuration(playerId, toDuration(p.duration));
});
playerTimeUpdateSubscription = p.onTimeUpdate.listen((_) {
streamsInterface.emitPosition(playerId, toDuration(p.currentTime));
});
playerEndedSubscription = p.onEnded.listen((_) {
streamsInterface.emitPlayerState(playerId, PlayerState.stopped);
streamsInterface.emitComplete(playerId);
});
}