You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
import defined from "../Core/defined.js";
|
|
/**
|
|
* @alias KmlTourWait
|
|
* @constructor
|
|
*
|
|
* @param {Number} duration entry duration
|
|
*/
|
|
function KmlTourWait(duration) {
|
|
this.type = "KmlTourWait";
|
|
this.blocking = true;
|
|
this.duration = duration;
|
|
|
|
this.timeout = null;
|
|
}
|
|
|
|
/**
|
|
* Play this playlist entry
|
|
*
|
|
* @param {KmlTourWait.DoneCallback} done function which will be called when playback ends
|
|
*/
|
|
KmlTourWait.prototype.play = function (done) {
|
|
var self = this;
|
|
this.activeCallback = done;
|
|
this.timeout = setTimeout(function () {
|
|
delete self.activeCallback;
|
|
done(false);
|
|
}, this.duration * 1000);
|
|
};
|
|
|
|
/**
|
|
* Stop execution of curent entry, cancel curent timeout
|
|
*/
|
|
KmlTourWait.prototype.stop = function () {
|
|
clearTimeout(this.timeout);
|
|
if (defined(this.activeCallback)) {
|
|
this.activeCallback(true);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* A function which will be called when playback ends.
|
|
*
|
|
* @callback KmlTourWait.DoneCallback
|
|
* @param {Boolean} terminated true if {@link KmlTourWait#stop} was
|
|
* called before entry done playback.
|
|
*/
|
|
export default KmlTourWait;
|