mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 22:48:34 +00:00
Added new noAudio
parameter, because it's a load setting, not an instance one
This commit is contained in:
parent
5ac4afb1f8
commit
7fb8718c80
1 changed files with 32 additions and 16 deletions
|
@ -39,10 +39,11 @@ var VideoFile = new Class({
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
// URL is an object created by VideoFile.getVideoURL
|
// URL is an object created by VideoFile.getVideoURL
|
||||||
function VideoFile (loader, key, urlConfig, loadEvent, asBlob, xhrSettings)
|
function VideoFile (loader, key, urlConfig, loadEvent, asBlob, noAudio, xhrSettings)
|
||||||
{
|
{
|
||||||
if (loadEvent === undefined) { loadEvent = 'canplaythrough'; }
|
if (loadEvent === undefined) { loadEvent = 'loadeddata'; }
|
||||||
if (asBlob === undefined) { asBlob = false; }
|
if (asBlob === undefined) { asBlob = false; }
|
||||||
|
if (noAudio === undefined) { noAudio = false; }
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
|
@ -54,11 +55,12 @@ var VideoFile = new Class({
|
||||||
xhrSettings: xhrSettings,
|
xhrSettings: xhrSettings,
|
||||||
config: {
|
config: {
|
||||||
loadEvent: loadEvent,
|
loadEvent: loadEvent,
|
||||||
asBlob: asBlob
|
asBlob: asBlob,
|
||||||
|
noAudio: noAudio
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(fileConfig);
|
// console.log(fileConfig);
|
||||||
|
|
||||||
File.call(this, loader, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
@ -72,7 +74,7 @@ var VideoFile = new Class({
|
||||||
*/
|
*/
|
||||||
onProcess: function ()
|
onProcess: function ()
|
||||||
{
|
{
|
||||||
console.log('Video.onProcess', this.config.asBlob);
|
// console.log('Video.onProcess', this.config.asBlob);
|
||||||
|
|
||||||
this.state = CONST.FILE_PROCESSING;
|
this.state = CONST.FILE_PROCESSING;
|
||||||
|
|
||||||
|
@ -84,18 +86,25 @@ var VideoFile = new Class({
|
||||||
}
|
}
|
||||||
|
|
||||||
var video = document.createElement('video');
|
var video = document.createElement('video');
|
||||||
|
|
||||||
video.controls = false;
|
video.controls = false;
|
||||||
video.canplay = true;
|
video.canplay = true;
|
||||||
|
|
||||||
video.setAttribute('autoplay', 'autoplay');
|
video.setAttribute('autoplay', 'autoplay');
|
||||||
video.setAttribute('playsinline', 'playsinline');
|
video.setAttribute('playsinline', 'playsinline');
|
||||||
|
|
||||||
|
if (this.config.noAudio)
|
||||||
|
{
|
||||||
|
video.muted = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.data = video;
|
this.data = video;
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
this.data.onloadeddata = function ()
|
this.data.onloadeddata = function ()
|
||||||
{
|
{
|
||||||
console.log('data.onloadeddata');
|
// console.log('data.onloadeddata');
|
||||||
|
|
||||||
File.revokeObjectURL(_this.data);
|
File.revokeObjectURL(_this.data);
|
||||||
|
|
||||||
|
@ -104,14 +113,14 @@ var VideoFile = new Class({
|
||||||
|
|
||||||
this.data.onerror = function ()
|
this.data.onerror = function ()
|
||||||
{
|
{
|
||||||
console.log('data.onerror');
|
// console.log('data.onerror');
|
||||||
|
|
||||||
File.revokeObjectURL(_this.data);
|
File.revokeObjectURL(_this.data);
|
||||||
|
|
||||||
_this.onProcessError();
|
_this.onProcessError();
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('onProcess createURL');
|
// console.log('onProcess createURL');
|
||||||
|
|
||||||
File.createObjectURL(this.data, this.xhrLoader.response, '');
|
File.createObjectURL(this.data, this.xhrLoader.response, '');
|
||||||
},
|
},
|
||||||
|
@ -154,10 +163,11 @@ var VideoFile = new Class({
|
||||||
{
|
{
|
||||||
var loadEvent = this.config.loadEvent;
|
var loadEvent = this.config.loadEvent;
|
||||||
var asBlob = this.config.asBlob;
|
var asBlob = this.config.asBlob;
|
||||||
|
var noAudio = this.config.noAudio;
|
||||||
|
|
||||||
if (asBlob)
|
if (asBlob)
|
||||||
{
|
{
|
||||||
console.log('Passing load over to File.load');
|
// console.log('Passing load over to File.load');
|
||||||
|
|
||||||
File.prototype.load.call(this);
|
File.prototype.load.call(this);
|
||||||
}
|
}
|
||||||
|
@ -171,6 +181,11 @@ var VideoFile = new Class({
|
||||||
|
|
||||||
video.controls = false;
|
video.controls = false;
|
||||||
video.crossOrigin = this.loader.crossOrigin;
|
video.crossOrigin = this.loader.crossOrigin;
|
||||||
|
|
||||||
|
if (noAudio)
|
||||||
|
{
|
||||||
|
video.muted = true;
|
||||||
|
}
|
||||||
|
|
||||||
video.setAttribute('autoplay', 'autoplay');
|
video.setAttribute('autoplay', 'autoplay');
|
||||||
video.setAttribute('playsinline', 'playsinline');
|
video.setAttribute('playsinline', 'playsinline');
|
||||||
|
@ -180,9 +195,9 @@ var VideoFile = new Class({
|
||||||
|
|
||||||
this.onVideoLoadHandler = function (event)
|
this.onVideoLoadHandler = function (event)
|
||||||
{
|
{
|
||||||
console.log('onVideoLoadHandler');
|
// console.log('onVideoLoadHandler');
|
||||||
console.log(event);
|
// console.log(event);
|
||||||
console.log(_this.config.loadEvent);
|
// console.log(_this.config.loadEvent);
|
||||||
|
|
||||||
var video = event.target;
|
var video = event.target;
|
||||||
|
|
||||||
|
@ -207,7 +222,7 @@ var VideoFile = new Class({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
VideoFile.create = function (loader, key, urls, loadEvent, asBlob, xhrSettings)
|
VideoFile.create = function (loader, key, urls, loadEvent, asBlob, noAudio, xhrSettings)
|
||||||
{
|
{
|
||||||
var game = loader.systems.game;
|
var game = loader.systems.game;
|
||||||
|
|
||||||
|
@ -217,12 +232,13 @@ VideoFile.create = function (loader, key, urls, loadEvent, asBlob, xhrSettings)
|
||||||
urls = GetFastValue(key, 'url', []);
|
urls = GetFastValue(key, 'url', []);
|
||||||
loadEvent = GetFastValue(key, 'loadEvent', 'canplaythrough');
|
loadEvent = GetFastValue(key, 'loadEvent', 'canplaythrough');
|
||||||
asBlob = GetFastValue(key, 'asBlob', false);
|
asBlob = GetFastValue(key, 'asBlob', false);
|
||||||
|
noAudio = GetFastValue(key, 'noAudio', false);
|
||||||
xhrSettings = GetFastValue(key, 'xhrSettings');
|
xhrSettings = GetFastValue(key, 'xhrSettings');
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlConfig = VideoFile.getVideoURL(game, urls);
|
var urlConfig = VideoFile.getVideoURL(game, urls);
|
||||||
|
|
||||||
console.log(urlConfig);
|
// console.log(urlConfig);
|
||||||
|
|
||||||
if (urlConfig)
|
if (urlConfig)
|
||||||
{
|
{
|
||||||
|
@ -320,7 +336,7 @@ VideoFile.getVideoURL = function (game, urls)
|
||||||
*
|
*
|
||||||
* @return {Phaser.Loader.LoaderPlugin} The Loader instance.
|
* @return {Phaser.Loader.LoaderPlugin} The Loader instance.
|
||||||
*/
|
*/
|
||||||
FileTypesManager.register('video', function (key, urls, loadEvent, asBlob, xhrSettings)
|
FileTypesManager.register('video', function (key, urls, loadEvent, asBlob, noAudio, xhrSettings)
|
||||||
{
|
{
|
||||||
var videoFile;
|
var videoFile;
|
||||||
|
|
||||||
|
@ -339,7 +355,7 @@ FileTypesManager.register('video', function (key, urls, loadEvent, asBlob, xhrSe
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
videoFile = VideoFile.create(this, key, urls, loadEvent, asBlob, xhrSettings);
|
videoFile = VideoFile.create(this, key, urls, loadEvent, asBlob, noAudio, xhrSettings);
|
||||||
|
|
||||||
if (videoFile)
|
if (videoFile)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue