【问题标题】:react native video stops right away反应原生视频立即停止
【发布时间】:2019-08-05 20:33:03
【问题描述】:

当我尝试播放直播时,播放器立即停止。 从日志中,我看到视频一开始就调用了 onEnd si。

奇怪的是它只发生在实际手机上,它在模拟器上运行良好。尝试使用 Android Studio Emulator 和 Genymotion,都可以正常工作。 调试和发布都无法在实际手机上播放直播。

<TouchableOpacity style={VideoPlayerStyles.fullScreen} onPress={this.handleVideoTap}>
  <Video source={{ uri: this.props.channelSrc }}
    style={VideoPlayerStyles.fullScreen}
    rate={this.state.rate}
    paused={this.state.paused}
    volume={this.state.volume}
    muted={this.state.muted}
    resizeMode={this.state.resizeMode}
    onLoad={this.onLoad}
    onProgress={this.onProgress}
    onEnd={this.onEnd}
    repeat={false}
    fullscreen={true}
    ref={ref => {
        this.player = ref
    }}
      onBuffer={this.onBuffer} 
    onError={this.videoError} />
</TouchableOpacity>

【问题讨论】:

  • 您的视频网址 (this.props.channelSrc) 是否可以通过移动网络访问?
  • 播放失败时,您是否在 Android Studio 中看到任何调试信息?此外,它是否对所有视频都这样做(您可以尝试其他 URL)吗?
  • 它只适用于直播,适用于电影。视频最多只有一秒长,没有错误。用 rn-fetch-blob 试过,视频长约 20-30 秒。链接也适用于 react native vlc。
  • 你可以分享流媒体链接吗?
  • @Gowtham 任何 IPTV 直播都有同样的问题,我可以私下分享。

标签: android react-native react-native-video


【解决方案1】:

检查您的视频 URI 是否可以从您的设备访问。

您可能正在尝试访问可从在台式机/笔记本电脑上运行的模拟器访问的 URI,因为台式机/笔记本电脑和模拟器将连接到同一网络。

在移动设备上打开 Chrome 并尝试访问视频 URI。如果它不起作用,那么它的网络问题。

【讨论】:

  • 是的,我测试的是直接url而不是props a。它在模拟器上也能正常工作,电影也能正常工作。只是直播一开始就停止。我尝试使用本地 vlc 播放器,链接工作正常,但是播放器已经过时,而且它会产生更多错误,甚至是编译错误。
【解决方案2】:

根据

汤姆·沃尔特斯

回答

react-native-video onEnd is called when video starts

onEnd={this.onEnd}

到 当组件被渲染时,当 prop 实际期望一个函数时,将立即执行 console.log

要修复它,请使用:

onEnd={() => this.onEnd}

【讨论】:

  • 这只是一个绑定问题,并不是我遇到的问题。
猜你喜欢
  • 2021-11-19
  • 1970-01-01
  • 2022-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多