React原生视频不使用exoplayer播放音频
React native video does not use play audio using exoplayer
我正在做一个 React Native 项目,我需要使用字幕,所以我开始使用 exoplayer 和 React Native 视频,问题是现在我的任何视频都没有音频,有人知道怎么办吗我解决了吗?
我尝试使用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,
},
});
我正在做一个 React Native 项目,我需要使用字幕,所以我开始使用 exoplayer 和 React Native 视频,问题是现在我的任何视频都没有音频,有人知道怎么办吗我解决了吗?
我尝试使用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,
},
});