У меня есть cra * sh в производстве, так как у меня появилась возможность транслировать видео HLS из моего приложения в Chromecast с использованием ExoPlayer Cast Extension. Это происходит на 100% Android 9 и на различных устройствах (Xiaomi Redmi K20, Samsung Galaxy S9, ZenFone Max Pro M2 и т. Д. c ...)
Вот моя реализация расширения для приведения ExoPlayer:
private fun initCast() {
mediaRouteButton = view?.findViewById(R.id.media_route_button)
CastButtonFactory.setUpMediaRouteButton(activity?.applicationContext, mediaRouteButton)
val castContext = CastContext.getSharedInstance()
}
private fun prepareCast(title: String) {
CastContext.getSharedInstance()?.let {
castPlayer = CastPlayer(it)
}
val movieMetadata = MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE)
movieMetadata.putString(MediaMetadata.KEY_TITLE, title)
videoThumbnail?.let {
movieMetadata.addImage(WebImage(Uri.parse(it)))
}
val mediaInfo = MediaInfo.Builder(videoUrl)
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType(MimeTypes.VIDEO_UNKNOWN)
.setMetadata(movieMetadata).build()
val mediaItems = arrayOf(MediaQueueItem.Builder(mediaInfo).build())
castPlayer?.setSessionAvailabilityListener(object : SessionAvailabilityListener {
override fun onCastSessionAvailable() {
castPlayer?.loadItems(mediaItems, 0, playerViewModel.getVideoPosition(), Player.REPEAT_MODE_OFF)
playerViewModel.pauseVideo()
}
override fun onCastSessionUnavailable() {
castPlayer?.currentPosition?.let {
playerViewModel.setVideoPosition(it)
playerViewModel.playVideo()
}
})
}
Вот трассировка стека:
Fatal Exception: java.lang.NullPointerException: Attempt to write to field 'boolean kj1.a' on a null object reference
at com.google.android.gms.internal.cast.zzka.zzhx(zzka.java:38)
at com.google.android.gms.internal.cast.zzmd.zza(zzmd.java:3)
at com.google.android.gms.internal.cast.zzms.zze(zzms.java:2518)
at com.google.android.gms.internal.cast.zzlf$zza.zziw(zzlf.java:20)
at com.google.android.gms.internal.cast.zzlf$zza.zziy(zzlf.java:41)
at com.google.android.gms.internal.cast.zzlf$zza.zzix(zzlf.java:23)
at com.google.android.gms.internal.cast.zzlf$zza.zziz(zzlf.java:42)
at com.google.android.gms.internal.cast.zzbc.zza(zzbc.java:1)
at com.google.android.gms.internal.cast.zzba.onSessionStarting(zzba.java:49)
at com.google.android.gms.cast.framework.zzag.zza(zzag.java:10)
at com.google.android.gms.cast.framework.zzz.dispatchTransaction(zzz.java:13)
at com.google.android.gms.internal.cast.zza.onTransact(zza.java:13)
at android.os.Binder.transact(Binder.java:667)
at androidx.mediarouter.media.MediaRouter$GlobalMediaRouter$MediaSessionRecord$1$2.b(MediaRouter.java:14)
at androidx.mediarouter.media.RegisteredMediaRouteProvider$Connection$1.a(RegisteredMediaRouteProvider.java:39)
at com.bumptech.glide.load.resource.gif.GifFrameLoader.b(GifFrameLoader.java:50)
at com.bumptech.glide.manager.TargetTracker.a(TargetTracker.java:42)
at androidx.media.AudioAttributesImpl.c(AudioAttributesImpl.java:21)
at androidx.fragment.app.FragmentState.a(FragmentState.java:11)
at androidx.preference.PreferenceGroupAdapter.onTransact(PreferenceGroupAdapter.java:5)
at android.os.Binder.transact(Binder.java:667)
at com.google.android.gms.internal.cast.zzb.zzb(zzb.java:21)
at com.google.android.gms.internal.cast.zzaf.zzd(zzaf.java:21)
at com.google.android.gms.internal.cast.zzaq.onRouteSelected(zzaq.java:4)
at androidx.mediarouter.media.MediaRouter$GlobalMediaRouter$CallbackHandler.invokeCallback(MediaRouter.java:3218)
at androidx.mediarouter.media.MediaRouter$GlobalMediaRouter$CallbackHandler.handleMessage(MediaRouter.java:3168)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6745)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
У меня есть проблема в github ExoPlayer и в github Glide без удачи.
Кто-нибудь имеет представление о причине этого кр sh?