AgoraIO / Basic-Video-Broadcasting

Sample app to join/leave a channel, set the role as a host/audience, mute/unmute, switch between front/rear cameras, and set the video parameters.
MIT License
269 stars 287 forks source link

Getting Cannot read property 'appendChild' of null on switchDevice method call #87

Open kush3107 opened 4 years ago

kush3107 commented 4 years ago

I am trying to switch the input device for the current local stream. I am on sdk version 3.0.2 but when I try to do so I get the error in the attached screenshot. I followed this link

This link clearly says that I just need to call this method above version 2.5.0 I have attached the console error

Screenshot 2020-05-03 at 11 08 22 PM
kush3107 commented 4 years ago
switchDevice(type: 'audio' | 'video', deviceId: string): Promise<void> {
        console.log(type, deviceId);
        this._currentStream?.stop();

        return new Promise((resolve, reject) => {
            // @ts-ignore
            this._currentStream?.getAudioTrack().stop();
            this._currentStream!.switchDevice(type, deviceId, () => {
                resolve();
            }, reject);
        });
    }
plutoless commented 4 years ago

the error usually means you are trying to play a dom but that dom does not exist. could you pls check all you play api call