lijinke666 / react-music-player

[Stop the maintenance] :musical_note: Maybe the best beautiful HTML5 responsive player component for react :)
https://lijinke666.github.io/react-music-player/
MIT License
715 stars 210 forks source link

Cannot recreate player after it has been destroyed #96

Closed deluan closed 4 years ago

deluan commented 4 years ago

Version

4.10 - 4.11.1

Description

If I destroy the player (using the destroy btn or the "close" btn from the MediaSession), I can't find a way to display it again when I want to play more music

Steps to Reproduce

  1. Go to the demo site,
  2. After it starts playing music, click on the destroy btn
  3. Now there's no way to make the player start again

Expected Behavior

After destroying the player, if I add more songs to the audioLists property, it should create a new player and start playing the new music

Current Behavior

There's no way to play more songs after the player has been destroyed. The only solution is to refresh the page so the <ReactJkMusicPlayer> is recreated

Comments

If you feel like this is not something you want to support, at least do not set the navigator's "stop" handler if showDestroy is false

lijinke666 commented 4 years ago

at least do not set the navigator's "stop" handler if showDestroy is false

yes, it's a bug, i will optimize the issue, thank your feedback

After destroying the player, if I add more songs to the audioLists property, it should create a new player and start playing the new music

i think maybe add a new api like this.audioInstance.rerender() to support more usage scenarios

deluan commented 4 years ago

i think maybe add a new api like this.audioInstance.rerender() to support more usage scenarios

If I understand your proposal well, I think it would be messier from a the client's code perspective, as I'd have to control when the destroy button was clicked, keep this "state". I think it would be easier if the player handles it automatically: If you add songs to it, it shows the player if not already shown, as it does on first usage.

lijinke666 commented 4 years ago

Do you mean to make the destroy of the player like hidden, not remove dom element, if playlist changed, to display player ?

lijinke666 commented 4 years ago

i'm released version 4.11.2, the close button form the MediaSession scope is pause the music , And should not destroy player, you can upgrade for your navidrome :), i'm sorry to trouble you

about the cannot recreate player after it has been destroyed. we can talk that this is indeed a feature. will todo