// import { autobind } from 'core-decorators'; // // import { ENDPOINT } from '../endpointConstants'; // import AppState from '../stores/appState'; // // @autobind // export default class SessionPlayer { // _appState: AppState; // _audio: HTMLAudioElement; // _playing: Promise; // _session: string; // isPlaying: boolean; // // constructor(appState: AppState, session: string) { // this._appState = appState; // this._session = session; // } // // getUrl(startTime: number, endTime?: number): Promise { // const requestArgs: any = { // bt: startTime, // session: this._session, // }; // if (endTime) { // requestArgs.tt = endTime; // } // return this._appState.apiRequest(ENDPOINT.SIGN_AUDIO_URL, requestArgs) // .then((result: { url: string }) => { // console.log({ result }); // return result.url; // }); // } // // playUrl(url: string, confirmStarted?: VoidFunction): Promise { // return new Promise((resolve: VoidFunction, reject: any) => { // this._audio = new Audio(url); // this._audio.onplaying = () => { // if (confirmStarted) { // confirmStarted(); // } // }; // this._audio.onended = resolve; // this._audio.onpause = resolve; // this._audio.onerror = () => { // this.stop(); // this._audio = null; // reject(); // }; // this.isPlaying = true; // this._playing = this._audio.play(); // }); // } // // streamFromTime(startTime: number, endTime?: number, confirmStarted?: VoidFunction): Promise { // this.stop(); // if (this._session) { // console.log(`playing session ${this._session} from ${startTime}`); // return this.getUrl(startTime, endTime) // .then((url: string) => this.playUrl(url, confirmStarted)) // .catch(console.error); // } // return Promise.resolve(); // } // // pause(): void { // this.stop(); // } // // stop(): void { // this.isPlaying = false; // if (this._playing && this._audio) { // const stopAudio = this._audio; // this._playing.then(() => stopAudio.pause()); // } // } // // setSession(session: string): void { // this._session = session; // } // }