google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.01k forks source link

Update DownloadRequest metadata without transitioning download back to STATE_QUEUED #7959

Open zubcoco opened 3 years ago

zubcoco commented 3 years ago

Hello,

Is it possible to update DownloadRequest data (byte[]) after the first initialization? I wanna store the bookmark and it will be updated after each playback.

I've tried to re-create a new DownloadRequest with all same parameters (except data who contains the new bookmark) but when I do that when my phone is offline, the state of the Download pass to STATE_QUEUED and I can't watch the video anymore.

Thanks for your help

ojw28 commented 2 years ago

I've tried to re-create a new DownloadRequest with all same parameters (except data who contains the new bookmark) but when I do that when my phone is offline, the state of the Download pass to STATE_QUEUED and I can't watch the video anymore.

I implemented an optimization that avoided going back to the queued state at one point (https://github.com/google/ExoPlayer/commit/f6928c0ef9a196fa0f6d298937ec207f4b1d3447), but had to roll the change back (https://github.com/google/ExoPlayer/commit/7cf0620231c01c4bdcb8dfbcfb0ae4c7f50d9642) because it caused crashes with the following stack trace:

E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:DownloadManager Process: com.google.android.apps.photos, PID: 30559 java.lang.IllegalStateException at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:81) at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.putDownload(DownloadManager.java:1224) at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.addDownload(DownloadManager.java:899) at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.handleMessage(DownloadManager.java:770) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) E/PhotosUEHandler: Uncaught exception on a background thread Thread[ExoPlayer:DownloadManager,5,main] java.lang.IllegalStateException at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:81) at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.putDownload(DownloadManager.java:1224) at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.addDownload(DownloadManager.java:899) at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.handleMessage(DownloadManager.java:770) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67)

Fixing this issue would probably be a case of re-landing that commit, with a fix for this issue.