benwiley4000 / cassette

📼 A flexible media player component library for React that requires no up-front config
https://benwiley4000.github.io/cassette/styleguide
MIT License
184 stars 28 forks source link

Handle media player network errors and try to recover #426

Closed danielr18 closed 5 years ago

danielr18 commented 5 years ago

Fixes #425.

The logic is that when the player gets a network error, it checks if it's online to try and reload the active track, and if it's not, it listens to the online event and once the player is back online, it will try to reload.

The reload track method has an option to auto play the track, however I'm not sure if we should auto play after the error, the player becomes paused after the error, maybe it's best to just reload and leave it paused? Might be weird if you were offline for a considerate amount of time and then when you go back online, something starts playing.

The online event listener is removed:

@benwiley4000 Let me know what you think.

danielr18 commented 5 years ago

I believe the reloadActiveTrack could be put in the control props. It would allow users to add a reload button when mediaCannotPlay is set. If you are offline and try to play a track, mediaCannotPlay will be true, and you can't play it again without changing tracks even after you come back online.

danielr18 commented 5 years ago

Just made the changes, feel free to modify the documentation of the new control prop if you want to improve it.

benwiley4000 commented 5 years ago

Great thank you! I'll try to release this soon.

benwiley4000 commented 5 years ago

@danielr18 released in v2.0.0-beta.2!