weixin_39917437
weixin_39917437
2020-12-09 00:04

Handle media player network errors and try to recover

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: - The event handler is called. - The active track changes. - The component unmounts.

Let me know what you think.

该提问来源于开源项目:benwiley4000/cassette

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39917437 weixin_39917437 4月前

    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.

    点赞 评论 复制链接分享
  • weixin_39917437 weixin_39917437 4月前

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

    点赞 评论 复制链接分享
  • weixin_39847437 weixin_39847437 4月前

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

    点赞 评论 复制链接分享
  • weixin_39847437 weixin_39847437 4月前

    released in v2.0.0-beta.2!

    点赞 评论 复制链接分享

相关推荐