如何缩放视频,以使视频在React Native中不会被裁剪?

时间:2019-01-28 08:33:36

标签: reactjs react-native react-native-video

我正在使用react-native-video

                <Video 
                    source={require('../../assets/imgs/video.mp4')}  
                    ref={(ref) => { this.player = ref }}                                     
                    repeat={true}
                    resizeMode="contain"
                    style={{
                        width: this.state.screenWidth,
                        height: this.state.heightScaled
                    }}
                    onLoad={response => {
                        const { width, height } = response.naturalSize;
                        const heightScaled = height * (this.state.screenWidth / width);

                        this.setState({ heightScaled: heightScaled });
                    }}

                />

这是我尝试过https://github.com/react-native-community/react-native-video/issues/746的一种解决方案,但不适用于我。有人可以告诉我如何使我的视频适合特定的高度吗?

0 个答案:

没有答案