视频的背景音频 react-native-video

Tho*_*cey 5 react-native react-native-ios react-native-video

我无法让 react-native-video 在后台播放 mp4 文件,它会播放 mp3 和音频文件,但拒绝继续播放视频。我已将 xcode 中的背景模式设置为打开,并选择了音频、播放和画中画,并传入了这些道具

playInBackground={true}
playWhenInactive={true}
ignoreSilentSwitch={'ignore'}
Run Code Online (Sandbox Code Playgroud)

当它是视频而不仅仅是音频时是否需要额外的配置?

Sat*_*esh 5

试试下面的代码:

<Video
    source={{uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4'}}
    style={{ width: 400, height: 400}}
    muted={false}
    repeat={false}
    resizeMode={"cover"}
    volume={1.0}
    rate={1.0}
    ignoreSilentSwitch={"ignore"}
    playWhenInactive={true}
    playInBackground={true}
  />
Run Code Online (Sandbox Code Playgroud)

Xcode在执行以下步骤后运行您的项目,而不仅仅是从React-Native packager.

设置CapabilitiesXcode

在此处输入图片说明