首页 > 解决方案 > 在 react-native-video selectedVideoTrack 道具中不起作用

问题描述

我正在使用 react-native-video 来显示 hls 视频。

视频链接:- https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8

由于视频在 hls 中,我需要手动或自动更改视频的质量但我无法使用 react-native-video 来实现这一点。我也使用 reactjs 为网络完成了此操作,并且做得非常成功。我还通过添加 react-native.config.js 文件并粘贴这些代码为 react-native-video 设置了 exoplayer。


module.exports = {
  dependencies: {
    'react-native-video': {
      platforms: {
        android: {
          sourceDir: '../node_modules/react-native-video/android-exoplayer',
        },
      },
    },
  },
};



但我的问题是大多数道具在这个播放器中不起作用。由于 selectedVideoTrack 永远不会工作。

视频组件代码:

      <Video
          ref={videoRef}
          source={{
            uri: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
          }}
          resizeMode={'contain'}
          style={styles.fullscreenVideo}
          fullscreen={true}
          hls={true}
          rate={1.0}
          volume={1}
          muted={false}
          repeat={false}
          playInBackground={false}
          playWhenInactive={false}
          minLoadRetryCount={5}
          selectedVideoTrack={{
            type: 'resolution',
            value: 240,
          }}
          onError={(err) => {
            console.error(err);
          }}
          onSeek={(data) => {
            console.log(`seeked data `, data);
          }}
          onBuffer={(data) => {
            console.log('buffer data is ', data);
          }}
          reportBandwidth={true}
          onBandwidthUpdate={(data) => console.log('bandwidth updated', data)}
          selectedVideoTrack={{
            type: 'resolution',
            value: 360,
          }}

        />


如果有人可以建议我其他一些方法来实现这一点,请

标签: react-nativereact-native-videohls.js

解决方案


推荐阅读