Skip to content

Instantly share code, notes, and snippets.

@larchanka
Last active March 13, 2017 14:25
Show Gist options
  • Save larchanka/e5c0374c9dcdaa87c97b to your computer and use it in GitHub Desktop.
Save larchanka/e5c0374c9dcdaa87c97b 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