call Flash with correct context
Showing
1 changed file
with
10 additions
and
25 deletions
... | @@ -178,9 +178,8 @@ var | ... | @@ -178,9 +178,8 @@ var |
178 | * Initializes the HLS plugin. | 178 | * Initializes the HLS plugin. |
179 | * @param options {mixed} the URL to an HLS playlist | 179 | * @param options {mixed} the URL to an HLS playlist |
180 | */ | 180 | */ |
181 | init = function(options, ready) { | 181 | init = function(options, mediaSource) { |
182 | var | 182 | var |
183 | mediaSource = new videojs.MediaSource(), | ||
184 | segmentParser = new videojs.Hls.SegmentParser(), | 183 | segmentParser = new videojs.Hls.SegmentParser(), |
185 | player = this, | 184 | player = this, |
186 | srcUrl, | 185 | srcUrl, |
... | @@ -202,7 +201,6 @@ var | ... | @@ -202,7 +201,6 @@ var |
202 | extname, | 201 | extname, |
203 | i = 0, | 202 | i = 0, |
204 | j = 0, | 203 | j = 0, |
205 | src = player.el().querySelector('.vjs-tech').src, | ||
206 | sources = player.options().sources, | 204 | sources = player.options().sources, |
207 | techName, | 205 | techName, |
208 | length = sources.length; | 206 | length = sources.length; |
... | @@ -214,17 +212,6 @@ var | ... | @@ -214,17 +212,6 @@ var |
214 | return options.url; | 212 | return options.url; |
215 | } | 213 | } |
216 | 214 | ||
217 | // src attributes take precedence over source children | ||
218 | if (src) { | ||
219 | |||
220 | // assume files with the m3u8 extension are HLS | ||
221 | extname = (/[^#?]*(?:\/[^#?]*\.([^#?]*))/).exec(src); | ||
222 | if (extname && extname[1] === 'm3u8') { | ||
223 | return src; | ||
224 | } | ||
225 | return; | ||
226 | } | ||
227 | |||
228 | // find the first playable source | 215 | // find the first playable source |
229 | for (; i < length; i++) { | 216 | for (; i < length; i++) { |
230 | 217 | ||
... | @@ -536,24 +523,22 @@ var | ... | @@ -536,24 +523,22 @@ var |
536 | //player.play(); | 523 | //player.play(); |
537 | //} | 524 | //} |
538 | 525 | ||
539 | var source = options.source; | ||
540 | options.source = [{ | ||
541 | src: videojs.URL.createObjectURL(mediaSource), | ||
542 | type: "video/flv" | ||
543 | }]; | ||
544 | //delete options.source; | ||
545 | //console.log(options.source); | ||
546 | videojs.Flash.call(videojs.Hls, player, options, ready); | ||
547 | options.source = source; | ||
548 | console.log(options.source); | ||
549 | }; | 526 | }; |
550 | 527 | ||
551 | var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i; | 528 | var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i; |
552 | 529 | ||
553 | videojs.Hls = videojs.Flash.extend({ | 530 | videojs.Hls = videojs.Flash.extend({ |
554 | init: function(player, options, ready) { | 531 | init: function(player, options, ready) { |
532 | var mediaSource = new videojs.MediaSource(); | ||
533 | var source = options.source; | ||
534 | options.source = { | ||
535 | src: videojs.URL.createObjectURL(mediaSource), | ||
536 | type: "video/flv" | ||
537 | }; | ||
538 | videojs.Flash.call(this, player, options, ready); | ||
555 | player.hls = {}; | 539 | player.hls = {}; |
556 | init.call(player, options, ready); | 540 | options.source = source; |
541 | init.call(player, options, mediaSource); | ||
557 | } | 542 | } |
558 | }); | 543 | }); |
559 | 544 | ... | ... |
-
Please register or sign in to post a comment