You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native应用从URL流式播放音频失败,求解决方法

React Native 流式播放音频/视频问题求助
  • 核心需求:在React Native应用中流式播放YouTube视频或远程.mp3 URL的音频,禁止下载音频文件,必须从互联网直接流播。
  • 已尝试库:Expo AV、React-Native-Sound-Player、react-native-video,均无法正常播放。
  • 测试用MP3地址:https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3

React-Native-Sound-Player 报错详情

调用loadUrl()加载音频时,抛出错误:TypeError: Cannot read property 'loadUrl' of null,代码片段:

try {
  currentSong = SoundPlayer.loadUrl('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3');
} catch (e) {
  console.error(e);
}

react-native-video 报错详情

尝试播放远程视频时,抛出错误:TypeError: Cannot read property 'Constants' of null,代码片段:

<Video 
  source={{uri: "https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"}}
  ref={(ref) => { this.player = ref }}
  onBuffer={this.onBuffer}
  onError={this.videoError}
  style={styles.video} 
/> 

求助:是否有开发者实现过React Native中从URL流式播放音频的功能?这一需求是否可行?欢迎提供任何解决建议或方案。

内容的提问来源于stack exchange,提问作者A. Eddy Nangia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 22:14:55