Skip to content

Instantly share code, notes, and snippets.

@mrenty
Forked from larchanka/JavaScript-AirPlay-Medium-Liberty.js
Created March 13, 2017 14:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mrenty/a499ca45d47cdac1edc9025cab616b17 to your computer and use it in GitHub Desktop.
// Detect if AirPlay is available
// Mac OS Safari 9+ only
if (window.WebKitPlaybackTargetAvailabilityEvent) {
video.addEventListener('webkitplaybacktargetavailabilitychanged', function(event) {
switch (event.availability) {
case "available":
airPlay.style.display = 'block';
break;
default:
airPlay.style.display = 'none';
}
airPlay.addEventListener('click', function() {
video.webkitShowPlaybackTargetPicker();
});
});
} else {
airPlay.style.display = 'none';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment