HTMLMediaElement.setSinkId()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
この記事を English (US) で読むこともできます。

 

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The HTMLMediaElement.setSinkId() method sets the ID of the audio device to use for output and returns a Promise. This only works when the application is authorized to use the specified device.

Syntax

HTMLMediaElement.setSinkId(sinkId).then(function() { ... })

Returns

A Promise that resolves to undefined.

Parameters

sinkId
The MediaDeviceInfo.deviceId of the audio output device.

Exceptions

Exception Explanation
DOMException No permission to use the requested device

Examples

const devices = await navigator.mediaDevices.enumerateDevices();
const audioDevices = devices.filter(device => device.kind === 'audiooutput');
const audio = document.createElement('audio');
await audio.setSinkId(audioDevices[0].deviceId);
console.log('Audio is being played on ' + audio.sinkId);

Specifications

Specification Status Comment
Audio Output Devices API
The definition of 'sinkId' in that specification.
Candidate Recommendation Initial definition. Older versions of this spec were called "Media Capture Output".

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
setSinkIdChrome Full support 49Edge Full support 17Firefox Full support 64
Disabled
Full support 64
Disabled
Disabled From version 64: this feature is behind the media.setsinkid.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 36Safari ? WebView Android Full support 49Chrome Android Full support 49Edge Mobile No support NoFirefox Android Full support 64
Disabled
Full support 64
Disabled
Disabled From version 64: this feature is behind the media.setsinkid.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android Full support 36Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
User must explicitly enable this feature.
User must explicitly enable this feature.

ドキュメントのタグと貢献者

このページの貢献者: mdnwebdocs-bot, chrisdavidmills, fscholz, jpmedley, Jedipedia, rolfedh
最終更新者: mdnwebdocs-bot,