1212*
1313* This can be applied to a Sprite as a texture. If multiple Sprites share the same Video texture and playback
1414* changes (i.e. you pause the video, or seek to a new time) then this change will be seen across all Sprites simultaneously.
15+ *
16+ * Due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode.
1517*
1618* If you need each Sprite to be able to play a video fully independently then you will need one Video object per Sprite.
1719* Please understand the obvious performance implications of doing this, and the memory required to hold videos in RAM.
@@ -37,8 +39,6 @@ Phaser.Video = function (game, key, captureAudio, width, height) {
3739 if ( typeof key === 'undefined' ) { key = null ; }
3840 if ( typeof captureAudio === 'undefined' ) { captureAudio = false ; }
3941
40- console . log ( 'create video' , key ) ;
41-
4242 /**
4343 * @property {Phaser.Game } game - A reference to the currently running game.
4444 */
@@ -69,6 +69,9 @@ Phaser.Video = function (game, key, captureAudio, width, height) {
6969 */
7070 this . videoStream = null ;
7171
72+ /**
73+ * @property {boolean } isStreaming - Is there a streaming video source? I.e. from a webcam.
74+ */
7275 this . isStreaming = false ;
7376
7477 if ( key === null )
@@ -117,7 +120,6 @@ Phaser.Video = function (game, key, captureAudio, width, height) {
117120
118121 if ( key !== null && this . video )
119122 {
120- console . log ( 'canplay?' , this . key , 'cp' , this . video . canplay , this . width , this . height ) ;
121123 this . texture . valid = this . video . canplay ;
122124 }
123125
@@ -279,17 +281,8 @@ Phaser.Video.prototype = {
279281 this . video . height = height ;
280282 }
281283
282- if ( ! navigator . getUserMedia )
283- {
284- navigator . getUserMedia = navigator . webkitGetUserMedia || navigator . mozGetUserMedia || navigator . msGetUserMedia ;
285- }
286-
287- window . URL = window . URL || window . webkitURL || window . mozURL || window . msURL ;
288-
289284 var self = this ;
290285
291- console . log ( 'createVideoStream' , width , height ) ;
292-
293286 navigator . getUserMedia ( {
294287 "audio" : captureAudio ,
295288 "video" : true
@@ -334,7 +327,6 @@ Phaser.Video.prototype = {
334327 var height = width / ( 4 / 3 ) ;
335328 }
336329
337- console . log ( 'checkStream' , retry ) ;
338330 self . isStreaming = true ;
339331 self . updateTexture ( null , width , height ) ;
340332 self . onAccess . dispatch ( self ) ;
@@ -402,9 +394,6 @@ Phaser.Video.prototype = {
402394 this . width = width ;
403395 this . height = height ;
404396
405- console . log ( 'updateTexture ---' , this . key , 'change?' , change ) ;
406- console . log ( width , height ) ;
407-
408397 this . baseTexture . forceLoaded ( width , height ) ;
409398
410399 this . texture . frame . resize ( width , height ) ;
@@ -454,8 +443,6 @@ Phaser.Video.prototype = {
454443 */
455444 play : function ( loop , playbackRate ) {
456445
457- console . log ( 'play ---' , this . key ) ;
458-
459446 if ( typeof loop === 'undefined' ) { loop = false ; }
460447 if ( typeof playbackRate === 'undefined' ) { playbackRate = 1 ; }
461448
@@ -508,28 +495,20 @@ Phaser.Video.prototype = {
508495
509496 } ,
510497
511- // canPlayHandler: function () {
498+ /**
499+ * Called when the video starts to play. Updates the texture.
500+ *
501+ * @method Phaser.Video#playHandler
502+ * @private
503+ */
512504 playHandler : function ( ) {
513505
514- // console.log('canPlayHandler ---', this.key);
515- console . log ( 'playHandler ---' , this . key ) ;
516-
517- // this.video.removeEventListener('canplay', this.canPlayHandler.bind(this));
518- // this.video.removeEventListener('canplaythrough', this.canPlayHandler.bind(this));
519- // this.video.removeEventListener('playing', this.canPlayHandler.bind(this));
520506 this . video . removeEventListener ( 'playing' , this . playHandler . bind ( this ) ) ;
521507
522508 // this.video.canplay = true;
523509
524- // if (this.width !== this.texture.width || this.width !== this.baseTexture.width)
525-
526- // this.width = width;
527- // this.height = height;
528-
529510 this . updateTexture ( ) ;
530511
531- // this.onPlay.dispatch(this, this.loop, this.playbackRate);
532-
533512 } ,
534513
535514 /**
@@ -559,7 +538,7 @@ Phaser.Video.prototype = {
559538
560539 // Stream or file?
561540
562- if ( this . videoStream )
541+ if ( this . isStreaming )
563542 {
564543 if ( this . video . mozSrcObject )
565544 {
@@ -573,6 +552,7 @@ Phaser.Video.prototype = {
573552 }
574553
575554 this . videoStream = null ;
555+ this . isStreaming = false ;
576556 }
577557 else
578558 {
@@ -765,8 +745,6 @@ Phaser.Video.prototype = {
765745 */
766746 changeSource : function ( src , autoplay ) {
767747
768- console . log ( 'changeSource from' , this . key , 'to' , src ) ;
769-
770748 if ( typeof autoplay === 'undefined' ) { autoplay = true ; }
771749
772750 // Invalidate the texture while we wait for the new one to load (crashes IE11 otherwise)
0 commit comments