aliplayer-react
aliplayer-react copied to clipboard
Video doesn't work right when changing vid and playauth in props.config
It seems window.Aliplayer
could have only one object.So when changing config.vid,this method in useEffect
just return
.
https://github.com/wangsijie/aliplayer-react/blob/58d9eeb1c72d0b92e2a3593714b61fac7659265c/src/index.tsx#L26
Any idea how to solve this please?
Maybe we can run a deeper comparison, detect vid
change and get a new instance?
Maybe we can run a deeper comparison, detect
vid
change and get a new instance?
Sure.When changing vid
, dispose
method in old player instance should be called,and no more
So sorry for my broken English and thanks for your reply anyway :)
Hello, how to destroy it? I'm still working on it, but I haven't solved it yet
Hello, how to destroy it? I'm still working on it, but I haven't solved it yet
player.dispose()
Hello, how to destroy it? I'm still working on it, but I haven't solved it yet
player.dispose()
It seems I made a mistake.According to the documentation, only flash player could be disposed by player.dispose()
.
And H5 player should use player.replayByVidAndPlayAuth
to change vid
,instead of destorying it(reloading the component).
BTW there is another problem about reloading the component:
If you need iOS H5 player autoPlay
feature, DON'T reload the component when changing vid, use player.replayByVidAndPlayAuth
.
At the first time the component mounted, player still could not auto play(maybe a bug?),but after player.replayByVidAndPlayAuth
,autoPlay
works well.