Skip to content

Commit e291f6d

Browse files
committed
Added type parameter to VideoTexture.fromUrl allowing you to define the mime-type of the video file, which is required for Firefox and Safari in most cases.
1 parent 4c0e34e commit e291f6d

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ Version 2.4 - "Katar" - in dev
298298
* SoundManager.pauseAll, resumeAll and stopAll now checks if the SoundManager.noAudio is set and ignores the calls.
299299
* SoundManager.usingWebAudio is set to `false` by default (used to be `true`) and is only explicitly set if Web Audio is available and hasn't been disabled in the PhaserGlobal object.
300300
* SoundManager.touchLocked is now set to `false` should the device be using legacy Audio, avoiding the unlock call running without need.
301+
* Added `type` parameter to `VideoTexture.fromUrl` allowing you to define the mime-type of the video file, which is required for Firefox and Safari in most cases.
301302

302303
### Bug Fixes
303304

src/pixi/textures/VideoTexture.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ PIXI.VideoTexture.prototype.stop = function()
7777
}
7878
};
7979

80-
PIXI.VideoTexture.prototype._onEnded = function()
80+
PIXI.VideoTexture.prototype._onEnded = function(event)
8181
{
8282
this.ended = true;
8383
this.onComplete.dispatch();
8484
};
8585

86-
PIXI.VideoTexture.prototype._onUpdate = function()
86+
PIXI.VideoTexture.prototype._onUpdate = function(event)
8787
{
8888
if (this.autoUpdate)
8989
{
@@ -107,7 +107,7 @@ PIXI.VideoTexture.prototype.onPlayStop = function()
107107
this.autoUpdate = false;
108108
};
109109

110-
PIXI.VideoTexture.prototype.onCanPlay = function()
110+
PIXI.VideoTexture.prototype.onCanPlay = function(event)
111111
{
112112
if (event.type === 'canplaythrough')
113113
{
@@ -196,17 +196,20 @@ PIXI.VideoTexture.textureFromVideo = function(video, scaleMode)
196196
* @param videoSrc {String} The URL for the video.
197197
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
198198
* @param autoPlay {boolean} Automatically start the video playing? Until you do this you can't get the width / height of the resulting texture.
199+
* @param type {string} The mime-type of the video to be played. Defaults to "video/mp4". Needed for Firefox and Safari.
199200
* @return {VideoTexture}
200201
*/
201-
PIXI.VideoTexture.fromUrl = function(videoSrc, scaleMode, autoPlay)
202+
PIXI.VideoTexture.fromUrl = function(videoSrc, scaleMode, autoPlay, type)
202203
{
203204
if (typeof scaleMode === 'undefined') { scaleMode = PIXI.scaleModes.DEFAULT; }
204205
if (typeof autoPlay === 'undefined') { autoPlay = true; }
206+
if (typeof type === 'undefined') { type = "video/mp4"; }
205207

206208
var video = document.createElement('video');
207209

208210
video.src = videoSrc;
209-
video.controls = true;
211+
video.controls = false;
212+
video.type = type;
210213

211214
if (autoPlay)
212215
{

0 commit comments

Comments
 (0)