I need to change audio track from Android. As mentioned in the official cast doc, I've tried to add the tracks using the following code:
MediaTrack audio1 = new MediaTrack.Builder(1, MediaTrack.TYPE_AUDIO)
.setName("Audio 1")
.setContentId(trackId)
.setLanguage("en")
.build();
MediaTrack audio2 = new MediaTrack.Builder(2, MediaTrack.TYPE_AUDIO)
.setName("Audio 2")
.setContentId(trackId2)
.setLanguage("it")
.build();
List tracks = new ArrayList();
tracks.add(audio1);
tracks.add(audio2);
MediaInfo mediaInfo = MediaInfo.Builder(url)
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType(getContentType())
.setMetadata(getMetadata())
.setMediaTracks(tracks)
.build();
For setContentId I've retrieved tracks ids using ffmpeg and mediainfo, but it doesn't work.
I also tried to extract audio tracks and passed the url to audio file in setContentId, but it still not working.
For change the current track, I've tried using the setActiveMediaTracks method, but I've also tried changing the track from the CAF js code:
playerManager.addEventListener(
cast.framework.events.EventType.PLAYER_LOAD_COMPLETE, () => {
const audioTracksManager = playerManager.getAudioTracksManager();
// Get all audio tracks
const tracks = audioTracksManager.getTracks();
// Choose the first audio track to be active by specifying its ID
audioTracksManager.setActiveById(tracks[0].trackId);
});
Anyone have some idea?