Blame view

node_modules/videojs-contrib-media-sources/docs/api/create-text-tracks-if-necessary.js.html 4.3 KB
2a09d1a4   liuqimichale   添加宜春 天水 宣化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="utf-8">
      <title>JSDoc: Source: create-text-tracks-if-necessary.js</title>
  
      <script src="scripts/prettify/prettify.js"> </script>
      <script src="scripts/prettify/lang-css.js"> </script>
      <!--[if lt IE 9]>
        <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
      <![endif]-->
      <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
      <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  </head>
  
  <body>
  
  <div id="main">
  
      <h1 class="page-title">Source: create-text-tracks-if-necessary.js</h1>
  
      
  
  
  
      
      <section>
          <article>
              <pre class="prettyprint source linenums"><code>/**
   * @file create-text-tracks-if-necessary.js
   */
  
  /**
   * Create text tracks on video.js if they exist on a segment.
   *
   * @param {Object} sourceBuffer the VSB or FSB
   * @param {Object} mediaSource the HTML or Flash media source
   * @param {Object} segment the segment that may contain the text track
   * @private
   */
  const createTextTracksIfNecessary = function(sourceBuffer, mediaSource, segment) {
    const player = mediaSource.player_;
  
    // create an in-band caption track if one is present in the segment
    if (segment.captions &amp;&amp;
        segment.captions.length) {
      if (!sourceBuffer.inbandTextTracks_) {
        sourceBuffer.inbandTextTracks_ = {};
      }
  
      for (let trackId in segment.captionStreams) {
        if (!sourceBuffer.inbandTextTracks_[trackId]) {
          player.tech_.trigger({type: 'usage', name: 'hls-608'});
          let track = player.textTracks().getTrackById(trackId);
  
          if (track) {
            // Resuse an existing track with a CC# id because this was
            // very likely created by videojs-contrib-hls from information
            // in the m3u8 for us to use
            sourceBuffer.inbandTextTracks_[trackId] = track;
          } else {
            // Otherwise, create a track with the default `CC#` label and
            // without a language
            sourceBuffer.inbandTextTracks_[trackId] = player.addRemoteTextTrack({
              kind: 'captions',
              id: trackId,
              label: trackId
            }, false).track;
          }
        }
      }
    }
  
    if (segment.metadata &amp;&amp;
        segment.metadata.length &amp;&amp;
        !sourceBuffer.metadataTrack_) {
      sourceBuffer.metadataTrack_ = player.addRemoteTextTrack({
        kind: 'metadata',
        label: 'Timed Metadata'
      }, false).track;
      sourceBuffer.metadataTrack_.inBandMetadataTrackDispatchType =
        segment.metadata.dispatchType;
    }
  };
  
  export default createTextTracksIfNecessary;
  </code></pre>
          </article>
      </section>
  
  
  
  
  </div>
  
  <nav>
      <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FlashMediaSource.html">FlashMediaSource</a></li><li><a href="FlashSourceBuffer.html">FlashSourceBuffer</a></li><li><a href="HtmlMediaSource.html">HtmlMediaSource</a></li><li><a href="MessageHandlers.html">MessageHandlers</a></li><li><a href="VirtualSourceBuffer.html">VirtualSourceBuffer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#abort">abort</a></li><li><a href="global.html#addSourceBuffer">addSourceBuffer</a></li><li><a href="global.html#appendBuffer">appendBuffer</a></li><li><a href="global.html#appendGopInfo_">appendGopInfo_</a></li><li><a href="global.html#endOfStream">endOfStream</a></li><li><a href="global.html#FlashTransmuxerWorker">FlashTransmuxerWorker</a></li><li><a href="global.html#get">get</a></li><li><a href="global.html#gopsSafeToAlignWith">gopsSafeToAlignWith</a></li><li><a href="global.html#MediaSource">MediaSource</a></li><li><a href="global.html#open">open</a></li><li><a href="global.html#remove">remove</a></li><li><a href="global.html#removeGopBuffer">removeGopBuffer</a></li><li><a href="global.html#set">set</a></li><li><a href="global.html#supportsNativeMediaSources">supportsNativeMediaSources</a></li><li><a href="global.html#TransmuxerWorker">TransmuxerWorker</a></li><li><a href="global.html#updateGopBuffer">updateGopBuffer</a></li><li><a href="global.html#URL">URL</a></li></ul>
  </nav>
  
  <br class="clear">
  
  <footer>
      Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Thu Nov 02 2017 12:03:25 GMT-0400 (EDT)
  </footer>
  
  <script> prettyPrint(); </script>
  <script src="scripts/linenumber.js"> </script>
  </body>
  </html>