cometchat / chat-sdk-javascript

Voice & Video Calling and Text Chat SDK for JavaScript/Web
Other
30 stars 24 forks source link

Override browser alert when things go wrong with audio/video #83

Closed joeyslack closed 6 months ago

joeyslack commented 3 years ago

User receives a browser alert dialog when things go wrong in a video chat. It would be more appropriate to expand CometChat event listeners, and override the hardcoded alert that is present in the embedded script on the hosted iframe react code, as such:

}).then(o.onLocalTracks).catch((function(e) {
                            console.log("erroraudio", e), JitsiMeetJS.createLocalTracks({
                                devices: ["audio"],
                                facingMode: "user"
                            }).then(o.onLocalTracks)
                        }))) : (b.log("CallingComponent", "createLocalTracks Video & Audio", ""), JitsiMeetJS.createLocalTracks({
                            devices: ["audio", "video"]
                        }).then(o.onLocalTracks).catch((function(t) {
                            JitsiMeetJS.createLocalTracks({
                                devices: ["audio"],
                                facingMode: "user"
                            }).then((function(e) {
                                o.onLocalTracks(e), alert("There is something wrong with your camera")
                            })).catch((function(t) {
                                b.log("CallingComponent", "Error creating Audio local media : ", t), o.setState({
                                    noMic: !0,
                                    showAudioMuteButton: !1
                                }), e = !0, JitsiMeetJS.createLocalTracks({
                                    devices: ["video"],
                                    facingMode: "user"
                                }).then((function(e) {
                                    o.onLocalTracks(e), alert("There is something wrong with your mic")
                                })).catch((function(t) {
                                    e && alert("There is something wrong with your camera and mic"), b.log("CallingComponent", "Error creating Video local media : ", t), o.setState({
                                        noCamera: !0,
                                        showVideoPauseButton: !1
                                    })
                                }))
                            }))
                        })))

Instead of an alert, can we bubble this to a Cometchat event listener, as other documented features?

new CometChat.OngoingCallListener({
        onUserListUpdated: userList => {
            console.log("user list:", userList);
    },
    onCallEnded: call => {
      console.log("Call ended:", call);
    },
    onError: error => {
      console.log("Error :", error);
    },
    onMediaDeviceListUpdated: deviceList => {
      console.log("Device List:", deviceList);
    },
  })

Could we bubble up the message in this error, or could a new error be added OnCameraError, etc, to handle this?

Would much prefer to handle the errors in my own UI instead of using the browser's alert.

Thanks

joeyslack commented 3 years ago

Perhaps, at the very least, can I pass a "verbose" or "debug" flag to the embed? Something like: https://rtc-web-us.cometchat.io/?v=3&verbose=0 or something? Just need a way to easily supress browser alerts for now, can work on event bubbling later if that's harder for you.

ketanyekale commented 6 months ago

Thank you for the suggestions. The calls SDK has been separated from the Chat SDK and the alerts have been removed.