CastPlayer send correct selected audio track to receiver.
See original GitHub issueI have media with multiple audio tracks in the manifest, but when I create the MediaItem, I can’t see a way to specify the initial audio track. Besides, I would like to be able to change the audio track in the CastPlayer during the playback, in case the user uses the sender to change the audio.
Exoplayer version: 2.12.1
// If I don't set the metadata, the title doesn't appear in the castMiniController, whereas it did appear in exoplayer 2.11.x
MediaMetadata metadata = new MediaMetadata.Builder()
.setTitle(currentShow.getFormattedTitle())
.build();
MediaItem mediaItem = new MediaItem.Builder()
.setUri(uri)
.setDrmLicenseRequestHeaders(hm)
.setDrmLicenseUri(drmLicenseUrl)
.setDrmUuid(C.WIDEVINE_UUID)
.setMediaId(currentShow.getFormattedTitle())
.setMediaMetadata(metadata)
.setMimeType(mimeType)
.build();
I can’t obtain the trackSelector in the CastPlayer’s implementation, as it basically returns null:
On the other hand, when we change audio tracks in settings for the local player, we do the following:
public void onAudioSelected(AudioCheckableItem audioItem) {
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo == null) {
return;
}
int rendererIndex = -1;
for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(i);
if (trackGroups.length != 0) {
switch (player.getRendererType(i)) {
case C.TRACK_TYPE_AUDIO:
rendererIndex = i;
break;
case C.TRACK_TYPE_VIDEO:
case C.TRACK_TYPE_TEXT:
default:
break;
}
}
}
if (rendererIndex == -1)
return;
TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
DefaultTrackSelector.ParametersBuilder parametersBuilder = trackSelector.buildUponParameters();
parametersBuilder.setSelectionOverride(rendererIndex, trackGroups, new DefaultTrackSelector.SelectionOverride(audioItem.getGroupIndex(), audioItem.getTrackIndex()));
trackSelector.setParameters(parametersBuilder);
}
I can’t find any documentation about this and the only question related (but with subtitles) is at SO and doesn’t have any answers: https://stackoverflow.com/questions/61396776/change-subtitle-using-castplayer
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to select audio / subtitle in a custom cast app on a mpd ...
I'm using a .mpd file containing already the video, the audio tracks, and subtitles. So my question is how to add a selection...
Read more >MEDIA_STATUS message: activeTrackIds is empty (after track ...
play MPD with multiple audio-tracks change selected audio track chromcast plays new selected audio-track with video. MEDIA_STATUS has NO activeTrackIds data
Read more >Tracks | Cast - Google Developers
Audio tracks. For audio track selection, the Web Receiver SDK provides a AudioTracksManager class that simplifies and streamlines track ...
Read more >Working with Audio in the Timeline Viewer - Peachpit
Page Down and Page Up keyboard shortcuts move the CTI right or left ... Simply right-click in the Timeline and choose Add Audio...
Read more >Export regions as audio files in Logic Pro - Apple Support
For a single region, enter a name for the exported audio file, and browse to a location to save it. When multiple regions...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think you need to fork the library. You need to instantiate the
CastPlayer
by passing your customMediaItemConverter
implementation. I think looking into theDefaultMediaItemConverter
is a good idea. Your implementation can delegate toDefaultMediaItemConverter
so you only need to implementtoMediaQueueItem
to add the thumbnail.Hi @marcbaechinger thanks for the reply. Apologies, I couldn’t answer earlier. I will study what you said.
As for the second part, I guess I have to do that custom MediaItemConverter anyway to support the extended controls view in the sender. If there is any guide on how to implement a custom MediaItemConverter, let me know. For the moment I will fork the library and copy the behaviour of DefaultMediaItemConverter. Thanks.
Perhaps it was too soon to deprecate the method addItem that used a MediaQueueItem in CastPlayer.