import IVideoApiModel from '@/model/api/video/IVideoApiModel' ; import IServerConfigModel from '@/model/serverConfig/IServerConfigModel' ; import { inject , injectable } from 'inversify' ; import * as apid from '../../../../../../api' ; import ISendVideoFileToKodiState from './ISendVideoFileToKodiState' ; @ injectable ( ) export default class SendVideoFileToKodiState implements ISendVideoFileToKodiState { public hostName : string | null = null ; private serverConfig : IServerConfigModel ; private videoApiModel : IVideoApiModel ; constructor ( @ inject ( 'IServerConfigModel' ) serverConfig , @ inject ( 'IVideoApiModel' ) videoApiModel ) { this . serverConfig = serverConfig ; this . videoApiModel = videoApiModel ; } /**
     * 初期化
     */ public init ( hostName ) { this . hostName = hostName ; if ( this . hostName === null ) { const hosts = this . getHosts ( ) ; if ( hosts . length > 0 ) { this . hostName = hosts [ 0 ] ; } } } return public getHosts ( ) { const config = this . serverConfig . getConfig ( ) ; return config === null || typeof config . kodiHosts === 'undefined' ? [ ] : config . kodiHosts ; } param videoFileId return public async send ( videoFileId ) { if ( this . hostName === null ) { throw new Error ( 'HostNameIsNull' ) ; } await this . videoApiModel . sendToKodi ( this . hostName , videoFileId ) ; } }