0

Hy!

I would like to create an application which supports TTML typed closed captions.

My ism/manifest file contains the TTML based closed caption, I would like to ask how can I use it?

I found this site, https://developers.google.com/cast/docs/player where they described the following:

Segmented TTML & WebVTT

Use Segmented TTML for Smooth Streaming and WebVTT - Web Video Text Tracks for HLS.

To enable:

protocol_.enableStream(streamIndex, true); player_.enableCaptions(true);

But I can't find an example for my problem. Do I have to enable this after creating my host at the receiver side? Are there any sample app for this?

UPDATE #1

Here's my code:

  window.onload = function() {

  var mediaElement = document.getElementById('video'); //video is a html video tag

  var mediamanager = new cast.receiver.MediaManager(mediaElement);

  var url = "http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism/Manifest";  //Just a sample URL

  var host = new cast.player.api.Host({ 'mediaElement': mediaElement, 'url': url });

  window.player = new cast.player.api.Player(host);

  protocol = cast.player.api.CreateSmoothStreamingProtocol(host);

  var initStart = 0;

  window.player.load(protocol, initStart);

  mediamanager.loadedmetadata = function(loadinfo) {
          //onMetadataLoaded fired, set the caption
  }


  }

It doesn't work. So I decided to get the streams:

  var streamCount = protocol.getStreamCount();

And streamCount contains 0. The manifest contains the closed caption, should I use something else, not the getStreamCount()?

Thank you very much!

Gábor Domonkos
  • 1,081
  • 1
  • 17
  • 33

2 Answers2

1

The correct approach is to listen for metadataloaded event. Once that event is fired, then you are good to get the stream count, but don't do that before that event is fired. Then you can enable the stream for the index that you want (for the language that you want, in case you have multiple ones) and then enable caption. If you want to change language, you first need to disable caption and then select a different stream index and then enable it again.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • Thank you for your reply! I updated my code and implemented the onMetadataLoaded event, but this event not get fired. What do you think, what could be the problem? Thank you! – Gábor Domonkos Mar 09 '14 at 00:06
  • I might be mistaking but isn't the proper name of the event "loadedmetadata" ? – Ali Naddaf Mar 09 '14 at 00:19
  • Oh, you are right, it was loadedmetadata, I correct the code, but the event is still not get fired and I stil don't get it. :( – Gábor Domonkos Mar 09 '14 at 00:42
  • loadedmetadata event SHOULD be fired if all is setup correctly. Double check your setup and everything. – Ali Naddaf Mar 09 '14 at 00:56
0

No samples yet.

Yes - you should enable after creating the Host and starting playback.