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.

This commit is contained in:
photonstorm 2015-04-29 14:41:47 +01:00
parent 4c0e34e788
commit e291f6d590
2 changed files with 9 additions and 5 deletions

View file

@ -298,6 +298,7 @@ Version 2.4 - "Katar" - in dev
* SoundManager.pauseAll, resumeAll and stopAll now checks if the SoundManager.noAudio is set and ignores the calls.
* 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.
* SoundManager.touchLocked is now set to `false` should the device be using legacy Audio, avoiding the unlock call running without need.
* 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.
### Bug Fixes

View file

@ -77,13 +77,13 @@ PIXI.VideoTexture.prototype.stop = function()
}
};
PIXI.VideoTexture.prototype._onEnded = function()
PIXI.VideoTexture.prototype._onEnded = function(event)
{
this.ended = true;
this.onComplete.dispatch();
};
PIXI.VideoTexture.prototype._onUpdate = function()
PIXI.VideoTexture.prototype._onUpdate = function(event)
{
if (this.autoUpdate)
{
@ -107,7 +107,7 @@ PIXI.VideoTexture.prototype.onPlayStop = function()
this.autoUpdate = false;
};
PIXI.VideoTexture.prototype.onCanPlay = function()
PIXI.VideoTexture.prototype.onCanPlay = function(event)
{
if (event.type === 'canplaythrough')
{
@ -196,17 +196,20 @@ PIXI.VideoTexture.textureFromVideo = function(video, scaleMode)
* @param videoSrc {String} The URL for the video.
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
* @param autoPlay {boolean} Automatically start the video playing? Until you do this you can't get the width / height of the resulting texture.
* @param type {string} The mime-type of the video to be played. Defaults to "video/mp4". Needed for Firefox and Safari.
* @return {VideoTexture}
*/
PIXI.VideoTexture.fromUrl = function(videoSrc, scaleMode, autoPlay)
PIXI.VideoTexture.fromUrl = function(videoSrc, scaleMode, autoPlay, type)
{
if (typeof scaleMode === 'undefined') { scaleMode = PIXI.scaleModes.DEFAULT; }
if (typeof autoPlay === 'undefined') { autoPlay = true; }
if (typeof type === 'undefined') { type = "video/mp4"; }
var video = document.createElement('video');
video.src = videoSrc;
video.controls = true;
video.controls = false;
video.type = type;
if (autoPlay)
{