Today the most of web browsers require audio to be muted when starting a stream playback automatically. A user action is required to unmute audio: to click a button, to move a volume slider etc. So developer needs to know a video tag state where a stream playback is started: is audio muted or not.
Therefore, since WebSDK build 2.0.241 the stream event type STREAM_EVENT_TYPE.UNMUTE_REQUIRED
is added. When the event is received, Unmute
button may be displayed that user must click, for example
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function (stream) { ... }).on(STREAM_EVENT, function(streamEvent){ if (STREAM_EVENT_TYPE.NOT_ENOUGH_BANDWIDTH === streamEvent.type) { ... } else if (STREAM_EVENT_TYPE.RESIZE === streamEvent.type) { ... } else if (STREAM_EVENT_TYPE.UNMUTE_REQUIRED === streamEvent.type) { console.log("Stream is muted by autoplay policy, user action required to unmute"); $("#unmute").show(); } }); stream.play();
Unmute
button handler example
function setStreamVolume(stream, currentVolumeValue) { if (stream) { if (stream.isRemoteAudioMuted()) { stream.unmuteRemoteAudio(); } stream.setVolume(currentVolumeValue); } }