Expose ID3 frames on cue objects
Pass along the parsed ID3 frame object that corresponds to the genererated VTTCue.
Showing
2 changed files
with
20 additions
and
5 deletions
... | @@ -99,7 +99,7 @@ videojs.Hls.prototype.src = function(src) { | ... | @@ -99,7 +99,7 @@ videojs.Hls.prototype.src = function(src) { |
99 | } | 99 | } |
100 | 100 | ||
101 | metadataStream.on('data', function(metadata) { | 101 | metadataStream.on('data', function(metadata) { |
102 | var i, frame, time, hexDigit; | 102 | var i, cue, frame, time, hexDigit; |
103 | 103 | ||
104 | // create the metadata track if this is the first ID3 tag we've | 104 | // create the metadata track if this is the first ID3 tag we've |
105 | // seen | 105 | // seen |
... | @@ -118,7 +118,9 @@ videojs.Hls.prototype.src = function(src) { | ... | @@ -118,7 +118,9 @@ videojs.Hls.prototype.src = function(src) { |
118 | for (i = 0; i < metadata.frames.length; i++) { | 118 | for (i = 0; i < metadata.frames.length; i++) { |
119 | frame = metadata.frames[i]; | 119 | frame = metadata.frames[i]; |
120 | time = metadata.pts / 1000; | 120 | time = metadata.pts / 1000; |
121 | textTrack.addCue(new window.VTTCue(time, time, frame.value || frame.url || frame.id === 'PRIV' && String.fromCharCode.apply(null, frame.data))); | 121 | cue = new window.VTTCue(time, time, frame.value || frame.url || ''); |
122 | cue.frame = frame; | ||
123 | textTrack.addCue(cue); | ||
122 | } | 124 | } |
123 | }); | 125 | }); |
124 | })(); | 126 | })(); | ... | ... |
... | @@ -1112,11 +1112,15 @@ test('exposes in-band metadata events as cues', function() { | ... | @@ -1112,11 +1112,15 @@ test('exposes in-band metadata events as cues', function() { |
1112 | pts: 2000, | 1112 | pts: 2000, |
1113 | data: new Uint8Array([]), | 1113 | data: new Uint8Array([]), |
1114 | frames: [{ | 1114 | frames: [{ |
1115 | type: 'TXXX', | 1115 | id: 'TXXX', |
1116 | value: 'cue text' | 1116 | value: 'cue text' |
1117 | }, { | 1117 | }, { |
1118 | type: 'WXXX', | 1118 | id: 'WXXX', |
1119 | url: 'http://example.com' | 1119 | url: 'http://example.com' |
1120 | }, { | ||
1121 | id: 'PRIV', | ||
1122 | owner: 'owner@example.com', | ||
1123 | privateData: new Uint8Array([1, 2, 3]) | ||
1120 | }] | 1124 | }] |
1121 | }); | 1125 | }); |
1122 | }; | 1126 | }; |
... | @@ -1128,7 +1132,7 @@ test('exposes in-band metadata events as cues', function() { | ... | @@ -1128,7 +1132,7 @@ test('exposes in-band metadata events as cues', function() { |
1128 | track = player.textTracks()[0]; | 1132 | track = player.textTracks()[0]; |
1129 | equal(track.kind, 'metadata', 'kind is metadata'); | 1133 | equal(track.kind, 'metadata', 'kind is metadata'); |
1130 | equal(track.inBandMetadataTrackDispatchType, '15010203BB', 'set the dispatch type'); | 1134 | equal(track.inBandMetadataTrackDispatchType, '15010203BB', 'set the dispatch type'); |
1131 | equal(track.cues.length, 2, 'created two cues'); | 1135 | equal(track.cues.length, 3, 'created three cues'); |
1132 | equal(track.cues[0].startTime, 2, 'cue starts at 2 seconds'); | 1136 | equal(track.cues[0].startTime, 2, 'cue starts at 2 seconds'); |
1133 | equal(track.cues[0].endTime, 2, 'cue ends at 2 seconds'); | 1137 | equal(track.cues[0].endTime, 2, 'cue ends at 2 seconds'); |
1134 | equal(track.cues[0].pauseOnExit, false, 'cue does not pause on exit'); | 1138 | equal(track.cues[0].pauseOnExit, false, 'cue does not pause on exit'); |
... | @@ -1138,6 +1142,15 @@ test('exposes in-band metadata events as cues', function() { | ... | @@ -1138,6 +1142,15 @@ test('exposes in-band metadata events as cues', function() { |
1138 | equal(track.cues[1].endTime, 2, 'cue ends at 2 seconds'); | 1142 | equal(track.cues[1].endTime, 2, 'cue ends at 2 seconds'); |
1139 | equal(track.cues[1].pauseOnExit, false, 'cue does not pause on exit'); | 1143 | equal(track.cues[1].pauseOnExit, false, 'cue does not pause on exit'); |
1140 | equal(track.cues[1].text, 'http://example.com', 'set cue text'); | 1144 | equal(track.cues[1].text, 'http://example.com', 'set cue text'); |
1145 | |||
1146 | equal(track.cues[2].startTime, 2, 'cue starts at 2 seconds'); | ||
1147 | equal(track.cues[2].endTime, 2, 'cue ends at 2 seconds'); | ||
1148 | equal(track.cues[2].pauseOnExit, false, 'cue does not pause on exit'); | ||
1149 | equal(track.cues[2].text, '', 'did not set cue text'); | ||
1150 | equal(track.cues[2].frame.owner, 'owner@example.com', 'set the owner'); | ||
1151 | deepEqual(track.cues[2].frame.privateData, | ||
1152 | new Uint8Array([1, 2, 3]), | ||
1153 | 'set the private data'); | ||
1141 | }); | 1154 | }); |
1142 | 1155 | ||
1143 | test('drops tags before the target timestamp when seeking', function() { | 1156 | test('drops tags before the target timestamp when seeking', function() { | ... | ... |
-
Please register or sign in to post a comment