miroslavpejic85 / mirotalksfu

🏆 WebRTC - SFU - Simple, Secure, Scalable Real-Time Video Conferences Up to 8k, compatible with all browsers and platforms.
https://sfu.mirotalk.com
GNU Affero General Public License v3.0
2.15k stars 340 forks source link

"Leave" button doesn't work #111

Closed qiangweihewu closed 1 year ago

qiangweihewu commented 1 year ago

Describe the bug

"Leave" button doesn't work

To Reproduce

Steps to reproduce the behavior:

  1. Go to main menu
  2. Click on 'leave'
  3. Error:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'stop') at RoomClient.stopRecording (RoomClient.js:3334:28) at Room.js:1549:16 at RoomClient.js:2092:64 at Array.forEach () at RoomClient.event (RoomClient.js:2092:42) at RoomClient. (RoomClient.js:2033:30) at

Desktop - Mobile

iphone 13 ios 15 and windows chrome

My solution:

I changed the code in RoomClient.js to this and it works:

stopRecording() { this._isRecording = false; if (this.mediaRecorder) { this.mediaRecorder.stop(); } if (this.recScreenStream) { this.recScreenStream.getTracks().forEach((track) => { if (track && track.kind === 'video') track.stop(); }); } if (this.isMobileDevice) this.getId('swapCameraButton').className = ''; this.event(_EVENTS.stopRec); this.sound('recStop'); }

miroslavpejic85 commented 1 year ago

Hello @qiangweihewu,

I'm not able to reproduce it by steps you provided.

The stopRecording method is called when leaving the room only if recording is in progress, ensuring that any ongoing video recording is stopped and saved automatically. This helps prevent the loss of recorded video in case the user forgets to manually click the 'stop recording' button.

    rc.on(RoomClient.EVENTS.exitRoom, () => {
        console.log('Room Client leave room');
        if (rc.isRecording() || recordingStatus.innerText != '0s') {
            console.log('Room Client save recording before to exit');
            rc.stopRecording();
        }
        if (survey.enabled) {
            leaveFeedback();
        } else {
            openURL('/newroom');
        }
    });

Just some questions:

  1. Was the recording active at the time you pressed the leave room button?
  2. Did you encounter this error in the official live demo: https://sfu.mirotalk.com?

Thank you!