Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Autoplay is not working with Youtube shorts videos in WebView Component in iOS - React Native

$
0
0

I'm trying to play youtube shorts videos with a webview component in IOS in React Native App. The autoloop (autoloop=1) and controls (controls=1) commands added to the URL seem to work, however the autoplay is not causing the video to play automatically when the video is loaded.

It is necessary for the user to click on the video to start playing. I had found that autoplay was only possible if the video started on mute, but even adding the command (mute=1) does not work. How do I set up video autoplay?

import * as React from 'react';import { StyleSheet, Text, View, ScrollView, Dimensions, FlatList , Button,Pressable, Image,SafeAreaView,TouchableWithoutFeedback } from 'react-native';import {NavigationContainer} from '@react-navigation/native';import {createNativeStackNavigator} from '@react-navigation/native-stack';import {WebView} from 'react-native-webview'export default class WebViewTest extends React.Component{  constructor(props) {    super(props);  }  render(){    return(<View style={{ flex: 1 }}><TouchableWithoutFeedback ref={(ref) => { this.touchableRef = ref; }} onPress={this.handleClick}><SafeAreaView style={{          //backgroundColor:'blue',          backgroundColor:'white',          flex:1}}><WebView style={{height:100}}          ref={this.webViewRef}          allowsInlineMediaPlayback={true}          allowsFullscreenVideo={false}          source={{uri: 'https://www.youtube.com/embed/SChKKUquCIE??autoplay=1&loop=1&mute=1&controls=0&playlist=SChKKUquCIE'}}          originWhiteList={['https://www.youtube.com']}/><View style={{height:120,width:'100%',position:'absolute',top:0,left:0}}></View><View style={{height:70,width:'100%',position:'absolute',bottom:0,left:0}}></View></SafeAreaView></TouchableWithoutFeedback></View>    );  }}

I basically tried to add the parameters in the url indicated by the youtube api: https://developers.google.com/youtube/player_parameters


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>