import { inject , injectable } from 'inversify' ; import * as apid from '../../../../../../api' ; import IRecordedApiModel from '../../../api/recorded/IRecordedApiModel' ; import IVideoApiModel from '../../../api/video/IVideoApiModel' ; import IRecordedStreamingVideoState from './IRecordedStreamingVideoState' ; @ injectable ( ) export default class RecordedStreamingVideoState implements IRecordedStreamingVideoState { private videoApiModel : IVideoApiModel ; private recordedApiModel : IRecordedApiModel ; private recordedItem : apid . RecordedItem | null = null ; private duration : number = 0 ; private fetchDateTime : number = 0 ; constructor ( @ inject ( 'IVideoApiModel' ) videoApiModel , @ inject ( 'IRecordedApiModel' ) recordedApiModel ) { this . videoApiModel = videoApiModel ; this . recordedApiModel = recordedApiModel ; } /**
     * 各種変数初期化
     */ public clear ( ) { this . recordedItem = null ; this . duration = 0 ; this . fetchDateTime = 0 ; } param recordedId param videoFileId return public async fetchInfo ( recordedId , videoFileId ) { this . recordedItem = await this . recordedApiModel . get ( recordedId , true ) ; this . duration = await this . videoApiModel . getDuration ( videoFileId ) ; this . fetchDateTime = new Date ( ) . getTime ( ) ; } return public isRecording ( ) { return this . recordedItem !== null ? this . recordedItem . isRecording : false ; } return public getDuration ( ) { if ( this . recordedItem === null ) { return 0 ; } if ( this . recordedItem . isRecording === true ) { return this . duration + ( new Date ( ) . getTime ( ) - this . fetchDateTime ) / 1000 ; } return this . duration ; } }