Skip to content

Commit

Permalink
fix: #79 BUG while changing between stations (Mozilla)
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseiNicolae committed Feb 19, 2023
1 parent 9406df8 commit 252467b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions frontend/components/StationPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,21 @@ export default function StationPlayer({stations}: any) {
audio.src = hls_stream_url;
}

hls.on(Hls.Events.AUDIO_TRACK_LOADING, function () {
setPlaybackState(PLAYBACK_STATE.BUFFERING);
});

hls.on(Hls.Events.MANIFEST_PARSED, () => {
audio.play().catch(() => {
setPlaybackState(PLAYBACK_STATE.STOPPED);
});
setPlaybackState(PLAYBACK_STATE.BUFFERING);
audio.addEventListener(
'canplaythrough',
function () {
audio.play().catch(() => {
setPlaybackState(PLAYBACK_STATE.STOPPED);
});
},
{once: true},
);
});

hls.on(Hls.Events.ERROR, function (event, data) {
Expand Down Expand Up @@ -374,9 +385,6 @@ export default function StationPlayer({stations}: any) {
onWaiting={() => {
setPlaybackState(PLAYBACK_STATE.BUFFERING);
}}
onLoadedData={() => {
setPlaybackState(PLAYBACK_STATE.STOPPED);
}}
onError={() => {
retryMechanism();
}}
Expand Down

1 comment on commit 252467b

@vercel
Copy link

@vercel vercel bot commented on 252467b Feb 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.