androidreact-nativereact-native-videoreact-native-cli

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


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.

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

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


Solution

  • Please add onError method to log the error.

     const videoError = error => {
    console.log('--videoError', 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