Open UsmanAhsanPs19 opened 4 years ago
@ UsmanAhsanPs19 have you tried adding aspectRatio of 16:9 to the video. I think it works!! You can set it like,
aspectRatio: 16/9
and remember to not to add a height, since it might cause an UNAUTHORIZED_OVERLAY in android and cause the video to freeze in case of inappropriate dimensions, since it adjusts the width relative to it's height.
OR 'aspectRatio: Dimensions.get("screen").height/Dimensions.get("screen").width' should solve the problem.
I am making an app in which I want to set the top view height according to the video height. If the video nature is horizontal then set its height according to the horizontal height and if its vertical then set height vertically as youtube built in app work. Belwo is my react native youtube code. it work good if video is horizontal but if video is portrait than video is stretched. I want to set the height according to the video height. <YouTube apiKey="my_api_key" //videoId={this.props.videoId} // The YouTube video ID videoId={'rWvnZG2z7AU'} play={false} // control playback of video with true/false fullscreen={false} // control whether the video should play in fullscreen or inline loop={this.props.loop} // control whether the video should loop when ended onChangeState={e => console.warn(e.state)} onChangeQuality={e => this.setState({quality: e.quality})} onError={e => this.setState({error: e.error})} showFullscreenButton={true} resumePlayAndroid={false} //because app crashed after come back on the same screen controls={2} showFullscreenButton={true} style={{ flex: 1, width:'100%', alignSelf:'baseline', aspectRatio:1 }} />
Sorry for my English.