問題
我正在嘗試在反應本機應用程式(適用于 android TV)中流式傳輸 m3u8 檔案,但出現此錯誤:
LOG {"error": {"errorCode": "22004", "errorException": "com.google.android.exoplayer2.ExoPlaybackException: Source error", "errorStackTrace": "com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
at com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource.open(OkHttpDataSource.java:329)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:99)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:62)
at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:174)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
", "errorString": "ExoPlaybackException: ERROR_CODE_IO_BAD_HTTP_STATUS"}}
我不知道java,所以從上面的回溯中我猜服務器正在回應HTTP 403,因此它無法流式傳輸檔案。
我試過的
- 這不是一個解決方案,但我嘗試切換到
react-native-video-player而不是,react-native-video但沒有奏效。 - 我嘗試將
type: 'm3u8'andtype: 'hls'與 uri 一起傳遞到 video 標簽的 source 屬性中,但這根本沒有幫助。 - 試圖檢查另一個 m3u8 url(即來自另一個域/服務器)是否正在作業,并且它正在作業。
- 降級
react-native-video版本,問題仍然存在,并出現不同的錯誤訊息。
我決定通過 ssh 連接到我的 android TV 并直接使用 curl 來獲取 m3u8 檔案,它的回應如下:
curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
此外,我在 github 上發現的許多具有類似問題的問題都包含一個在直接使用 curl 獲取時給出相同回應的 URL。有趣的是,如果我在 JS 中使用 fetch API 來控制臺記錄來自 m3u8 url 的回應,它可以完美運行。所以我猜問題出在exoplayer的某個地方。
眼鏡
- 反應原生:'npm:[email protected]'
- 反應原生視頻:'^6.0.0-alpha.3'
- Android TV:在運行 Android TV(我認為是 LineageOS)的 Raspberry Pi 和具有相同結果的實際 android 電視機頂盒上進行了測驗。
uj5u.com熱心網友回復:
問題出在用戶代理標頭上,exoplayer 設定了一個導致 HTTP 403 的用戶代理。我不得不使用代理來解決這個問題,但仍然不知道為什么 android studio 沒有顯示請求有錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/525372.html
