如何将字幕加载到chromecast Media Player?

List<MediaTrack> subs = new ArrayList<MediaTrack>();
... MediaTrack.Builder(long trackid, MediaTrack.TYPE_TEXT);


我不知道如何获取trackid。

编辑:

long subId = 12;
long[] subIds = {subId};
MediaTrack track = new MediaTrack.Builder(subId,MediaTrack.TYPE_TEXT).setContentId("http://example.com/abc.srt").build();
    subs.add(track);
...
mediaInfo.setMediaTracks(subs);
...
mRemoteMediaPlayer.setActiveMediaTracks(mApiClient,subIds);


字幕未显示

最佳答案

根据新文档-您必须将语言设置为字幕:

  MediaTrack englishSubtitle = new MediaTrack.Builder(1 /* ID */, MediaTrack.TYPE_TEXT)
  .setName("English Subtitle")
  .setSubtype(MediaTrack.SUBTYPE_SUBTITLE)
  .setContentId("https://some-url/caption_en.vtt")
  /* language is required for subtitle type but optional otherwise */
  .setLanguage("en-US")
  .build();

08-05 08:30