TheWidlarzGroup / react-native-video

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

[BUG]: Android Cache fails on Loaded Resource #4243

Open lovegaoshi opened 1 month ago

lovegaoshi commented 1 month ago

Version

6.7.0

What platforms are you having the problem on?

Android

System Version

any

On what device are you experiencing the issue?

Real device, Simulator

Architecture

Old architecture

What happened?

loaded resource require("./asset/path") will fail to load in production when cache enables. this is because with cache enabled, RNV will attempt to load resources as http and a local res URI will be a malformed URI.

one solution could be an isUriLocalFile function, and use DefaultDataSource accordingly instead of http.

logs:

12526-12691 ExoPlayerImplInternal   com.noxplay.noxplayer                E  Playback error
                                                                                                      androidx.media3.exoplayer.ExoPlaybackException: Source error
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:736)
                                                                                                          at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:708)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                          at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                          at android.os.Looper.loop(Looper.java:294)
                                                                                                          at android.os.HandlerThread.run(HandlerThread.java:67)
                                                                                                      Caused by: androidx.media3.datasource.HttpDataSource$HttpDataSourceException: Malformed URL
                                                                                                          at androidx.media3.datasource.okhttp.OkHttpDataSource.makeRequest(OkHttpDataSource.java:369)
                                                                                                          at androidx.media3.datasource.okhttp.OkHttpDataSource.open(OkHttpDataSource.java:262)
                                                                                                          at androidx.media3.datasource.TeeDataSource.open(TeeDataSource.java:54)
                                                                                                          at androidx.media3.datasource.cache.CacheDataSource.openNextSource(CacheDataSource.java:802)
                                                                                                          at androidx.media3.datasource.cache.CacheDataSource.open(CacheDataSource.java:615)
                                                                                                          at androidx.media3.datasource.StatsDataSource.open(StatsDataSource.java:86)
                                                                                                          at androidx.media3.exoplayer.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1045)

Reproduction Link

the example app

Reproduction

run the example app in production with cache on, and load the local file

github-actions[bot] commented 1 month ago

Thank you for your bug report. We will review it and get back to you if we need more information.

freeboub commented 1 month ago

@lovegaoshi on js side we already have a property indicating if it is a local file (isAsset if I remember well). It would be easier to use this one !

github-actions[bot] commented 5 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.