Skip to content

Instantly share code, notes, and snippets.

@thehunmonkgroup
Last active September 4, 2018 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehunmonkgroup/1e687259167e3a48a55cd0f3260deb70 to your computer and use it in GitHub Desktop.
Save thehunmonkgroup/1e687259167e3a48a55cd0f3260deb70 to your computer and use it in GitHub Desktop.
/**
* 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
Copy link

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