如何解决React本机视频不使用exoplayer播放音频
我正在开发一个React Native项目,我需要使用字幕,所以我开始使用带有React Native视频的exoplayer,问题是现在我的任何视频上都没有音频,有人知道我该如何解决它吗?
解决方法
我尝试使用react-native-exoplayer
,但是此模块存在很多问题,
现在我使用react-native-video
,并且发现它比exoplayer更好,您可以尝试从此link
这是来自react-native-video
的示例:
// Load the module
import Video from 'react-native-video';
// Within your render function,assuming you have a file called
// "background.mp4" in your project. You can include multiple videos
// on a single screen if you like.
<Video source={{uri: "background"}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}} // Store reference
onBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo}
selectedTextTrack={{ // Subtitles
type: "title",value: "English Subtitles"
}}
selectedVideoTrack={{
type: "resolution",value: 480
}}
/>
// Later on in your styles..
var styles = StyleSheet.create({
backgroundVideo: {
position: 'absolute',top: 0,left: 0,bottom: 0,right: 0,},});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。