From 2bffbc0ebb4654948e54f91363ad24cabbeb6f97 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 17 Oct 2024 17:31:35 +0200 Subject: [PATCH] fix showing multiple languages in YT like stream --- .../net/newpipe/newplayer/NewPlayerImpl.kt | 18 ++++++++++++++---- .../net/newpipe/newplayer/data/StreamTrack.kt | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/new-player/src/main/java/net/newpipe/newplayer/NewPlayerImpl.kt b/new-player/src/main/java/net/newpipe/newplayer/NewPlayerImpl.kt index e970fcd2..59454034 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/NewPlayerImpl.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/NewPlayerImpl.kt @@ -212,11 +212,13 @@ class NewPlayerImpl( uniqueIdToStreamSelectionLookup[mediaItem.mediaId.toLong()]!! launchJobAndCollectError { mutableCurrentlyAvailableTracks.update { - TrackUtils.getNonDynamicTracksNonDuplicated( + val tracks = TrackUtils.getNonDynamicTracksNonDuplicated( repository.getStreams( streamSelection.item ) ) + Log.d(TAG, "New avialble tracks: \n" + tracks.joinToString()) + tracks } } } else { @@ -230,7 +232,10 @@ class NewPlayerImpl( val streamTracks = TrackUtils.streamTracksFromMedia3Tracks(tracks, onlySelectedTracks = true) .ifEmpty { - TrackUtils.streamTracksFromMedia3Tracks(tracks, onlySelectedTracks = false) + TrackUtils.streamTracksFromMedia3Tracks( + tracks, + onlySelectedTracks = false + ) } streamTracks.joinToString("\n") { it.toString() } Log.d( @@ -368,7 +373,10 @@ class NewPlayerImpl( override fun playStream(item: String, playMode: PlayMode) { launchJobAndCollectError { mutableCurrentlyAvailableTracks.update { - TrackUtils.getNonDynamicTracksNonDuplicated(repository.getStreams(item)) + val tracks = + TrackUtils.getNonDynamicTracksNonDuplicated(repository.getStreams(item)) + Log.d(TAG, "New avialble tracks: \n" + tracks.joinToString()) + tracks } val mediaSource = toMediaSource(item) @@ -446,7 +454,9 @@ class NewPlayerImpl( private suspend fun replaceCurrentItem(item: String) { mutableCurrentlyAvailableTracks.update { - TrackUtils.getNonDynamicTracksNonDuplicated(repository.getStreams(item)) + val tracks = TrackUtils.getNonDynamicTracksNonDuplicated(repository.getStreams(item)) + Log.d(TAG, "New avialble tracks: \n" + tracks.joinToString()) + tracks } val mediaSource = toMediaSource(item) diff --git a/new-player/src/main/java/net/newpipe/newplayer/data/StreamTrack.kt b/new-player/src/main/java/net/newpipe/newplayer/data/StreamTrack.kt index 3b812480..020eba64 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/data/StreamTrack.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/data/StreamTrack.kt @@ -98,6 +98,7 @@ data class AudioStreamTrack( override fun hashCode(): Int { var result = bitrate + result = 31 * result + language.hashCode() result = 31 * result + fileFormat.hashCode() return result }