I'm working on a Chromecast app for Android, and trying to get WebVTT captions/subtitles working.
I instantiate a MediaTrack object as follows:
MediaTrack track = new MediaTrack.Builder(0, MediaTrack.TYPE_TEXT)
.setContentId("http://www.example.com/example.vtt")
.setSubtype(MediaTrack.SUBTYPE_SUBTITLES)
.setContentType("ISO-8859-1")
.setLanguage(Locale.ENGLISH)
.setName("English")
.build();
and add it to a list.
I instantiate MediaInfo using the builder, and include reference the list of tracks using the .setMediaTracks method:
MediaInfo.Builder builder = new MediaInfo.Builder("http://www.example.com/example.m3u8")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("application/vnd.apple.mpegurl")
.setMetadata(movieMetadata)
.setMediaTracks(mediaTracks).build();
In my app I then start the CastControllerActivity that comes with the companion library:
mCastManager.startCastControllerActivity(this, mSelectedMedia, position, autoPlay);
After I've done this I set the active media track (only one in my case), and the text track style:
long [] activeTracks = new long[1];
activeTracks[0] = 0l;
mCastManager.getRemoteMediaPlayer()
.setActiveMediaTracks(mCastManager.getGoogleApiClient(), activeTracks)
.setResultCallback(new MediaResultCallback());
mCastManager.getRemoteMediaPlayer().setTextTrackStyle(
mCastManager.getGoogleApiClient(),
TextTrackStyle.fromSystemSettings(getBaseContext()));
When playing a clip containing subtitles the console shows the following:
[775.223s] [cast.receiver.MediaManager] Too many track IDs cast_receiver.js:18
[775.232s] [cast.receiver.MediaManager] Invalid track IDs cast_receiver.js:18
[775.238s] [cast.receiver.MediaManager] Sending error: INVALID_REQUEST INVALID_PARAMS
and the status code in the returned ResultCallback is SERVICE_MISSING - even though Google Play Services 5.0.89 is installed on both Android 4.4 devices I'm using when developing. The subtitles are hosted with CORS headers.
Any ideas or pointers?