Table of Contents

Class HTMLMediaElement

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The HTMLMediaElement interface adds to HTMLElement the properties and methods needed to support basic media-related capabilities that are common to audio and video.

[Value("HTMLMediaElement")]
public class HTMLMediaElement : HTMLElement
Inheritance
HTMLMediaElement
Derived
Inherited Members

Remarks

The HTMLVideoElement and HTMLAudioElement elements both inherit this interface.

See also on MDN

Constructors

HTMLMediaElement()

public HTMLMediaElement()

Fields

HAVE_CURRENT_DATA

[Value("HAVE_CURRENT_DATA")]
public const ushort HAVE_CURRENT_DATA = 2

Field Value

ushort

HAVE_ENOUGH_DATA

[Value("HAVE_ENOUGH_DATA")]
public const ushort HAVE_ENOUGH_DATA = 4

Field Value

ushort

HAVE_FUTURE_DATA

[Value("HAVE_FUTURE_DATA")]
public const ushort HAVE_FUTURE_DATA = 3

Field Value

ushort

HAVE_METADATA

[Value("HAVE_METADATA")]
public const ushort HAVE_METADATA = 1

Field Value

ushort

HAVE_NOTHING

[Value("HAVE_NOTHING")]
public const ushort HAVE_NOTHING = 0

Field Value

ushort

NETWORK_EMPTY

[Value("NETWORK_EMPTY")]
public const ushort NETWORK_EMPTY = 0

Field Value

ushort

NETWORK_IDLE

[Value("NETWORK_IDLE")]
public const ushort NETWORK_IDLE = 1

Field Value

ushort

NETWORK_LOADING

[Value("NETWORK_LOADING")]
public const ushort NETWORK_LOADING = 2

Field Value

ushort

NETWORK_NO_SOURCE

[Value("NETWORK_NO_SOURCE")]
public const ushort NETWORK_NO_SOURCE = 3

Field Value

ushort

Properties

AudioTracks

The read-only audioTracks
property on HTMLMediaElement objects returns
an AudioTrackList object listing all of the AudioTrack
objects representing the media element's audio tracks.

[Value("audioTracks")]
public AudioTrackList AudioTracks { get; }

Property Value

AudioTrackList

An AudioTrackList object representing the list of audio tracks included
in the media element. The list of tracks can be accessed using array notation, or using
the object's GetTrackById(string) method.Each track is represented by an AudioTrack object which provides
information about the track.

Remarks

The media element may be
either an audio element or a video element.

The returned list is live; that is, as tracks are added to and removed from
the media element, the list's contents change dynamically. Once you have a reference to
the list, you can monitor it for changes to detect when new audio tracks are added or
existing ones removed. See AudioTrackList events
to learn more about watching for changes to a media element's track list.

-HTMLMediaElement: Interface used to define the HTMLMediaElement.audioTracks property
-audio, video
-AudioTrack, AudioTrackList

See also on MDN

Autoplay

The HTMLMediaElement.autoplay
property reflects the autoplay HTML attribute, indicating
whether playback should automatically begin as soon as enough media is available to do
so without interruption.

[Value("autoplay")]
public bool Autoplay { get; set; }

Property Value

bool

A boolean value which is true if the media element will
begin playback as soon as enough content has loaded to allow it to do so without
interruption.

NOTE
Some browsers offer users the ability to override
autoplay in order to prevent disruptive audio or video from playing
without permission or in the background. Do not rely on autoplay actually
starting playback and instead use Play()
event.

Remarks

A media element whose source is a MediaStream and whose
autoplay property is true will begin playback when it becomes
active (that is, when Active becomes true).

NOTE

Sites which automatically play audio (or videos with an audio
track) can be an unpleasant experience for users, so it should be avoided when
possible. If you must offer autoplay functionality, you should make it opt-in
(requiring a user to specifically enable it). However, autoplay can be useful when
creating media elements whose source will be set at a later time, under user control.

For a much more in-depth look at autoplay, autoplay blocking, and how to respond when
autoplay is blocked by the user's browser, see our article Autoplay guide for media and Web Audio APIs.

-HTMLMediaElement: Interface used to define the HTMLMediaElement.autoplay property
-audio, video

See also on MDN

Buffered

The buffered read-only property of HTMLMediaElement objects returns a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent has buffered at the moment the buffered property is accessed.

[Value("buffered")]
public TimeRanges Buffered { get; }

Property Value

TimeRanges

A new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent has buffered at the moment the buffered property is accessed.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.buffered property

See also on MDN

Controls

The HTMLMediaElement.controls property reflects the
controls HTML attribute, which controls whether user
interface controls for playing the media item will be displayed.

[Value("controls")]
public bool Controls { get; set; }

Property Value

bool

A boolean value. A value of true means controls will be
displayed.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.controls property

See also on MDN

CrossOrigin

The HTMLMediaElement.crossOrigin property is the CORS setting for this media element. See CORS settings attributes for details.

[Value("crossOrigin")]
public string? CrossOrigin { get; set; }

Property Value

string

A string of a keyword specifying the CORS mode to use when fetching the resource. Possible values are:If the crossOrigin property is specified with any other value, it is the same as specifying as the anonymous.If the crossOrigin property is not specified, the resource is fetched without CORS (the no-cors {{domxref("Request.mode", "mode", "", "nocode")}} and the same-origin {{domxref("Request.credentials", "credentials", "", "nocode")}} mode).

Remarks

CurrentSrc

The HTMLMediaElement.currentSrc property contains the
absolute URL of the chosen media resource. This could happen, for example, if the web
server selects a media file based on the resolution of the user's display. The value
is an empty string if the networkState property is EMPTY.

[Value("currentSrc")]
public string CurrentSrc { get; }

Property Value

string

A string containing the absolute URL of the chosen media
source; this may be an empty string if networkState is EMPTY;
otherwise, it will be one of the resources listed by the
HTMLSourceElement contained within the media element, or the value or src
if no source element is provided.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.currentSrc property

See also on MDN

CurrentTime

The HTMLMediaElement interface's
currentTime property specifies the current playback time
in seconds.

[Value("currentTime")]
public Number CurrentTime { get; set; }

Property Value

Number

A double-precision floating-point value indicating the current playback time in
seconds.If the media is not yet playing, the value of currentTime indicates the
time position within the media at which playback will begin once the
Play() method is called.Setting currentTime to a new value seeks the media to the given time, if
the media is available.For media without a known duration—such as media being streamed live—it's possible that
the browser may not be able to obtain parts of the media that have expired from the
media buffer. Also, media whose timeline doesn't begin at 0 seconds cannot be seeked to
a time before its timeline's earliest time.The length of the media in seconds can be determined using the
Duration property.

Remarks

Changing the value of currentTime seeks the media to
the new time.

-HTMLMediaElement: Interface used to define the HTMLMediaElement.currentTime property
-FastSeek(Number): Another way to set the time
-Duration: The duration of the media in seconds

See also on MDN

DefaultMuted

The HTMLMediaElement.defaultMuted property reflects the muted HTML attribute, which indicates whether the media element's audio output should be muted by default. This property has no dynamic effect. To mute and unmute the audio output, use the Muted property.

[Value("defaultMuted")]
public bool DefaultMuted { get; set; }

Property Value

bool

A boolean value. A value of true means that the audio output will be muted by default.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.defaultMuted property
-Muted
-Volume

See also on MDN

DefaultPlaybackRate

The HTMLMediaElement.defaultPlaybackRate property indicates the default playback rate for the media.

[Value("defaultPlaybackRate")]
public Number DefaultPlaybackRate { get; set; }

Property Value

Number

A double. 1.0 is "normal speed," values lower than 1.0 make the media play slower than normal, higher values make it play faster.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.defaultPlaybackRate property

See also on MDN

DisableRemotePlayback

The disableRemotePlayback property of the HTMLMediaElement interface determines whether the media element is allowed to have a remote playback UI.

[Value("disableRemotePlayback")]
public bool DisableRemotePlayback { get; set; }

Property Value

bool

A boolean value indicating whether the media element may have a remote playback
UI. (false means "not disabled", which means "enabled")

Remarks

Duration

The read-only HTMLMediaElement
property duration indicates the length of the element's
media in seconds.

[Value("duration")]
public double Duration { get; }

Property Value

double

A double-precision floating-point value indicating the duration of the media in
seconds. If no media data is available, the value NaN is returned. If the
element's media doesn't have a known duration—such as for live media streams—the value
of duration is Infinity.

Remarks

-Web media technologies
-CurrentTime: The current playback position of the
media
-The audio and video elements

See also on MDN

Ended

The HTMLMediaElement.ended property indicates whether the media
element has ended playback.

[Value("ended")]
public bool Ended { get; }

Property Value

bool

A boolean value which is true if the media contained in the
element has finished playing.If the source of the media is a MediaStream, this value is
true if the value of the stream's Active property is false.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.ended property
-MediaStream
-Active

See also on MDN

Error

The HTMLMediaElement.error property is the
MediaError object for the most recent error, or null if
there has not been an error. When an HTMLMediaElementerror event is received by the
element, you can determine details about what happened by examining this object.

[Value("error")]
public MediaError? Error { get; }

Property Value

MediaError

A MediaError object describing the most recent error to occur on the
media element or null if no errors have occurred.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.error property
-audio and video

See also on MDN

Loop

The HTMLMediaElement.loop property reflects the loop HTML attribute, which controls whether the media element should start over when it reaches the end.

[Value("loop")]
public bool Loop { get; set; }

Property Value

bool

A boolean value.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.loop property

See also on MDN

MediaKeys

The read-only HTMLMediaElement.mediaKeys property returns a MediaKeys object, that is a set of keys that the element can use for decryption of media data during playback.

[Value("mediaKeys")]
public MediaKeys? MediaKeys { get; }

Property Value

MediaKeys

A MediaKeys object, or null if no key is available.

Remarks

Muted

The HTMLMediaElement.muted property indicates whether the media
element is muted.

[Value("muted")]
public bool Muted { get; set; }

Property Value

bool

A boolean value. true means muted and false means
not muted.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.muted property
-DefaultMuted
-Volume

See also on MDN

NetworkState

The
HTMLMediaElement.networkState property indicates the
current state of the fetching of media over the network.

[Value("networkState")]
public ushort NetworkState { get; }

Property Value

ushort

An unsigned short. Possible values are:

ConstantValueDescription
NETWORK_EMPTY0There is no data yet. Also, readyState is HAVE_NOTHING.
NETWORK_IDLE1HTMLMediaElement is active and has selected a resource, but is not using the network.
NETWORK_LOADING2The browser is downloading HTMLMediaElement data.
NETWORK_NO_SOURCE3No HTMLMediaElement src found.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.networkState property

See also on MDN

Onencrypted

[Value("onencrypted")]
public EventHandlerNonNull Onencrypted { get; set; }

Property Value

EventHandlerNonNull

Onwaitingforkey

[Value("onwaitingforkey")]
public EventHandlerNonNull Onwaitingforkey { get; set; }

Property Value

EventHandlerNonNull

Paused

The read-only HTMLMediaElement.paused property
tells whether the media element is paused.

[Value("paused")]
public bool Paused { get; }

Property Value

bool

A boolean value. true is paused and false is not
paused.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.paused property

See also on MDN

PlaybackRate

The HTMLMediaElement.playbackRate property sets the rate at which the media is being played back. This is used to implement user controls for fast forward, slow motion, and so forth. The normal playback rate is multiplied by this value to obtain the current rate, so a value of 1.0 indicates normal speed.

[Value("playbackRate")]
public Number PlaybackRate { get; set; }

Property Value

Number

A double. 1.0 is "normal speed," values lower than 1.0 make the media play slower than normal, higher values make it play faster. (Default: 1.0)

Remarks

A negative playbackRate value indicates that the media should be played backwards, but support for this is not yet widespread. (See browser compatibility for details.)

The audio is muted when the fast forward or slow motion is outside a useful range (for example, Gecko mutes the sound outside the range 0.25 to 4.0).

The pitch of the audio is corrected by default. You can disable pitch correction using the PreservesPitch property.

-HTMLMediaElement: Interface used to define the HTMLMediaElement.playbackRate property
-Browser bug reports to support negative playbackRate in Firefox and Blink (Chrome, etc.)
-The Web Hypertext Application Technology Working Group (WHATWG) issue to require support for negative playbackRate

See also on MDN

Played

The played read-only property of the HTMLMediaElement interface indicates the time ranges the resource, an {{htmlelement("audio")}} or {{htmlelement("video")}} media file, has played. It returns a new TimeRanges object that contains the ranges of the media source that the browser has played, if any, at the time the attribute is evaluated.

[Value("played")]
public TimeRanges Played { get; }

Property Value

TimeRanges

A TimeRanges object; representing the time ranges that have been played.

Remarks

-HTMLMediaElement.Seeked event
-HTMLMediaElement.Progress event
-Seekable
-Buffered
-HTMLVideoElement
-HTMLAudioElement

See also on MDN

Preload

The preload property of the HTMLMediaElement interface is a string that provides a hint to the browser about what the author thinks will lead to the best user experience.

[Value("preload")]
public string Preload { get; set; }

Property Value

string

A string. Possible values are as follows:

Remarks

It reflects the preload attribute of the audio element and the video element.

See also on MDN

PreservesPitch

The HTMLMediaElement.preservesPitch property determines whether or not the browser should adjust the pitch of the audio to compensate for changes to the playback rate made by setting PlaybackRate.

[Value("preservesPitch")]
public bool PreservesPitch { get; set; }

Property Value

bool

A boolean value defaulting to true.

Remarks

ReadyState

The HTMLMediaElement.readyState property indicates the
readiness state of the media.

[Value("readyState")]
public ushort ReadyState { get; }

Property Value

ushort

A number which is one of the five possible state constants defined on the HTMLMediaElement interface:

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.readyState property

See also on MDN

Remote

The remote read-only property of the HTMLMediaElement interface returns the RemotePlayback object associated with the media element. The RemotePlayback object allow the control of remote devices playing the media.

[Value("remote")]
public RemotePlayback Remote { get; }

Property Value

RemotePlayback

A RemotePlayback object associated with the media element.

Remarks

Seekable

The seekable read-only property of HTMLMediaElement objects returns a new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent is able to seek to at the time seekable property is accessed.

[Value("seekable")]
public TimeRanges Seekable { get; }

Property Value

TimeRanges

A new static normalized TimeRanges object that represents the ranges of the media resource, if any, that the user agent is able to seek to at the time seekable property is accessed.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.seekable property
-Media Source API
-Media buffering, seeking, and time ranges

See also on MDN

Seeking

The seeking read-only property of the HTMLMediaElement interface is a Boolean indicating whether the resource, the {{htmlelement("audio")}} or {{htmlelement("video")}}, is in the process of seeking to a new position.

[Value("seeking")]
public bool Seeking { get; }

Property Value

bool

A boolean value.

Remarks

-Seeking event
-HTMLMediaElement.Seeked event
-HTMLVideoElement
-HTMLAudioElement

See also on MDN

SinkId

The sinkId read-only property of the HTMLMediaElement interface returns a string that is the unique ID of the device to be used for playing audio output.

[Value("sinkId")]
public string SinkId { get; }

Property Value

string

A string indicating the current audio output device, or the empty string if the default user agent output device is being used.

Remarks

This ID should be one of the DeviceId values returned from EnumerateDevices().
If the user agent default device is being used, it returns an empty string.

-Audio Output Devices API
-SelectAudioOutput(AudioOutputOptions)
-SetSinkId(string)

See also on MDN

Src

The HTMLMediaElement.src property reflects the value of
the HTML media element's src attribute, which indicates the URL of a media
resource to use in the element.

[Value("src")]
public string Src { get; set; }

Property Value

string

A string containing the URL of a media resource to use in the
element; this property reflects the value of the HTML element's src
attribute.

Remarks

NOTE

The best way to know the URL of the media resource currently
in active use in this element is to look at the value of the
CurrentSrc attribute, which also takes
into account selection of a best or preferred media resource from a list provided in
an HTMLSourceElement (which represents a {{HTMLElement("source")}}
element).

-HTMLMediaElement: Interface used to define the HTMLMediaElement.src property

See also on MDN

SrcObject

The srcObject property of the
HTMLMediaElement interface sets or returns the object which serves as
the source of the media associated with the HTMLMediaElement, or null if not assigned.

[Value("srcObject")]
public Union63? SrcObject { get; set; }

Property Value

Union63?

A 'MediaStream', 'MediaSource', 'Blob', or
'File' object (though see the compatibility table for what is actually
supported), or null if not assigned.

Remarks

The object can be a MediaStream, a MediaSource, a
Blob, or a File (which inherits from Blob).

NOTE

As of March 2020, only Safari has full support for srcObject, i.e., using MediaSource, MediaStream, Blob, and File objects as values. Other browsers support MediaStream objects; until they catch up, consider falling back to creating a URL with CreateObjectURL(Union46) and assigning it to Src (see below for an example). In addition, as of version 108 Chromium supports attaching a dedicated worker MediaSource object by assigning that object's MediaSourceHandle instance (transferred from the worker) to srcObject.

See also on MDN

TextTracks

The read-only textTracks
property on HTMLMediaElement objects returns a
TextTrackList object listing all of the TextTrack
objects representing the media element's text tracks, in the same order as in
the list of text tracks.

[Value("textTracks")]
public TextTrackList TextTracks { get; }

Property Value

TextTrackList

A TextTrackList object representing the list of text tracks included in the media element. The list of tracks can be accessed using textTracks[n] to get the n-th text track from the object's list of text tracks, or using the textTracks.getTrackById()
method.Each track is represented by a TextTrack object which provides
information about the track.

Remarks

You can detect when tracks are added to and removed from an
<audio> or
<video> element
using the addtrack and removetrack events. However, these
events aren't sent directly to the media element itself. Instead, they're sent to the
track list object of the HTMLMediaElement
that corresponds to the type of track that was added to the element

The returned list is live; that is, as tracks are added to and removed from
the media element, the list's contents change dynamically. Once you have a reference to
the list, you can monitor it for changes to detect when new text tracks are added or
existing ones removed.

See TextTrackList events to learn
more about watching for changes to a media element's track list.

-HTMLMediaElement: Interface used to define the HTMLMediaElement.textTracks property
-audio, video
-AudioTrack, AudioTrackList
-VideoTrack, VideoTrackList
-addtrack,
change,
removetrack: AudioTrackList events
-addtrack,
change,
removetrack: VideoTrackList events

See also on MDN

VideoTracks

The read-only videoTracks
property on HTMLMediaElement objects returns a
VideoTrackList object listing all of the VideoTrack
objects representing the media element's video tracks.

[Value("videoTracks")]
public VideoTrackList VideoTracks { get; }

Property Value

VideoTrackList

A VideoTrackList object representing the list of video tracks included
in the media element. The list of tracks can be accessed using array notation, or using
the object's GetTrackById(string) method.Each track is represented by a VideoTrack object which provides
information about the track.

Remarks

The returned list is live; that is, as tracks are added to and removed from
the media element, the list's contents change dynamically. Once you have a reference to
the list, you can monitor it for changes to detect when new video tracks are added or
existing ones removed. See VideoTrackList events
to learn more about watching for changes to a media element's track list.

-HTMLMediaElement: Interface used to define the HTMLMediaElement.videoTracks property
-video
-VideoTrack, VideoTrackList

See also on MDN

Volume

The HTMLMediaElement.volume property sets the volume at
which the media will be played.

[Value("volume")]
public Number Volume { get; set; }

Property Value

Number

A double values must fall between 0 and 1, where 0 is effectively muted and 1 is the
loudest possible value.

Remarks

-HTMLMediaElement: Interface used to define the HTMLMediaElement.volume property
-Muted

See also on MDN

Methods

AddTextTrack(TextTrackKind, string, string)

The addTextTrack() method of the HTMLMediaElement interface creates a new TextTrack object and adds it to the media element. It fires an TextTrackListaddtrack event on this media element's HTMLMediaElementtextTracks. This method can't be used on a TextTrackList interface, only an HTMLMediaElement.

[Value("addTextTrack")]
public TextTrack AddTextTrack(TextTrackKind kind, string label = null, string language = null)

Parameters

kind TextTrackKind
label string
language string

Returns

TextTrack

The newly created TextTrack object.

Remarks

CanPlayType(string)

The HTMLMediaElement method canPlayType() reports how likely it is that the current browser will be able to play media of a given MIME type.

[Value("canPlayType")]
public CanPlayTypeResult CanPlayType(string type)

Parameters

type string

Returns

CanPlayTypeResult

A string indicating how likely it is that the media can be played.
The string will be one of the following values:

Remarks

CaptureStream()

The captureStream() method of the HTMLMediaElement interface returns a 'MediaStream' object which is streaming a real-time capture of the content being rendered in the media element.

[Value("captureStream")]
public MediaStream CaptureStream()

Returns

MediaStream

A 'MediaStream' object which can be used as a source for audio and/or
video data by other media processing code, or as a source for WebRTC.

Remarks

FastSeek(Number)

The HTMLMediaElement.fastSeek() method quickly seeks the
media to the new time with precision tradeoff.

[Value("fastSeek")]
public GlobalObject.Undefined FastSeek(Number time)

Parameters

time Number

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

NOTE

If you need to seek with precision, you should set HTMLMediaElement.currentTime
instead.

-HTMLMediaElement.currentTime
for seeking without precision tradeoff

See also on MDN

GetStartDate()

[Value("getStartDate")]
public Object GetStartDate()

Returns

Object

Load()

The HTMLMediaElement method
load() resets the media element to its initial state and
begins the process of selecting a media source and loading the media in preparation
for playback to begin at the beginning.

[Value("load")]
public GlobalObject.Undefined Load()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The amount of media data that is
prefetched is determined by the value of the element's preload attribute.

This method is generally only useful when you've made dynamic changes to the set of
sources available for the media element, either by changing the element's
src attribute or by adding or removing
source elements nested within the media element itself.
load() will reset the element and rescan the available sources, thereby
causing the changes to take effect.

See also on MDN

Pause()

The HTMLMediaElement.pause() method will pause playback
of the media, if the media is already in a paused state this method will have no effect.

[Value("pause")]
public GlobalObject.Undefined Pause()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Play()

The HTMLMediaElement
play() method attempts to begin playback of the media.
It returns a Promise which is resolved when playback has been
successfully started.

[Value("play")]
public Task<GlobalObject.Undefined> Play()

Returns

Task<GlobalObject.Undefined>

A Promise which is resolved when playback has been started, or is
rejected if for any reason playback cannot be started.

NOTE
Browsers released before 2019 may not return a value from
play().

Remarks

Failure to begin playback for any reason, such as
permission issues, result in the promise being rejected.

-Web media technologies
-Learning: HTML video and audio
-Autoplay guide for media and Web Audio APIs
-Using the Web Audio API

See also on MDN

SetMediaKeys(MediaKeys?)

The setMediaKeys() method of the HTMLMediaElement interface sets the MediaKeys that will be used to decrypt media during playback.

[Value("setMediaKeys")]
public Task<GlobalObject.Undefined> SetMediaKeys(MediaKeys? mediaKeys)

Parameters

mediaKeys MediaKeys

Returns

Task<GlobalObject.Undefined>

A Promise that fulfills with 'undefined'.

Remarks

It returns a Promise that fulfils if the new keys are successfully set, or rejects if keys cannot be set.

See also on MDN

SetSinkId(string)

The setSinkId() method of the HTMLMediaElement interface sets the ID of the audio device to use for output and returns a {{jsxref("Promise")}}.

[Value("setSinkId")]
public Task<GlobalObject.Undefined> SetSinkId(string sinkId)

Parameters

sinkId string

Returns

Task<GlobalObject.Undefined>

A Promise that resolves to GlobalObject.Undefined.

Remarks

This only works when the application is permitted to use the specified device.
For more information see the security requirements below.

-Audio Output Devices API
-SelectAudioOutput(AudioOutputOptions)
-SinkId

See also on MDN