1 line
2.5 KiB
JavaScript
1 line
2.5 KiB
JavaScript
|
|
"use strict";var r=function(r){return r&&r.__esModule?r["default"]:r},t=function(){function r(r,t){for(var e in t){var i=t[e];i.configurable=!0,i.value&&(i.writable=!0)}Object.defineProperties(r,t)}return function(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}}(),e=function(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")},i=r(require("./audio-controller")),n=r(require("async")),s={FORWARD:0,REVERSE:1},o=function(){function r(t){e(this,r),this.forward=new i(t),this.reverse=new i(t,!0),this.direction=s.FORWARD,this.forward.onCurrentTime=this.onCurrentTime.bind(this),this._currentTime=0}return t(r,{duration:{get:function(){return this.forward.duration}},currentTime:{get:function(){return this._currentTime},set:function(r){this._currentTime=r,this.reverse.currentTime=this.forward.duration-r,this.forward.currentTime=r,this.direction===s.REVERSE?this.forward.stop():this.reverse.stop()}},playbackRate:{set:function(r){this._playbackRate=r,r>=0&&this.direction===s.REVERSE?(this.direction=s.FORWARD,this.forward.currentTime=this._currentTime,this.forward.onCurrentTime=this.onCurrentTime.bind(this),this.reverse.onCurrentTime=null,this.reverse.stop()):0>r&&this.direction===s.FORWARD&&(this.direction=s.REVERSE,this.reverse.currentTime=this.forward.duration-this._currentTime,this.reverse.onCurrentTime=this.onCurrentTime.bind(this),this.forward.onCurrentTime=null,this.forward.stop()),this.direction===s.FORWARD?this.forward.playbackRate=r:this.direction===s.REVERSE&&(this.reverse.playbackRate=-r)},get:function(){return this._playbackRate}},load:{value:function(r){var t=this;n.parallel([function(r){t.forward.load(r)},function(r){t.reverse.load(r)}],r)}},stop:{value:function(){var r=void 0===arguments[0]?0:arguments[0];this.currentTime=r,this.forward.stop(),this.reverse.stop()}},onCurrentTime:{value:function(r){this.direction===s.REVERSE?this._currentTime=this.forward.duration-r:this._currentTime=r}},playAtTime:{value:function(r){var t=void 0===arguments[1]?1:arguments[1];this._currentTime=r||0,this._playbackRate=t,this.direction===s.REVERSE&&(this.direction=s.FORWARD,this.forward.onCurrentTime=this.onCurrentTime.bind(this),this.reverse.onCurrentTime=null,this.reverse.stop()),this.forward.currentTime=this._currentTime,this.forward.playbackRate=this._playbackRate}},dispose:{value:function(){this.forward.onCurrentTime=null,this.forward.dispose(),this.reverse.onCurrentTime=null,this.reverse.dispose(),this.forward=null,this.reverse=null}}}),r}();module.exports=o;
|