How to know if Recording is running in session or not?

How to know if Recording is running in session or not ?

One way i can think is get all recording list and then filter out by session id and recording status… but is there any other direct way where i can get this flag by session object or some other way ?

This is how I get recordings

const session = openvidu.initSession();

session.on(‘recordingStarted’, (event) => {
// Add Code Here
});

session.on(‘recordingStopped’, (event) => {
// Add Code Here
});

I use angular, so I have a service for OpenVidu. If you are interested I can show you the full implementation. I use BehaviorSubject and full disclaimer I am not an RXJS expert

 // Recording
 public recordState = new BehaviorSubject<boolean>(false);


session.on(‘recordingStarted’, (event) => {
       this.recordState.next(true);
});

session.on(‘recordingStopped’, (event) => {
       this.recordState.next(false);
});

In my components

isRecording: boolean

ngOnInit(): void {
     this.openviduService.recordState.subscribe(
         (recording) => (this.isRecording = recording)
     );
}

And also don’t forget to unsubscribe.

I am Using Java client with ui made of plain javascript . Where user start recording from browser and suppose he closed or refresh the page without stopping the recording and come back to same session within few time then I need to find out if is there any recoding is already running or not in that session so that on ui I can show start/stop button accordingly.

Oh I see, then you just need to get the recording, this for REST API

/openvidu/api/recordings/<RECORDING_ID>

In my case RECORDING_ID is the SessionID since it’s always unique and never reused

this recturns Recording Object

{
    "id": "ses_YnDaGYNcd7",
    "object": "recording",
    "name": "MyRecording",
    "outputMode": "COMPOSED",
    "hasAudio": true,
    "hasVideo": true,
    "resolution": "1280x720",
    "recordingLayout": "CUSTOM",
    "customLayout": "",
    "sessionId": "ses_YnDaGYNcd7",
    "createdAt": 1600564785109,
    "size": 303072692,
    "duration": 108000.234,
    "url": "https://my.openvidu.ip/openvidu/recordings/ses_YnDaGYNcd7/MyRecording.mp4",
    "status": "ready"
}

Look at the status
starting, started, stopped, ready, failed

1 Like

For Java

// Get recording
Recording recordingRetrieved = openvidu.getRecording(recordingId);

Yes in this way we can get details but in my case there might be multiple recording exist in same session as I do start- stop and again start recording. So either I need keep track of running recording of each session on server OR need to get all recording and then filter by session Id and then get recording of status of started.

Just call the REST API /openvidu/api/sessions/<SESSION_ID> to retrieve the session details. There is a property recording which is true when a recording is currently active.

3 Likes

In my case, it’s always the Session ID + some number.

For example, if Session ID is 6MEBpdT0SLa4lIBDizLe RecordingID will 6MEBpdT0SLa4lIBDizLe-1 or 6MEBpdT0SLa4lIBDizLe-2 and also I keep track of my RecordingID using Browser Local Storage if the user refreshes the Page I then Check for recordings, if one already exists is still running I then Updated my UI, or If fails to retrieve recording the user I notify the user to start a new recording.