// Set the audio session type for music playback
navigator.audioSession.type = "playback";
// Play music
audioElement.play();AudioSession: type property / notebook
AudioSession: type property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
// Set up for video conferencing (both playback and recording)
navigator.audioSession.type = "play-and-record";
// Start video call
const stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true,
});
localVideo.srcObject = stream;// Set transient type for a notification sound
navigator.audioSession.type = "transient";
// Play notification
notificationSound.play();