@@ -857,6 +857,66 @@ var Video = new Class({
857857
858858 return this ;
859859 } ,
860+
861+ /**
862+ * Loads a Video from the given MediaStream object, ready for playback with the `Video.play` method.
863+ *
864+ * You can control at what point the browser determines the video as being ready for playback via
865+ * the `loadEvent` parameter. See https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement
866+ * for more details.
867+ *
868+ * @method Phaser.GameObjects.Video#loadURL
869+ * @since 3.20.0
870+ *
871+ * @param {string } stream - The MediaStream object.
872+ * @param {string } [loadEvent='loadeddata'] - The load event to listen for. Either `loadeddata`, `canplay` or `canplaythrough`.
873+ * @param {boolean } [noAudio=false] - Does the video have an audio track? If not you can enable auto-playing on it.
874+ *
875+ * @return {this } This Video Game Object for method chaining.
876+ */
877+ loadMediaStream : function ( stream , loadEvent , noAudio ) {
878+ if ( loadEvent === undefined ) { loadEvent = 'loadeddata' ; }
879+ if ( noAudio === undefined ) { noAudio = false ; }
880+
881+ if ( this . video )
882+ {
883+ this . stop ( ) ;
884+ }
885+
886+ if ( this . videoTexture )
887+ {
888+ this . scene . sys . textures . remove ( this . _key ) ;
889+ }
890+
891+ var video = document . createElement ( 'video' ) ;
892+
893+ video . controls = false ;
894+
895+ if ( noAudio )
896+ {
897+ video . muted = true ;
898+ video . defaultMuted = true ;
899+
900+ video . setAttribute ( 'autoplay' , 'autoplay' ) ;
901+ }
902+
903+ video . setAttribute ( 'playsinline' , 'playsinline' ) ;
904+ video . setAttribute ( 'preload' , 'auto' ) ;
905+
906+ video . addEventListener ( 'error' , this . _callbacks . error , true ) ;
907+
908+ try {
909+ video . srcObject = stream ;
910+ } catch ( error ) {
911+ video . src = window . URL . createObjectURL ( stream ) ;
912+ }
913+
914+ video . load ( ) ;
915+
916+ this . video = video ;
917+
918+ return this ;
919+ } ,
860920
861921 /**
862922 * This internal method is called automatically if the playback Promise resolves successfully.
0 commit comments