0
votes

I am trying to include subtitles on a Chromecast application I'm building.

  1. I am using the default receiver application.
  2. I am writing a chrome sender application using v1 of the chrome sender api.

According to the Chromecast Sender Api documentation, I should be passing in an array of track objects into the chrome.cast.media.MediaInfo object. My issue is, whenever I call chrome.cast.media.Track(trackId, trackType), it returns undefined. When I look through the public methods in chrome.cast.media, through console, I don't see anything related to Track. Link to documentation here.

Below is my loadMedia method where I try to include an array of track objects along with my LoadRequest as specified by the cast api. The commented out code is how I've seen closed-captioning handled in one of the cast Github repositories, but unfortunately I believe you have to handle that customData in your own custom receiver application.

Are subtitles through the chrome sender SDK possible yet, or does one have to build their own receiver application and specifically handle text tracking through passed in customData? Am I potentially using the wrong sender api?

function loadMedia() {
  mediaUrl = decodeURIComponent(_player.sources.mp4);
  var mediaInfo = new chrome.cast.media.MediaInfo(mediaUrl);
  mediaInfo.contentType = 'video/mp4';

  var track1 = new chrome.cast.media.Track(1, chrome.cast.media.TrackType.TEXT);
  track1.trackContentId = "https://dl.dropboxusercontent.com/u/35106650/test.vtt";

  mediaInfo.tracks = [track1];
  var request = new chrome.cast.media.LoadRequest(mediaInfo);

  // var json = {
  //   cc: {
  //     tracks: [{
  //       src: "https://dl.dropboxusercontent.com/u/35106650/test.vtt"
  //     }],
  //     active: 0
  //   }
  // };

  // request.customData = json;
  session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);
}
1
And what have you done to achieve this goal? Or is this an RFP for the community to do spec work for you?Giacomo1968
@JakeGould not really sure what you mean. Apologies if my question came across to you as an RFP to do work...I've been trying to build subtitle functionality using my sender application and the default receiver app. When I try to create the Track object specified in Google's documentation, it seems like it's not part of the API. Just knowing that someone else has had this issue trying to use the current Cast api would in itself be very helpful to me.Sagar Shah
This is a programming site. Where is your code?Giacomo1968

1 Answers

1
votes

Currently, neither the Default nor the Styled Receivers support Closed Caption; you need to create your own. We have a sample in our GitHub repo that can be used for doing exactly that.

Update: Styled and Default receivers now support Tracks, see our documentations.