aliplayer-react icon indicating copy to clipboard operation
aliplayer-react copied to clipboard

Video doesn't work right when changing vid and playauth in props.config

Open imbant opened this issue 5 years ago • 5 comments

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?

imbant avatar Nov 28 '19 10:11 imbant

Maybe we can run a deeper comparison, detect vid change and get a new instance?

wangsijie avatar Nov 28 '19 10:11 wangsijie

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 :)

imbant avatar Nov 28 '19 10:11 imbant

Hello, how to destroy it? I'm still working on it, but I haven't solved it yet

LunarEdeg avatar Mar 03 '20 05:03 LunarEdeg

Hello, how to destroy it? I'm still working on it, but I haven't solved it yet

player.dispose()

wangsijie avatar Mar 03 '20 05:03 wangsijie

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.

imbant avatar Mar 03 '20 06:03 imbant