Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
imbant opened this issue Nov 28, 2019 · 5 comments
Open

Comments

@imbant
Copy link

imbant commented Nov 28, 2019

It seems window.Aliplayer could have only one object.So when changing config.vid,this method in useEffect just return.

if (player.current) { return }

Any idea how to solve this please?

@imbant imbant changed the title Video doesn Video doesn't works right when changing vid and playauth in props.config Nov 28, 2019
@imbant imbant changed the title Video doesn't works right when changing vid and playauth in props.config Video doesn't work right when changing vid and playauth in props.config Nov 28, 2019
@wangsijie
Copy link
Owner

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

@imbant
Copy link
Author

imbant commented Nov 28, 2019

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 <script> should be created.
This will make the component more 'Reactive' since the component really changed after props changing.

So sorry for my broken English and thanks for your reply anyway :)

@LunarEdeg
Copy link

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

@wangsijie
Copy link
Owner

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

player.dispose()

@imbant
Copy link
Author

imbant commented Mar 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants