TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.13k stars 2.88k forks source link

[BUG]: Some video cant be load. OnLoad doesn't get called. isBuffering stuck at true. #4007

Open ng-ha opened 1 month ago

ng-ha commented 1 month ago

Version

6.3.0, 6.4.1

What platforms are you having the problem on?

Android

System Version

Android 14

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

Package works as expected in simulator.

But on real device (Pixel 6), after re-setState source, some "file:///" source cannot be load. onLoad, onReadyForDisplay doesn't get called. isBuffering is stuck at true.

First source logs:

LOG source {"uri": "file:///data/user/0/com.my.app/cache/244_d1baa119-05d9-4605-9d23-564fe94aaafb/2023121815451718545158505.mp4"} LOG onIdle LOG onLoadStart {} LOG onBuffer {"isBuffering": true} LOG onLoadStart {} LOG onVideoTracks {"videoTracks": [{"bitrate": 0, "codecs": "avc1.4D402A", "height": 1034, "index": 0, "rotation": 0, "selected": false, "trackId": "1", "width": 640}]} LOG onPlaybackStateChanged {"isPlaying": true} LOG onReadyForDisplay LOG onBuffer {"isBuffering": false} LOG onLoad {"audioTracks": [{"bitrate": 128000, "index": 0, "language": "und", "selected": true, "title": null, "type": "audio/mp4a-latm"}], "canPlayFastForward": true, "canPlayReverse": true, "canPlaySlowForward": true, "canPlaySlowReverse": true, "canStepBackward": true, "canStepForward": true, "currentTime": 0, "duration": 26.024, "naturalSize": {"height": 1034, "orientation": "portrait", "width": 640}, "textTracks": [], "trackId": "1", "videoTracks": [{"bitrate": 0, "codecs": "avc1.4D402A", "height": 1034, "index": 0, "rotation": 0, "selected": false, "trackId": "1", "width": 640}]}

Then, set second source, that second one can't be played. Second source logs:

LOG source {"uri": "file:///data/user/0/com.my.app/cache/244_d1baa119-05d9-4605-9d23-564fe94aaafb/1720928478104.mp4"} LOG onBuffer {"isBuffering": true} LOG onVideoTracks {"videoTracks": []} LOG onLoadStart {} LOG onVideoTracks {"videoTracks": [{"bitrate": 0, "codecs": "avc1.4D0029", "height": 868, "index": 0, "rotation": 0, "selected": false, "trackId": "1", "width": 640}]}

If i set that second source first ( as initial source), video is played as intended. Or i change the first source to another video, then re-set source to second one, both are played as intended. Very strange behaviour.

Reproduction

repository link

Reproduction

<Video
            ref={videoRef}
            source={source}
            onIdle={() => console.log('onIdle')}
            onLoad={e => console.log('onLoad', e)}
            onLoadStart={e => console.log('onLoadStart', e)}
            onReadyForDisplay={() => console.log('onReadyForDisplay')}
            onError={e => console.log('onError', e)}
            onBuffer={e => console.log('onBuffer', e)}
            onVideoTracks={e => console.log('onVideoTracks', e)}
            onPlaybackStateChanged={e =>
              console.log('onPlaybackStateChanged', e)
            }
            style={{
              width: 1034,
              height:  640,
            }}
          />
freeboub commented 1 month ago

Did you have a look to the logcat ? maybe you will have more information inside this log...

YangJonghun commented 1 month ago

This happens when inserting another prop into a loaded player. It looks like Android media3 issue, and I was expecting it would be fixed in #3784 But it still seems to happen. Tricky fix is to pass source an integer(not decimal) greater than 0 for startPosition, such as 1 on Android. (currently there is a bug in media3 where it buffers indefinitely if you treat it as 0 or null)

JCYDigitalinnov commented 1 month ago

This happens when inserting another prop into a loaded player. It looks like Android media3 issue, and I was expecting it would be fixed in #3784 But it still seems to happen. Tricky fix is to pass source an integer(not decimal) greater than 0 for startPosition, such as 1 on Android. (currently there is a bug in media3 where it buffers indefinitely if you treat it as 0 or null)

Thanks for the temporary fix! This works for me, for now.

github-actions[bot] commented 6 days ago

This issue is stale because it has been open for 30 days with no activity. If there won't be any activity in the next 14 days, this issue will be closed automatically.