Skip to content

Commit

Permalink
fix showing multiple languages in YT like stream
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Oct 17, 2024
1 parent ccb429c commit 2bffbc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions new-player/src/main/java/net/newpipe/newplayer/NewPlayerImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 2bffbc0

Please sign in to comment.