update for seeking to segment border. requires videojs-swf/feature/hls-seeking based swf
Showing
2 changed files
with
36 additions
and
0 deletions
... | @@ -351,7 +351,13 @@ | ... | @@ -351,7 +351,13 @@ |
351 | if (entry.duration >= 0) { | 351 | if (entry.duration >= 0) { |
352 | currentUri.duration = entry.duration; | 352 | currentUri.duration = entry.duration; |
353 | } | 353 | } |
354 | |||
355 | currentUri.timeRange = {}; | ||
356 | currentUri.timeRange.start = (uris.length > 0) ? uris[uris.length-1].timeRange.end : 0; | ||
357 | currentUri.timeRange.end = currentUri.timeRange.start + currentUri.duration; | ||
358 | |||
354 | this.manifest.segments = uris; | 359 | this.manifest.segments = uris; |
360 | |||
355 | }, | 361 | }, |
356 | 'media-sequence': function() { | 362 | 'media-sequence': function() { |
357 | if (!isFinite(entry.number)) { | 363 | if (!isFinite(entry.number)) { | ... | ... |
... | @@ -109,6 +109,34 @@ var | ... | @@ -109,6 +109,34 @@ var |
109 | return 1; // HAVE_METADATA | 109 | return 1; // HAVE_METADATA |
110 | }; | 110 | }; |
111 | 111 | ||
112 | player.currentTime = function(value) { | ||
113 | if(value) { | ||
114 | player.el().getElementsByClassName('vjs-tech')[0].vjs_setProperty('currentTime', 0); | ||
115 | player.hls.mediaIndex = player.hls.selectSegmentByTime(value); | ||
116 | fillBuffer(); | ||
117 | } else { | ||
118 | return player.el().getElementsByClassName('vjs-tech')[0].vjs_getProperty('currentTime'); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | player.hls.selectSegmentByTime = function(time) { | ||
123 | if(player.hls.media && player.hls.media.segments) | ||
124 | { | ||
125 | var index, currentSegment; | ||
126 | |||
127 | for (index = 0; index < player.hls.media.segments.length; index++) | ||
128 | { | ||
129 | currentSegment = player.hls.media.segments[index]; | ||
130 | |||
131 | if(time > currentSegment.timeRange.start && time <= currentSegment.timeRange.end) | ||
132 | { | ||
133 | return index; | ||
134 | } | ||
135 | |||
136 | } | ||
137 | } | ||
138 | } | ||
139 | |||
112 | /** | 140 | /** |
113 | * Chooses the appropriate media playlist based on the current | 141 | * Chooses the appropriate media playlist based on the current |
114 | * bandwidth estimate and the player size. | 142 | * bandwidth estimate and the player size. |
... | @@ -210,6 +238,8 @@ var | ... | @@ -210,6 +238,8 @@ var |
210 | if (parser.manifest.totalDuration) { | 238 | if (parser.manifest.totalDuration) { |
211 | // update the duration | 239 | // update the duration |
212 | player.duration(parser.manifest.totalDuration); | 240 | player.duration(parser.manifest.totalDuration); |
241 | // Notify the flash layer | ||
242 | player.el().getElementsByClassName('vjs-tech')[0].vjs_setProperty('duration',parser.manifest.totalDuration); | ||
213 | } | 243 | } |
214 | player.trigger('loadedmanifest'); | 244 | player.trigger('loadedmanifest'); |
215 | player.trigger('loadedmetadata'); | 245 | player.trigger('loadedmetadata'); | ... | ... |
-
Please register or sign in to post a comment