recording state fix wip
This commit is contained in:
parent
fd64e946bf
commit
c28508bcf7
|
|
@ -478,6 +478,7 @@ SQL
|
|||
end
|
||||
|
||||
if tracks_changed
|
||||
music_session.active_music_session.tick_track_changes
|
||||
Notification.send_tracks_changed(music_session.active_music_session)
|
||||
end
|
||||
|
||||
|
|
@ -529,6 +530,7 @@ SQL
|
|||
end
|
||||
|
||||
if send_tracks_changed
|
||||
music_session.active_music_session.tick_track_changes
|
||||
Notification.send_tracks_changed(music_session.active_music_session)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@
|
|||
GetAudioRecordingPreference: enumAppCounter++,
|
||||
PeerStopRecording: enumAppCounter++,
|
||||
FrontStopRecording: enumAppCounter++,
|
||||
GetCurrentRecordingId: enumAppCounter++,
|
||||
});
|
||||
|
||||
function setupWebSocketConnection() {
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ AppStore = context.AppStore
|
|||
onAppInit: (@app) ->
|
||||
|
||||
onSessionMixerChange: (sessionMixers) ->
|
||||
console.log("_DEBUG_ SessionRecordBtn onSessionMixerChange", sessionMixers)
|
||||
console.log("_DEBUG_* SessionRecordBtn onSessionMixerChange", sessionMixers.session)
|
||||
@setState({isRecording: sessionMixers.session.isRecording})
|
||||
@setState({isRecordingInitiator: sessionMixers.session.recordingClinetId && sessionMixers.session.recordingClinetId == @app.clientId})
|
||||
@setState({isRecordingOwner: sessionMixers.session.recordingClinetId == @app.clientId})
|
||||
|
||||
getInitialState: () ->
|
||||
{childWindow: null, isRecording: false}
|
||||
|
|
@ -25,7 +25,7 @@ AppStore = context.AppStore
|
|||
return 'noclose'
|
||||
|
||||
handleClick: () ->
|
||||
if @state.isRecording && @state.isRecordingInitiator
|
||||
if @state.isRecording && @state.isRecordingOwner
|
||||
RecordingActions.stopRecording()
|
||||
else
|
||||
@openRecording()
|
||||
|
|
@ -53,7 +53,7 @@ AppStore = context.AppStore
|
|||
btnStyles = "session-record session-record-btn left"
|
||||
|
||||
if this.state.isRecording
|
||||
if this.state.isRecordingInitiator
|
||||
if this.state.isRecordingOwner
|
||||
btnStyles = btnStyles+' button-orange'
|
||||
`<a className={btnStyles} data-is-recording={this.state.isRecording} onClick={this.handleClick}>
|
||||
<img src="/assets/content/icon_record.png" align="texttop" height="14" width="14"/>
|
||||
|
|
@ -63,7 +63,7 @@ AppStore = context.AppStore
|
|||
btnStyles = btnStyles+' button-grey'
|
||||
`<a className={btnStyles} data-is-recording={this.state.isRecording}>
|
||||
<img src="/assets/content/icon_record.png" align="texttop" height="14" width="14"/>
|
||||
RECORDING INPROGRESS
|
||||
RECORDING IN-PROGRESS
|
||||
</a>`
|
||||
else
|
||||
btnStyles = btnStyles+' button-grey'
|
||||
|
|
|
|||
|
|
@ -1616,18 +1616,49 @@ ConfigureTracksActions = @ConfigureTracksActions
|
|||
onUpdateSession: (session) ->
|
||||
@updateSessionInfo(session, true)
|
||||
|
||||
updateSessionInfo: (session, force) ->
|
||||
if force == true || @currentTrackChanges < session.track_changes_counter
|
||||
logger.debug("updating current track changes from %o to %o", @currentTrackChanges, session.track_changes_counter)
|
||||
@currentTrackChanges = session.track_changes_counter
|
||||
@sendClientParticipantChanges(@currentSession, session)
|
||||
logger.debug('update current session')
|
||||
@updateCurrentSession(session);
|
||||
#if(callback != null) {
|
||||
# callback();
|
||||
#}
|
||||
else
|
||||
logger.info("ignoring refresh because we already have current: " + @currentTrackChanges + ", seen: " + session.track_changes_counter);
|
||||
# updateSessionInfo: (session, force) ->
|
||||
# console.log("_DEBUG_* SessionStore#updateSessionInfo", session)
|
||||
# if force == true || @currentTrackChanges < session.track_changes_counter
|
||||
# logger.debug("updating current track changes from %o to %o", @currentTrackChanges, session.track_changes_counter)
|
||||
# @currentTrackChanges = session.track_changes_counter
|
||||
# @sendClientParticipantChanges(@currentSession, session)
|
||||
# console.log("_DEBUG_* recordingState", recordingState);
|
||||
# logger.debug('update current session')
|
||||
# @updateCurrentSession(session);
|
||||
# #if(callback != null) {
|
||||
# # callback();
|
||||
# #}
|
||||
# else
|
||||
# logger.info("ignoring refresh because we already have current: " + @currentTrackChanges + ", seen: " + session.track_changes_counter);
|
||||
|
||||
updateSessionInfo: `function(session, force) {
|
||||
console.log("_DEBUG_* SessionStore#updateSessionInfo", session);
|
||||
if ((force === true) || (this.currentTrackChanges < session.track_changes_counter)) {
|
||||
logger.debug("updating current track changes from %o to %o", this.currentTrackChanges, session.track_changes_counter);
|
||||
this.currentTrackChanges = session.track_changes_counter;
|
||||
this.sendClientParticipantChanges(this.currentSession, session);
|
||||
this.recordingModel.getRecordingState().then(
|
||||
(recordingState) => {
|
||||
if (recordingState) {
|
||||
//merge the recording state with the session
|
||||
console.log("_DEBUG_* SessionStore getRecordingState -> recordingState", recordingState);
|
||||
session = {...session, ...recordingState};
|
||||
}
|
||||
}
|
||||
).finally(() => {
|
||||
console.log("_DEBUG_* SessionStore final -> recordingState", session);
|
||||
logger.debug('update current session');
|
||||
this.updateCurrentSession(session);
|
||||
//if(callback != null) {
|
||||
// callback();
|
||||
//}
|
||||
|
||||
})
|
||||
|
||||
} else {
|
||||
return logger.info("ignoring refresh because we already have current: " + this.currentTrackChanges + ", seen: " + session.track_changes_counter);
|
||||
}
|
||||
}`
|
||||
|
||||
|
||||
leaveSessionRest: () ->
|
||||
|
|
@ -1769,6 +1800,7 @@ ConfigureTracksActions = @ConfigureTracksActions
|
|||
# @issueChange()
|
||||
|
||||
updateCurrentSession: `async function(sessionData) {
|
||||
console.log("_DEBUG_* SessionStore#updateCurrentSession", sessionData)
|
||||
if (sessionData !== null) {
|
||||
let until_time;
|
||||
this.currentOrLastSession = sessionData;
|
||||
|
|
|
|||
|
|
@ -213,12 +213,11 @@
|
|||
stopRecording(recordingId, null, null);
|
||||
}
|
||||
|
||||
function handleRecordingStartResult(recordingId, result) {
|
||||
|
||||
async function handleRecordingStartResult(recordingId, result) {
|
||||
//console.log("_DEBUG_* handleRecordingStartResult", recordingId, result)
|
||||
var success = result.success;
|
||||
var reason = result.reason;
|
||||
var detail = result.detail;
|
||||
|
||||
var detail = result.detail
|
||||
|
||||
if(success) {
|
||||
var details = {clientId: app.clientId, isRecording:true}
|
||||
|
|
@ -235,7 +234,7 @@
|
|||
}
|
||||
|
||||
function handleRecordingStopResult(recordingId, result) {
|
||||
|
||||
//console.log("_DEBUG_* handleRecordingStopResult", recordingId, result)
|
||||
var success = result.success;
|
||||
var reason = result.reason;
|
||||
var detail = result.detail;
|
||||
|
|
@ -255,6 +254,7 @@
|
|||
}
|
||||
|
||||
function handleRecordingStarted(recordingId, result, clientId) {
|
||||
console.log("_DEBUG_* handleRecordingStarted", recordingId, result)
|
||||
var success = result.success;
|
||||
var reason = result.reason;
|
||||
var detail = result.detail;
|
||||
|
|
@ -281,7 +281,26 @@
|
|||
context.RecordingActions.startedRecording(details)
|
||||
}
|
||||
|
||||
function handleRecordingStopped(recordingId, result) {
|
||||
async function handleRecordingStopped(recordingId, result) {
|
||||
console.log("_DEBUG_* handleRecordingStopped", recordingId, result, $self)
|
||||
// var recordState = await $self.getRecordingState();
|
||||
// console.log("_DEBUG_* handleRecordingStopped -> recordState", recordState);
|
||||
var session;
|
||||
try{
|
||||
session = context.SessionStore.getCurrentOrLastSession();
|
||||
}catch(e){
|
||||
console.error("_DEBUG_* Error getting session", e);
|
||||
}
|
||||
|
||||
console.log("_DEBUG_* handleRecordingStopped -> session", session);
|
||||
if(session) {
|
||||
context.SessionStore.updateSessionInfo(session)
|
||||
}
|
||||
|
||||
// if(recordState.isRecording) {
|
||||
// //we are still recording, so don't stop
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(recordingId == "video") {
|
||||
// comes from VideoRecordingStopped
|
||||
|
|
@ -334,7 +353,7 @@
|
|||
}
|
||||
|
||||
function handleRecordingAborted(recordingId, result) {
|
||||
|
||||
//console.log("_DEBUG_* handleRecordingAborted", recordingId, result)
|
||||
if(recordingId == "video") {
|
||||
|
||||
// comes from AbortedVideoRecording
|
||||
|
|
@ -401,6 +420,28 @@
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* sync recording state with the client back end
|
||||
*/
|
||||
async function getRecordingState() {
|
||||
var isRecording = false;
|
||||
var recordingClientId = null;
|
||||
var currentRecId = await jamClient.GetCurrentRecordingId(); //if this passes recording Id it means there is an ongoing recording
|
||||
//var currentRecId = currentRecordingId
|
||||
console.log("_DEBUG_* getRecordingState", currentRecId)
|
||||
if(currentRecId && currentRecId !== '') {
|
||||
var recording = await rest.getRecordingPromise({id: currentRecId})
|
||||
if(recording) {
|
||||
isRecording = true;
|
||||
recordingClientId = recording.client_id;
|
||||
}
|
||||
} else {
|
||||
isRecording = false;
|
||||
recordingClientId = null;
|
||||
}
|
||||
return { isRecording: isRecording, recordingClientId: recordingClientId };
|
||||
}
|
||||
|
||||
this.initialize = function() {
|
||||
};
|
||||
|
||||
|
|
@ -411,6 +452,7 @@
|
|||
this.reset = reset;
|
||||
this.stopRecordingIfNeeded = stopRecordingIfNeeded;
|
||||
this.currentOrLastRecordingId = function () { return currentOrLastRecordingId; };
|
||||
this.getRecordingState = getRecordingState;
|
||||
|
||||
context.JK.HandleRecordingStartResult = handleRecordingStartResult;
|
||||
context.JK.HandleRecordingStopResult = handleRecordingStopResult;
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@
|
|||
|
||||
// you should only update currentSession with this function
|
||||
function updateCurrentSession(sessionData) {
|
||||
console.log("_DEBUG_* sessionModel#updateCurrentSession", sessionData)
|
||||
if(sessionData != null) {
|
||||
currentOrLastSession = sessionData;
|
||||
}
|
||||
|
|
@ -428,10 +429,12 @@
|
|||
}
|
||||
|
||||
function updateSessionInfo(response, callback, force) {
|
||||
console.log("_DEBUG_* sessionModel#updateSessionInfo", response)
|
||||
if(force === true || currentTrackChanges < response.track_changes_counter) {
|
||||
logger.debug("updating current track changes from %o to %o", currentTrackChanges, response.track_changes_counter)
|
||||
currentTrackChanges = response.track_changes_counter;
|
||||
sendClientParticipantChanges(currentSession, response);
|
||||
|
||||
updateCurrentSession(response);
|
||||
if(callback != null) {
|
||||
callback();
|
||||
|
|
|
|||
Loading…
Reference in New Issue