如果下载时没有网络,Exoplayer 会崩溃

问题描述 投票:0回答:1

Exoplayer,当我在下载视频时断开 wifi 连接时,应用程序崩溃并显示以下错误,我该怎么做才能使应用程序不会崩溃并给出一个 Toast,而不是没有互联网。 这是错误

                        Process: com.a.acs2, PID: 22492
                        java.lang.IllegalArgumentException: No such service ComponentInfo{com.a.acs2/androidx.media3.exoplayer.scheduler.PlatformScheduler$PlatformSchedulerService}
                            at android.os.Parcel.readException(Parcel.java:1560)
                            at android.os.Parcel.readException(Parcel.java:1509)
                            at android.app.job.IJobScheduler$Stub$Proxy.schedule(IJobScheduler.java:122)
                            at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:42)
                            at androidx.media3.exoplayer.scheduler.PlatformScheduler.schedule(PlatformScheduler.java:86)
                            at androidx.media3.exoplayer.offline.DownloadService$DownloadManagerHelper.updateScheduler(DownloadService.java:1020)
                            at androidx.media3.exoplayer.offline.DownloadService.onIdle(DownloadService.java:838)
                            at androidx.media3.exoplayer.offline.DownloadService.access$700(DownloadService.java:56)
                            at androidx.media3.exoplayer.offline.DownloadService$DownloadManagerHelper.onIdle(DownloadService.java:1065)
                            at androidx.media3.exoplayer.offline.DownloadManager.onMessageProcessed(DownloadManager.java:650)
                            at androidx.media3.exoplayer.offline.DownloadManager.handleMainMessage(DownloadManager.java:607)
                            at androidx.media3.exoplayer.offline.DownloadManager.$r8$lambda$Ljilo1rwNXzdYIqsr2zvGuwCKeY(DownloadManager.java)
                            at androidx.media3.exoplayer.offline.DownloadManager$$ExternalSyntheticLambda0.handleMessage(D8$$SyntheticClass:0)
                            at android.os.Handler.dispatchMessage(Handler.java:107)
                            at android.os.Looper.loop(Looper.java:224)
                            at android.app.ActivityThread.main(ActivityThread.java:5958)
                            at java.lang.reflect.Method.invoke(Native Method)
                            at java.lang.reflect.Method.invoke(Method.java:372)
                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)

我尝试过,但在 exoplayer 文档上找不到任何内容

android exoplayer android-media3
1个回答
0
投票

看起来当下载时网络连接丢失时,exoplayer 会尝试安排下载,可能会在连接恢复时恢复下载。 并且在尝试调用 PlatformSchedulerService 时缺少它。将其添加到您的清单中并重试

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<service android:name="androidx.media3.exoplayer.scheduler.PlatformScheduler$PlatformSchedulerService"
    android:permission="android.permission.BIND_JOB_SERVICE"
    android:exported="true"/>
© www.soinside.com 2019 - 2024. All rights reserved.