refactor(external videos): state as integer
A media state may have more than 2 states. Moving this property back to integer so it can be extended.
This commit is contained in:
parent
4a5b92445a
commit
d4888f585c
@ -36,7 +36,7 @@ class UpdateExternalVideoRecordEvent extends AbstractExternalVideoRecordEvent {
|
|||||||
eventMap.put(TIME, time.toString)
|
eventMap.put(TIME, time.toString)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setState(state: Boolean) {
|
def setState(state: Int) {
|
||||||
eventMap.put(STATE, state.toString)
|
eventMap.put(STATE, state.toString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ case class StartExternalVideoPubMsgBody(externalVideoUrl: String)
|
|||||||
|
|
||||||
object UpdateExternalVideoPubMsg { val NAME = "UpdateExternalVideoPubMsg" }
|
object UpdateExternalVideoPubMsg { val NAME = "UpdateExternalVideoPubMsg" }
|
||||||
case class UpdateExternalVideoPubMsg(header: BbbClientMsgHeader, body: UpdateExternalVideoPubMsgBody) extends StandardMsg
|
case class UpdateExternalVideoPubMsg(header: BbbClientMsgHeader, body: UpdateExternalVideoPubMsgBody) extends StandardMsg
|
||||||
case class UpdateExternalVideoPubMsgBody(status: String, rate: Double, time: Double, state: Boolean)
|
case class UpdateExternalVideoPubMsgBody(status: String, rate: Double, time: Double, state: Int)
|
||||||
|
|
||||||
object StopExternalVideoPubMsg { val NAME = "StopExternalVideoPubMsg" }
|
object StopExternalVideoPubMsg { val NAME = "StopExternalVideoPubMsg" }
|
||||||
case class StopExternalVideoPubMsg(header: BbbClientMsgHeader, body: StopExternalVideoPubMsgBody) extends StandardMsg
|
case class StopExternalVideoPubMsg(header: BbbClientMsgHeader, body: StopExternalVideoPubMsgBody) extends StandardMsg
|
||||||
@ -20,7 +20,7 @@ case class StartExternalVideoEvtMsgBody(externalVideoUrl: String)
|
|||||||
|
|
||||||
object UpdateExternalVideoEvtMsg { val NAME = "UpdateExternalVideoEvtMsg" }
|
object UpdateExternalVideoEvtMsg { val NAME = "UpdateExternalVideoEvtMsg" }
|
||||||
case class UpdateExternalVideoEvtMsg(header: BbbClientMsgHeader, body: UpdateExternalVideoEvtMsgBody) extends BbbCoreMsg
|
case class UpdateExternalVideoEvtMsg(header: BbbClientMsgHeader, body: UpdateExternalVideoEvtMsgBody) extends BbbCoreMsg
|
||||||
case class UpdateExternalVideoEvtMsgBody(status: String, rate: Double, time: Double, state: Boolean)
|
case class UpdateExternalVideoEvtMsgBody(status: String, rate: Double, time: Double, state: Int)
|
||||||
|
|
||||||
object StopExternalVideoEvtMsg { val NAME = "StopExternalVideoEvtMsg" }
|
object StopExternalVideoEvtMsg { val NAME = "StopExternalVideoEvtMsg" }
|
||||||
case class StopExternalVideoEvtMsg(header: BbbClientMsgHeader, body: StopExternalVideoEvtMsgBody) extends BbbCoreMsg
|
case class StopExternalVideoEvtMsg(header: BbbClientMsgHeader, body: StopExternalVideoEvtMsgBody) extends BbbCoreMsg
|
||||||
|
@ -4,6 +4,7 @@ import { defineMessages, injectIntl } from 'react-intl';
|
|||||||
import ReactPlayer from 'react-player';
|
import ReactPlayer from 'react-player';
|
||||||
import { sendMessage, onMessage, removeAllListeners } from './service';
|
import { sendMessage, onMessage, removeAllListeners } from './service';
|
||||||
import logger from '/imports/startup/client/logger';
|
import logger from '/imports/startup/client/logger';
|
||||||
|
import Service from './service';
|
||||||
|
|
||||||
import ArcPlayer from './custom-players/arc-player';
|
import ArcPlayer from './custom-players/arc-player';
|
||||||
import PeerTubePlayer from './custom-players/peertube';
|
import PeerTubePlayer from './custom-players/peertube';
|
||||||
@ -345,8 +346,9 @@ class VideoPlayer extends Component {
|
|||||||
|
|
||||||
this.seekTo(time);
|
this.seekTo(time);
|
||||||
|
|
||||||
if (playing !== state) {
|
const playingState = Service.getPlayingState(state);
|
||||||
this.setState({ playing: state });
|
if (playing !== playingState) {
|
||||||
|
this.setState({ playing: playingState });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,11 @@ const sendMessage = (event, data) => {
|
|||||||
|
|
||||||
lastMessage = { ...data, event };
|
lastMessage = { ...data, event };
|
||||||
|
|
||||||
|
// Use an integer for playing state
|
||||||
|
// 0: stopped 1: playing
|
||||||
|
// We might use more states in the future
|
||||||
|
data.state = data.state ? 1 : 0;
|
||||||
|
|
||||||
makeCall('emitExternalVideoEvent', { status: event, playerStatus: data });
|
makeCall('emitExternalVideoEvent', { status: event, playerStatus: data });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,6 +69,13 @@ const getVideoUrl = () => {
|
|||||||
return externalVideo && externalVideo.externalVideoUrl;
|
return externalVideo && externalVideo.externalVideoUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Convert state (Number) to playing (Boolean)
|
||||||
|
const getPlayingState = (state) => {
|
||||||
|
if (state === 1) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
sendMessage,
|
sendMessage,
|
||||||
onMessage,
|
onMessage,
|
||||||
@ -72,4 +84,5 @@ export {
|
|||||||
isUrlValid,
|
isUrlValid,
|
||||||
startWatching,
|
startWatching,
|
||||||
stopWatching,
|
stopWatching,
|
||||||
|
getPlayingState,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user