From 9032d9b3cf2d67d015ebd0f9cb827c351113035c Mon Sep 17 00:00:00 2001 From: Kayra Uylar Date: Wed, 5 Jul 2023 23:46:25 +0300 Subject: [PATCH] fix: storyboards making the app crash on short videos --- .../kuylar/lighttube/ui/VideoPlayerManager.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/dev/kuylar/lighttube/ui/VideoPlayerManager.kt b/app/src/main/java/dev/kuylar/lighttube/ui/VideoPlayerManager.kt index 842ecbc..69c2561 100644 --- a/app/src/main/java/dev/kuylar/lighttube/ui/VideoPlayerManager.kt +++ b/app/src/main/java/dev/kuylar/lighttube/ui/VideoPlayerManager.kt @@ -271,14 +271,18 @@ class VideoPlayerManager(private val activity: MainActivity) : Player.Listener, player.currentMediaItem?.mediaMetadata?.artist if (player.currentMediaItem?.mediaId != null) setSponsors(player.currentMediaItem?.mediaId!!) - if (player.currentMediaItem?.mediaMetadata?.extras != null) - setStoryboards( - player.currentMediaItem?.mediaMetadata?.extras?.getString("storyboard"), - player.currentMediaItem?.mediaMetadata?.extras?.getString("recommendedLevel"), - player.currentMediaItem?.mediaMetadata?.extras?.getLong("length") - ) - else + try { + if (player.currentMediaItem?.mediaMetadata?.extras != null) + setStoryboards( + player.currentMediaItem?.mediaMetadata?.extras?.getString("storyboard"), + player.currentMediaItem?.mediaMetadata?.extras?.getString("recommendedLevel"), + player.currentMediaItem?.mediaMetadata?.extras?.getLong("length") + ) + else + storyboard = null + } catch (e: Exception) { storyboard = null + } videoTracks = null }