Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Illustrates methods for testing for the existence of support
* for setting a speaker device.
*/
// Check for the setSinkId() method on HTMLMediaElement.
if (setSinkId in HTMLMediaElement.prototype) {
// Do the work.
}
// ...or...
// Check for the sinkId property on an HTMLMediaElement instance.
if (typeof element.sinkId !== 'undefined') {
// Do the work.
}
@fippo

This comment has been minimized.

fippo commented Sep 4, 2018

if ('setSinkId' in HTMLMediaElement.prototype) (missing quotes) is the better check in terms of semantics as it checks for general support)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment