Updated handling of audio device change
parent
30f42d6ced
commit
bc9deb1200
|
|
@ -809,6 +809,8 @@ export default class RoomClient
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'changeAudioDevice() | new selected webcam [device:%o]',
|
'changeAudioDevice() | new selected webcam [device:%o]',
|
||||||
device);
|
device);
|
||||||
|
|
||||||
|
this._micProducer.track.stop();
|
||||||
|
|
||||||
logger.debug('changeAudioDevice() | calling getUserMedia()');
|
logger.debug('changeAudioDevice() | calling getUserMedia()');
|
||||||
|
|
||||||
|
|
@ -822,14 +824,18 @@ export default class RoomClient
|
||||||
|
|
||||||
const track = stream.getAudioTracks()[0];
|
const track = stream.getAudioTracks()[0];
|
||||||
|
|
||||||
const newTrack = await this._micProducer.replaceTrack(track);
|
await this._micProducer.replaceTrack({ track });
|
||||||
|
|
||||||
const harkStream = new MediaStream();
|
const harkStream = new MediaStream();
|
||||||
|
|
||||||
harkStream.addTrack(newTrack);
|
harkStream.addTrack(track);
|
||||||
|
|
||||||
if (!harkStream.getAudioTracks()[0])
|
if (!harkStream.getAudioTracks()[0])
|
||||||
throw new Error('changeAudioDevice(): given stream has no audio track');
|
throw new Error('changeAudioDevice(): given stream has no audio track');
|
||||||
if (this._micProducer.hark != null) this._micProducer.hark.stop();
|
|
||||||
|
if (this._micProducer.hark != null)
|
||||||
|
this._micProducer.hark.stop();
|
||||||
|
|
||||||
this._micProducer.hark = hark(harkStream, { play: false });
|
this._micProducer.hark = hark(harkStream, { play: false });
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -855,7 +861,7 @@ export default class RoomClient
|
||||||
track.stop();
|
track.stop();
|
||||||
|
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
stateActions.setProducerTrack(this._micProducer.id, newTrack));
|
stateActions.setProducerTrack(this._micProducer.id, track));
|
||||||
|
|
||||||
store.dispatch(stateActions.setSelectedAudioDevice(deviceId));
|
store.dispatch(stateActions.setSelectedAudioDevice(deviceId));
|
||||||
|
|
||||||
|
|
@ -1885,8 +1891,10 @@ export default class RoomClient
|
||||||
const harkStream = new MediaStream();
|
const harkStream = new MediaStream();
|
||||||
|
|
||||||
harkStream.addTrack(track);
|
harkStream.addTrack(track);
|
||||||
|
|
||||||
if (!harkStream.getAudioTracks()[0])
|
if (!harkStream.getAudioTracks()[0])
|
||||||
throw new Error('enableMic(): given stream has no audio track');
|
throw new Error('enableMic(): given stream has no audio track');
|
||||||
|
|
||||||
this._micProducer.hark = hark(harkStream, { play: false });
|
this._micProducer.hark = hark(harkStream, { play: false });
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue