-
Notifications
You must be signed in to change notification settings - Fork 157
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
Autoplay does not work upon videoId changes #176
Comments
hmm yes. A whole new js player instance is created when the videoId is changed. But the RN code was not taking this into consideration. this seems to have fixed it - dad252a, but I couldn't fully test it. I'll release a patch version as soon as I test it for a bit :) |
Thanks for the response. I have a question though, why would we recreate the js player instead of just asking the existed player to call player.loadVideoById, possible via |
@hoangvvo the fix is published in
yep, this is definitely a better way to do it. I've added this to a todo list of APIs to port in a future update! (https://github.com/LonelyCpp/react-native-youtube-iframe/projects/3) |
Awesome, I'd love to open a PR for that too if you don't mind |
PRs are welcome! 💯 |
@LonelyCpp I can confirm that the new version works! I will try to put together a PR some time soon for the discussed refactor though. Thanks for the work! |
Thank you @LonelyCpp and @hoangvvo. Issue exist for iOS simulator. Working well in physical iOS device. @LonelyCpp @hoangvvo |
@vishwadeepghimirezph this was published with v2.2.0 try it out and let me know |
Describe the bug
If
videoId
is changed after the first render ofYoutubePlayer
, the video will not autoplay despiteplay
prop being trueTo Reproduce
https://snack.expo.dev/zeiphINXa
Steps to reproduce the behavior:
Toggle Render
-> see that video is autoplayed.Switch video
-> video is no longer playedToggle Render
twice to unmount and remount component -> video is autoplayedExpected behavior
Video should always be played or paused based on the
play
propI tested this on both Expo and bare React Native project.
Smartphone (Expo):
react-native-youtube-iframe
version 11.6.2react-native-webview
version ^2.1.1Expo
version 42.0.0Smartphone (Bare):
react-native-youtube-iframe
version 11.6.2react-native-webview
version ^2.1.1Expo
version 42.0.0Thank you.
The text was updated successfully, but these errors were encountered: