react-native-youtube-iframe icon indicating copy to clipboard operation
react-native-youtube-iframe copied to clipboard

Autoplay does not work on Web

Open Oranjoose opened this issue 1 year ago • 1 comments

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 ( <View style={styles.layout}> <YoutubePlayer ref={playerRef} height={height} play={playing} videoId={'SGHNi6fJjZE'} mute={true} onReady={()=>{setPlaying(true)}} initialPlayerParams={{controls:false, loop:true}} webViewProps={{onLoad: ()=>(setPlaying(true))}} /> </View>`

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.

Oranjoose avatar Jul 01 '24 15:07 Oranjoose