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 can't auto play #2

Closed
PhamMinhKha opened this issue Feb 8, 2020 · 11 comments
Closed

Video can't auto play #2

PhamMinhKha opened this issue Feb 8, 2020 · 11 comments
Labels
android bug Something isn't working

Comments

@PhamMinhKha
Copy link

PhamMinhKha commented Feb 8, 2020

Screenshot_1581136954
i try set play=true but not working
Screen Shot 2020-02-08 at 11 45 33 AM
Screen Shot 2020-02-08 at 11 46 18 AM

@LonelyCpp
Copy link
Owner

what platform are you trying it on? ios or android?

@PhamMinhKha
Copy link
Author

PhamMinhKha commented Feb 8, 2020

Screen Shot 2020-02-08 at 1 30 33 PM

what platform are you trying it on? ios or android?

I run on android. But you click button video play normal

@LonelyCpp LonelyCpp added the bug Something isn't working label Feb 8, 2020
@LonelyCpp
Copy link
Owner

Ok it looks like a bug on android. I will look into it and fix it ASAP. thanks :)

@LonelyCpp
Copy link
Owner

Hey, I've tried multiple things but there doesn't seem to be a very straightforward method to do this. This is due to autoplay rules enforced by chrome.

The HTML5

more info here - https://developers.google.com/youtube/iframe_api_reference#Mobile_considerations

A quick work around for this would be to change your user agent with webViewProps. I just pushed this with a minor path version of 1.1.3

<YoutubePlayer
        width={380}
        height={250}
        play={true}
        webViewProps={{
          userAgent:
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
        }} 
/>

Let me know if this works. Thanks :)

@PhamMinhKha
Copy link
Author

@LonelyCpp thank you very much. but it not work for me
Screenshot_1582522610
i use "react-native-youtube-iframe": "^1.1.3"
Screen Shot 2020-02-24 at 12 37 43 PM

@LonelyCpp
Copy link
Owner

LonelyCpp commented Mar 1, 2020

Hey, try adding mediaPlaybackRequiresUserAction: false to webViewProps, like -

webViewProps={{
          userAgent:
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
          mediaPlaybackRequiresUserAction: false,
        }}

@PhamMinhKha
Copy link
Author

thank you reply. i try your new code but not working

@kurroo10
Copy link

hello, no update on this ?

@LonelyCpp
Copy link
Owner

@bobbyrinaldy
Try the solution from this issue - #3
Give it a try and let me know if its not working

@kurroo10
Copy link

@bobbyrinaldy
Try the solution from this issue - #3
Give it a try and let me know if its not working

Seems working now, thanks. i have another question , should i make another issue or not ?

@LonelyCpp
Copy link
Owner

yes please

LonelyCpp added a commit that referenced this issue Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants