Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player keeps playing when remote stream ends #63

Open
shaksp opened this issue Jan 4, 2021 · 2 comments
Open

Player keeps playing when remote stream ends #63

shaksp opened this issue Jan 4, 2021 · 2 comments

Comments

@shaksp
Copy link

shaksp commented Jan 4, 2021

HI,

I'm building an app using FRRadioPlayer to play various streams from a remote icecast server which is streaming in mp3 format.

The streams are not always live. Many streams are on for 1-2 hours per day.
The app has code to check the stream is live and only shows the player when live.

The issue I'm experiencing is that when the stream ends, the player keeps playing a dead stream. The icecast server is no longer publishing the mount so the url should give a 404 error. However FRRadioPlayer thinks its still live.

FRadioPlaybackState keeps saying "Player is playing"
playerState says "Loading is finished"
isplaying shows true (playing)

I've checked all the published values and none of them appear to change. I need the player to stop playing when the stream ends.

When the stream starts again and if the url hasn't changed, the new stream doesn't play either. If the player was stopped when the stream ended and then the user started again the stream then it would be OK as it would reload the url but as the player never seems the stream stop, the UI keeps showing playing and the app never reloads the url.

@urayoanm
Copy link
Contributor

urayoanm commented Jan 5, 2021

@shaksp, if you put the stream URL in a browser when no one is streaming, does it gives you error 404?

@shaksp
Copy link
Author

shaksp commented Jan 6, 2021

@shaksp, if you put the stream URL in a browser when no one is streaming, does it gives you error 404?

Hi, correct, icecast does appear to let the device know the stream is ending and then after that, the url gives a 404 error. Browsers correctly handle this and show the stream is about to end. Also exoplayer on Android does the same.

I had a look into this further and AVPlayer does send a notification- NSNotification.Name.AVPlayerItemDidPlayToEndTime.
The FRadioPlayer.swift file has a remove observer for this but not an add observer.

I have amended this file to add an observer and also added a playbackstate of ended and this seems to work fine and the status correctly changes but haven't tested if there are any other downsides to this e.g. if this affects audio interruptions. FRadioPlayer.Swift file attached.

FRadioPlayer.swift.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants