<commit_before>/**
 * @author       <NAME> <<EMAIL>>
 * @copyright    2019 Photon Storm Ltd.
 * @license      {@link https://opensource.org/licenses/MIT|MIT License}
 */

var Class = require('../../utils/Class');
var CONST = require('../../const');
var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetURL = require('../GetURL');
var GetFastValue = require('../../utils/object/GetFastValue');
var IsPlainObject = require('../../utils/object/IsPlainObject');

/**
 * @classdesc
 * A single Video File suitable for loading by the Loader.
 *
 * These are created when you use the Phaser.Loader.LoaderPlugin#video method and are not typically created directly.
 * 
 * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#video.
 *
 * @class VideoFile
 * @extends Phaser.Loader.File
 * @memberof Phaser.Loader.FileTypes
 * @constructor
 * @since 3.20.0
 *
 * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.
 * @param {(string|Phaser.Types.Loader.FileTypes.VideoFileConfig)} key - The key to use for this file, or a file configuration object.
 * @param {any} [urlConfig] - The absolute or relative URL to load this file from in a config object.
 * @param {string} [loadEvent] - The load event to listen for when _not_ loading as a blob. Either 'loadeddata', 'canplay' or 'canplaythrough'.
 * @param {boolean} [asBlob] - Load the video as a data blob, or via the Video element?
 * @param {boolean} [noAudio] - Does the video have an audio track? If not you can enable auto-playing on it.
 * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.
 */
var VideoFile = new Class({

    Extends: File,

    initialize:

    //  URL is an object created by VideoFile.getVideoURL
    function VideoFile (loader, key, urlConfig, loadEvent, asBlob, noAudio, xhrSettings)
    {
        if (loadEvent === undefined) { loadEvent = 'loadeddata'; }
        if (asBlob === undefined) { asBlob = false; }
        if (noAudio === undefined) { noAudio = false; }

        if (loadEvent !== 'loadeddata' && loadEvent !== 'canplay' && loadEvent !== 'canplaythrough')
        {
            loadEvent = 'loadeddata';
        }

        var fileConfig = {
            type: 'video',
            cache: loader.cacheManager.video,
            extension: urlConfig.type,
            responseType: 'blob',
            key: key,
            url: urlConfig.url,
            xhrSettings: xhrSettings,
            config: {
                loadEvent: loadEvent,
                asBlob: asBlob,
                noAudio: noAudio
            }
        };

        this.onLoadCallback = this.onVideoLoadHandler.bind(this);
        this.onErrorCallback = this.onVideoErrorHandler.bind(this);

        File.call(this, loader, fileConfig);
    },

    /**
     * Called automatically by Loader.nextFile.
     * This method controls what extra work this File does with its loaded data.
     *
     * @method Phaser.Loader.FileTypes.VideoFile#onProcess
     * @since 3.20.0
     */
    onProcess: function ()
    {
        this.state = CONST.FILE_PROCESSING;

        if (!this.config.asBlob)
        {
            this.onProcessComplete();

            return;
        }

        //  Load Video as blob

        var video = this.createVideoElement();

        this.data = video;

        var _this = this;

        this.data.onloadeddata = function ()
        {
            File.revokeObjectURL(_this.data);

            _this.onProcessComplete();
        };<commit_msg>Shouldn't remove the blob data, or videos too large for memory cannot replay<commit_after>/**
 * @author       <NAME> <<EMAIL>>
 * @copyright    2019 Photon Storm Ltd.
 * @license      {@link https://opensource.org/licenses/MIT|MIT License}
 */

var Class = require('../../utils/Class');
var CONST = require('../../const');
var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetURL = require('../GetURL');
var GetFastValue = require('../../utils/object/GetFastValue');
var IsPlainObject = require('../../utils/object/IsPlainObject');

/**
 * @classdesc
 * A single Video File suitable for loading by the Loader.
 *
 * These are created when you use the Phaser.Loader.LoaderPlugin#video method and are not typically created directly.
 * 
 * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#video.
 *
 * @class VideoFile
 * @extends Phaser.Loader.File
 * @memberof Phaser.Loader.FileTypes
 * @constructor
 * @since 3.20.0
 *
 * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.
 * @param {(string|Phaser.Types.Loader.FileTypes.VideoFileConfig)} key - The key to use for this file, or a file configuration object.
 * @param {any} [urlConfig] - The absolute or relative URL to load this file from in a config object.
 * @param {string} [loadEvent] - The load event to listen for when _not_ loading as a blob. Either 'loadeddata', 'canplay' or 'canplaythrough'.
 * @param {boolean} [asBlob] - Load the video as a data blob, or via the Video element?
 * @param {boolean} [noAudio] - Does the video have an audio track? If not you can enable auto-playing on it.
 * @param {Phaser.Types.Loader.XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.
 */
var VideoFile = new Class({

    Extends: File,

    initialize:

    //  URL is an object created by VideoFile.getVideoURL
    function VideoFile (loader, key, urlConfig, loadEvent, asBlob, noAudio, xhrSettings)
    {
        if (loadEvent === undefined) { loadEvent = 'loadeddata'; }
        if (asBlob === undefined) { asBlob = false; }
        if (noAudio === undefined) { noAudio = false; }

        if (loadEvent !== 'loadeddata' && loadEvent !== 'canplay' && loadEvent !== 'canplaythrough')
        {
            loadEvent = 'loadeddata';
        }

        var fileConfig = {
            type: 'video',
            cache: loader.cacheManager.video,
            extension: urlConfig.type,
            responseType: 'blob',
            key: key,
            url: urlConfig.url,
            xhrSettings: xhrSettings,
            config: {
                loadEvent: loadEvent,
                asBlob: asBlob,
                noAudio: noAudio
            }
        };

        this.onLoadCallback = this.onVideoLoadHandler.bind(this);
        this.onErrorCallback = this.onVideoErrorHandler.bind(this);

        File.call(this, loader, fileConfig);
    },

    /**
     * Called automatically by Loader.nextFile.
     * This method controls what extra work this File does with its loaded data.
     *
     * @method Phaser.Loader.FileTypes.VideoFile#onProcess
     * @since 3.20.0
     */
    onProcess: function ()
    {
        this.state = CONST.FILE_PROCESSING;

        if (!this.config.asBlob)
        {
            this.onProcessComplete();

            return;
        }

        //  Load Video as blob

        var video = this.createVideoElement();

        this.data = video;

        var _this = this;

        this.data.onloadeddata = function ()
        {
            _this.onProcessComplete();
        };
{'fraction_non_alphanumeric': 0.11633324198410523, 'fraction_numerical': 0.003288572211564812, 'mean_word_length': 2.497364638236703, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '649208', 'n_tokens_mistral': 2066, 'n_tokens_neox': 2008, 'n_words': 640}