question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CastPlayer send correct selected audio track to receiver.

See original GitHub issue

I 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: imagen

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:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
marcbaechingercommented, Nov 12, 2020

I don’t think you need to fork the library. You need to instantiate the CastPlayer by passing your custom MediaItemConverter implementation. I think looking into the DefaultMediaItemConverter is a good idea. Your implementation can delegate to DefaultMediaItemConverter so you only need to implement toMediaQueueItem to add the thumbnail.

0reactions
aiescolacommented, Nov 12, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found