AnP/Public/ecma/Models/ThreadModel.ecma.js

53 lines
1.6 KiB
JavaScript

"use strict";
import {Common} from "../Utils/Common.ecma.js";
/**
* @class ThreadModel
* @constructor
* @param {!thread_callback} callback
* @param {!(Object.<string, any|null>|Array.<any|null>)} inputs
* @return {void}
* @access public
* @static
*/
export const ThreadModel = (function(){
/**
* @callback thread_callback
* @param {!ThreadModel} thread
* @return {void}
*/
/**
* @constructs ThreadModel
* @param {!thread_callback} callback
* @param {!number} i
* @param {?(Object.<string, any|null>|Array.<any|null>)} [inputs = null]
* @return {void}
* @access private
* @static
*/
const ThreadModel = function(callback, i, inputs = null){
/** @type {number} */
this.i = i;
/** @type {thread_callback} */
this.callback = callback;
/** @type {boolean} */
this.autoplay = Common.get_value("autoplay", inputs, true);
/** @type {boolean} */
this.play_immediately = Common.get_value("play_immediately", inputs, false);
/** @type {number} */
this.last = this.play_immediately ? 0 : Date.now();
/** @type {boolean} */
this.stopped = Common.get_value("stopped", inputs, false);
/** @type {number} */
this.frames_per_second = Common.get_value(["frames_per_second", "fps"], inputs, 0);
/** @type {number} */
this.timer = this.frames_per_second > 0 ? 1000 / this.frames_per_second : 0;
/** @type {boolean} */
this.bucle = Common.get_value("bucle", inputs, false);
};
return ThreadModel;
})();