@@ -87,8 +87,6 @@ var Video = new Class({
8787
8888 this . _key = UUID ( ) ;
8989
90- this . snapshot = null ;
91-
9290 /**
9391 * @property {boolean } touchLocked - true if this video is currently locked awaiting a touch event. This happens on some mobile devices, such as iOS.
9492 * @default
@@ -179,20 +177,6 @@ var Video = new Class({
179177 */
180178 this . _codePaused = false ;
181179
182- /**
183- * @property {boolean } _pendingChangeSource - Internal var tracking play pending.
184- * @private
185- * @default
186- */
187- this . _pendingChangeSource = false ;
188-
189- /**
190- * @property {boolean } _autoplay - Internal var tracking autoplay when changing source.
191- * @private
192- * @default
193- */
194- this . _autoplay = false ;
195-
196180 this . _callbacks = {
197181 end : this . completeHandler . bind ( this ) ,
198182 play : this . playHandler . bind ( this ) ,
@@ -210,6 +194,7 @@ var Video = new Class({
210194 this . _crop = this . resetCropObject ( ) ;
211195
212196 this . _lastUpdate = 0 ;
197+ this . _cacheKey = '' ;
213198
214199 this . setPosition ( x , y ) ;
215200 this . initPipeline ( ) ;
@@ -222,6 +207,8 @@ var Video = new Class({
222207 {
223208 this . video = _video ;
224209
210+ this . _cacheKey = key ;
211+
225212 console . log ( 'Video constructor, setting defaults' , _video . videoWidth , 'x' , _video . videoHeight ) ;
226213
227214 this . _codePaused = _video . paused ;
@@ -232,7 +219,7 @@ var Video = new Class({
232219 }
233220 else if ( url )
234221 {
235- this . createVideoFromURL ( url ) ;
222+ this . playURL ( url ) ;
236223 }
237224
238225 var game = scene . sys . game . events ;
@@ -279,7 +266,7 @@ var Video = new Class({
279266 */
280267 play : function ( loop , playbackRate )
281268 {
282- if ( this . _pendingChangeSource || ( this . touchLocked && this . playWhenUnlocked ) || this . isPlaying ( ) )
269+ if ( ( this . touchLocked && this . playWhenUnlocked ) || this . isPlaying ( ) )
283270 {
284271 return this ;
285272 }
@@ -336,6 +323,37 @@ var Video = new Class({
336323 return this ;
337324 } ,
338325
326+ /**
327+ * Creates a new Video element from the given URL.
328+ *
329+ * @method Phaser.Video#playURL
330+ * @param {string } url - The URL of the video.
331+ * @param {boolean } [autoplay=false] - Automatically start the video?
332+ * @return {Phaser.Video } This Video object for method chaining.
333+ */
334+ playURL : function ( url , loop , playbackRate )
335+ {
336+ // this.video = document.createElement('video');
337+ // this.video.controls = false;
338+
339+ // if (autoplay)
340+ // {
341+ // this.video.setAttribute('autoplay', 'autoplay');
342+ // }
343+
344+ // this.video.src = url;
345+
346+ // this.video.canplay = true;
347+
348+ // this.video.load();
349+
350+ // this.retry = this.retryLimit;
351+
352+ // this._retryID = window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval);
353+
354+ return this ;
355+ } ,
356+
339357 playSuccessHandler : function ( )
340358 {
341359 console . log ( 'playSuccessHandler' ) ;
@@ -346,6 +364,7 @@ var Video = new Class({
346364 playErrorHandler : function ( error )
347365 {
348366 console . log ( 'playErrorHandler' ) ;
367+ console . log ( error ) ;
349368
350369 this . scene . sys . input . once ( 'pointerdown' , this . unlockHandler , this ) ;
351370
@@ -508,39 +527,6 @@ var Video = new Class({
508527 return this ;
509528 } ,
510529
511- /**
512- * Creates a new Video element from the given URL.
513- *
514- * @method Phaser.Video#createVideoFromURL
515- * @param {string } url - The URL of the video.
516- * @param {boolean } [autoplay=false] - Automatically start the video?
517- * @return {Phaser.Video } This Video object for method chaining.
518- */
519- createVideoFromURL : function ( url , autoplay )
520- {
521- if ( autoplay === undefined ) { autoplay = false ; }
522-
523- this . video = document . createElement ( 'video' ) ;
524- this . video . controls = false ;
525-
526- if ( autoplay )
527- {
528- this . video . setAttribute ( 'autoplay' , 'autoplay' ) ;
529- }
530-
531- this . video . src = url ;
532-
533- this . video . canplay = true ;
534-
535- this . video . load ( ) ;
536-
537- this . retry = this . retryLimit ;
538-
539- this . _retryID = window . setTimeout ( this . checkVideoProgress . bind ( this ) , this . retryInterval ) ;
540-
541- return this ;
542- } ,
543-
544530 /**
545531 * Internal callback that monitors the download progress of a video after changing its source.
546532 *
@@ -578,7 +564,7 @@ var Video = new Class({
578564 * @method Phaser.Video#updateTexture
579565 * @param {object } [event] - The event which triggered the texture update.
580566 */
581- updateTexture : function ( event )
567+ updateTexture : function ( )
582568 {
583569 var video = this . video ;
584570
@@ -902,54 +888,6 @@ var Video = new Class({
902888 return this . videoTexture ;
903889 } ,
904890
905- /**
906- * Grabs the current frame from the Video or Video Stream and renders it to the Video.snapshot BitmapData.
907- *
908- * You can optionally set if the BitmapData should be cleared or not, the alpha and the blend mode of the draw.
909- *
910- * If you need more advanced control over the grabbing them call `Video.snapshot.copy` directly with the same parameters as BitmapData.copy.
911- *
912- * @method Phaser.Video#grab
913- * @param {boolean } [clear=false] - Should the BitmapData be cleared before the Video is grabbed? Unless you are using alpha or a blend mode you can usually leave this set to false.
914- * @param {number } [alpha=1] - The alpha that will be set on the video before drawing. A value between 0 (fully transparent) and 1, opaque.
915- * @param {string } [blendMode=null] - The composite blend mode that will be used when drawing. The default is no blend mode at all. This is a Canvas globalCompositeOperation value such as 'lighter' or 'xor'.
916- * @return {Phaser.BitmapData } A reference to the Video.snapshot BitmapData object for further method chaining.
917- */
918- grab : function ( clear , alpha , blendMode )
919- {
920- if ( clear === undefined ) { clear = false ; }
921- if ( alpha === undefined ) { alpha = 1 ; }
922- if ( blendMode === undefined ) { blendMode = null ; }
923-
924- var source = this . videoTextureSource ;
925- var width = ( source ) ? source . width : 128 ;
926- var height = ( source ) ? source . height : 128 ;
927-
928- if ( ! this . snapshot )
929- {
930- this . snapshot = this . scene . sys . textures . createCanvas ( UUID ( ) , width , height ) ;
931- }
932- else if ( this . snapshot . width !== width || this . snapshot . height !== height )
933- {
934- this . snapshot . setSize ( width , height ) ;
935- }
936-
937- if ( clear )
938- {
939- this . snapshot . clear ( ) ;
940- }
941-
942- if ( source )
943- {
944- // Set globalAlpha
945- // Set blendMode
946-
947- this . snapshot . draw ( 0 , 0 , source . image ) ;
948- }
949-
950- return this . snapshot ;
951- } ,
952-
953891 /**
954892 * Removes the Video element from the DOM by calling parentNode.removeChild on itself.
955893 * Also removes the autoplay and src attributes and nulls the reference.
@@ -958,23 +896,25 @@ var Video = new Class({
958896 */
959897 removeVideoElement : function ( )
960898 {
961- if ( ! this . video )
899+ var video = this . video ;
900+
901+ if ( ! video )
962902 {
963903 return ;
964904 }
965905
966- if ( this . video . parentNode )
906+ if ( video . parentNode )
967907 {
968- this . video . parentNode . removeChild ( this . video ) ;
908+ video . parentNode . removeChild ( video ) ;
969909 }
970910
971- while ( this . video . hasChildNodes ( ) )
911+ while ( video . hasChildNodes ( ) )
972912 {
973- this . video . removeChild ( this . video . firstChild ) ;
913+ video . removeChild ( video . firstChild ) ;
974914 }
975915
976- this . video . removeAttribute ( 'autoplay' ) ;
977- this . video . removeAttribute ( 'src' ) ;
916+ video . removeAttribute ( 'autoplay' ) ;
917+ video . removeAttribute ( 'src' ) ;
978918
979919 this . video = null ;
980920 } ,
@@ -993,8 +933,8 @@ var Video = new Class({
993933
994934 var game = this . scene . sys . game . events ;
995935
996- game . off ( GameEvents . PAUSE , this . pause , this ) ;
997- game . off ( GameEvents . RESUME , this . resume , this ) ;
936+ game . off ( GameEvents . PAUSE , this . globalPause , this ) ;
937+ game . off ( GameEvents . RESUME , this . globalResume , this ) ;
998938
999939 var sound = this . scene . sys . sound ;
1000940
@@ -1007,20 +947,6 @@ var Video = new Class({
1007947 {
1008948 window . clearTimeout ( this . _retryID ) ;
1009949 }
1010- } ,
1011-
1012- /**
1013- * @name Phaser.Video#playing
1014- * @property {boolean } playing - True if the video is currently playing (and not paused or ended), otherwise false.
1015- * @readOnly
1016- */
1017- playing : {
1018-
1019- get : function ( )
1020- {
1021- return ( this . video ) ? ! ( this . video . paused || this . video . ended ) : false ;
1022- }
1023-
1024950 }
1025951
1026952} ) ;
0 commit comments