TheWidlarzGroup / react-native-video

A <Video /> component for react-native
https://docs.thewidlarzgroup.com/react-native-video/
MIT License
7.21k stars 2.9k forks source link

[BUG]: `v6.6.2` android can't play video after build, `Playback error ExoPlaybackException: Source error` #4195

Open gyhyfj opened 1 month ago

gyhyfj commented 1 month ago

Version

6.6.2

What platforms are you having the problem on?

Android

System Version

12

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

I'm using react-native-video@6.6.2 on react-native@0.73.5, to display required asset video. Everything works well on dev, but after build, video and postes can't display, with error:

E  Playback error
     androidx.media3.exoplayer.ExoPlaybackException: Source error
         at androidx.media3.exoplayer.O000O0O0OO0OO0OO00O.O000O0O0O0OO0O0O0OO(SourceFile:17)
         at androidx.media3.exoplayer.O000O0O0OO0OO0OO00O.handleMessage(SourceFile:321)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loopOnce(Looper.java:233)
         at android.os.Looper.loop(Looper.java:344)
         at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: androidx.media3.datasource.HttpDataSource$HttpDataSourceException: Malformed URL
         at O000O0OO0OOO00O0O0O.O000O0O00OO0O0OOO0O.O000O0O00OOO0O0O0OO(SourceFile:173)
         at O000O0OO0OOO00O0O0O.O000O0O00OO0O0OOO0O.O000O0O00OO0O0OOO0O(SourceFile:12)
         at O000O0OO0OO0OO0O0O0.O000O0O00OOOO0O0O0O.O000O0O00OO0O0OOO0O(SourceFile:3)
         at androidx.media3.datasource.cache.O000O0O00OO0O0OOO0O.O000O0O00OOO0OO0O0O(SourceFile:279)
         at androidx.media3.datasource.cache.O000O0O00OO0O0OOO0O.O000O0O00OO0O0OOO0O(SourceFile:127)
         at O000O0OO0OO0OO0O0O0.O000O0O00OOO0OOO0O0.O000O0O00OO0O0OOO0O(SourceFile:13)
         at androidx.media3.exoplayer.source.O000O0O0O0O0OOO00OO$O000O0O00OO0O0OOOO0.load(SourceFile:26)
         at androidx.media3.exoplayer.upstream.Loader$O000O0O00OO0OO0OO0O.run(SourceFile:51)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
         at java.lang.Thread.run(Thread.java:1012)

Reproduction Link

repository link

Reproduction

props is:

const defaultConfig: ReactVideoProps = {
  allowsExternalPlayback: false,
  controls: false,
  disableFocus: true,
  disableDisconnectError: true, 
  focusable: false,
  fullscreenAutorotate: false,
  hideShutterView: true,
  minLoadRetryCount: 3,
  muted: true,
  pictureInPicture: false,
  playInBackground: false, 
  playWhenInactive: true, 
  preventsDisplaySleepDuringVideoPlayback: false,

  bufferConfig: /* android only */ {
    cacheSizeMB: 100,
  },
  repeat: true,
  resizeMode: 'cover',
  viewType: 1, //  TEXTURE = 0,  SURFACE = 1,  (default, cannot be animated and overlay)  SURFACE_SECURE = 2
}

source is

source={{uri:require('~/assets/test.mp4')}}
github-actions[bot] commented 1 month ago

Thank you for your issue report. Please note that the following information is missing or incomplete:

Please update your issue with this information to help us address it more effectively.

Note: issues without complete information have a lower priority

freeboub commented 1 month ago

I don't think urls with ~ are supported ...

gyhyfj commented 1 month ago

@freeboub I found that remove bufferConfig can solve this problem

gyhyfj commented 1 month ago

I don't think urls with ~ are supported ...

It's still available NodeRequire, transformed by babel. However I think it's wired to pass it to uri since v6, which is different from Image componet

freeboub commented 1 month ago

@gyhyfj It looks like the issue is the following: we try to cache a local file playback, it doesn't make sense, but I agree this configuration should work in the package. My remark was about the file path starting with ~, but if it works without bufferingConfig, it is a valid workaround

freeboub commented 1 month ago

I don't reproduce the issue with the sample app ... Did you try to put a path without '~' inside, and with a relative path to your project ? The error is : "Malformed URL" I really suspect an issue with your path which may not be correctly translated.

If it still not working, can you please share a sample which reproduce the issue ?

freeboub commented 1 month ago

any update ?

gyhyfj commented 3 weeks ago

@gyhyfj It looks like the issue is the following: we try to cache a local file playback, it doesn't make sense, but I agree this configuration should work in the package. My remark was about the file path starting with ~, but if it works without bufferingConfig, it is a valid workaround

I replace ~ path with relative path, after build, it still throw the same error

freeboub commented 3 weeks ago

Can you try without cacheSize property ?

gyhyfj commented 3 weeks ago

Can you try without cacheSize property ?

It works well without cahceSize property. But the default cacheSize is 0.

gyhyfj commented 3 weeks ago

I don't think urls with ~ are supported ...

Also if I use source={require()} rather than source={{uri: require()}}, it throw that same error