-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
868 handle text and audio tracks with castplayer (#879)
Co-authored-by: Gaëtan Muller <[email protected]>
- Loading branch information
Showing
5 changed files
with
243 additions
and
40 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/CastTrackSelector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.cast | ||
|
||
import androidx.media3.common.TrackSelectionParameters | ||
import androidx.media3.common.Tracks | ||
|
||
/** | ||
* Cast track selector | ||
*/ | ||
interface CastTrackSelector { | ||
|
||
/** | ||
* Returns the indices of the currently selected media tracks. | ||
* | ||
* This function determines the active tracks based on the provided [parameters] | ||
* and the available [tracks]. It returns an array containing the indices of these tracks. | ||
* | ||
* @param parameters The track selection preferences. | ||
* @param tracks The available media tracks. | ||
* @return An array of track indices for the selected tracks. Returns an empty array if no tracks are selected. | ||
* @see TrackSelectionParameters | ||
* @see Tracks | ||
*/ | ||
fun getActiveMediaTracks(parameters: TrackSelectionParameters, tracks: Tracks): LongArray | ||
} |
25 changes: 25 additions & 0 deletions
25
pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/DefaultCastTrackSelector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.cast | ||
|
||
import androidx.media3.common.TrackSelectionOverride | ||
import androidx.media3.common.TrackSelectionParameters | ||
import androidx.media3.common.Tracks | ||
|
||
/** | ||
* Default cast track selector | ||
* Support only [TrackSelectionOverride] from [TrackSelectionParameters.overrides]. | ||
*/ | ||
class DefaultCastTrackSelector : CastTrackSelector { | ||
|
||
override fun getActiveMediaTracks( | ||
parameters: TrackSelectionParameters, | ||
tracks: Tracks | ||
): LongArray { | ||
return parameters.overrides.keys | ||
.mapNotNull { it.id.toLongOrNull() } | ||
.toLongArray() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.