-
Notifications
You must be signed in to change notification settings - Fork 156
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 on Web #340
Comments
To add, having YouTube autoplay in a web browser is certainly possible, as can be seen in this jsfiddle: https://jsfiddle.net/7kqr4ac0/1/ . This is the code example:
JS:
Using the YouTube API with JS in this way does get videos to autoplay. If react-native-youtube-iframe can inject the player vars of autoplay (set to 1) and mute (set to 1), along with the already working "controls" property (set to 0), then I believe autoplay would work. |
Describe the bug
There doesn't appear to be any way to get a YouTube video to autoplay on Web (autoplay works fine on Android)
To Reproduce
`const playerRef = useRef(null);
const [playing, setPlaying] = useState(true);
return (
<YoutubePlayer
ref={playerRef}
height={height}
play={playing}
videoId={'SGHNi6fJjZE'}
mute={true}
onReady={()=>{setPlaying(true)}}
initialPlayerParams={{controls:false, loop:true}}
webViewProps={{onLoad: ()=>(setPlaying(true))}}
/>
`
Expected behavior
The play prop set to true is expected to make the video play when ready. The onReady prop and webViewProp onLoad assigned to a function which sets the play prop to true should cause the video to play when the video is ready.
Additional context
The onReady prop doesn't appear to fire at all. The webViewProp onLoad does appear to fire, but setting the play prop to true or false doesn't do anything it appears.
A Button component trying to set the play prop on the player doesn't do anything either. However, I'm really only interested in autoplay and loop, but it does not appear to work on Web.
The text was updated successfully, but these errors were encountered: