在 `react-native-video` 中视频无法播放(卡住)。

huangapple go评论66阅读模式
英文:

Video not playing (stuck) in react-native-video

问题

我正在使用 react-native-cli,在我的应用中 react-native-video 不起作用。

在外部设备(安卓)上运行时,它显示一个空白空间,没有错误。

在安卓模拟器上运行时,视频屏幕显示第一帧,但视频没有播放(卡住)。

.mp4 文件存储在项目中。

<Video
  source={require('../../../storage/videos/video1.mp4')}
  resizeMode="cover"
  repeat={true}
  paused={false}
  style={{ height: 400, width: 400, position: 'absolute' }}
/>

文件结构:

- src
   -- components
        -- screens
           -- Video.js
    -- storage
        -- videos
            -- video1.mp4
- App.js

版本信息:

React Native: 0.70

React: 18.1

React Native Video: 5.2.1

英文:

I am using react-native-cli and in my app react-native-video doesn't work.

While running on external device (android) it shows a blank space without error

On running on android simulator, the video screen appears with the first frame but the video is not playing (stuck)

The .mp4 file is stored in the project itself.

&lt;Video
source={require(&#39;../../../storage/videos/video1.mp4&#39;)}
resizeMode=&quot;cover&quot;
repeat={true}
paused={false}
style={{height: 400, width: 400, position: &#39;absolute&#39;}}
/&gt;

File Structure:

- src
   -- components
        -- screens
           -- Video.js
    -- storage
        -- videos
            -- video1.mp4
- App.js

Versions

React native : 0.70

React : 18.1

React native video: 5.2.1

答案1

得分: 1

请添加 onError 方法来记录错误。

const videoError = error => {
  console.log('--videoError', error);
};

这可能有助于您获取确切的问题。
如果您正在从应用程序外部访问文件,还必须请求权限。

请阅读文档

英文:

Please add onError method to log the error.

 const videoError = error =&gt; {
console.log(&#39;--videoError&#39;, error);

};

That might help you to get the exact problem.
If you are accessing file from outside of the app, you have to ask for request permission as well.

Please read the Doc

huangapple
  • 本文由 发表于 2023年1月8日 23:25:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75048981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定