Skip to content

Instantly share code, notes, and snippets.

@tonycoco
Last active April 22, 2021 16:58
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 tonycoco/72087d874b620fa06a25d7acb3732a03 to your computer and use it in GitHub Desktop.
Save tonycoco/72087d874b620fa06a25d7acb3732a03 to your computer and use it in GitHub Desktop.
Safari Bookmarklet for <video> AirPlay options – Copy the `bookmarket.js` snippet and paste it as the address of a bookmark in Safari. Then, while playing any <video> you can click the bookmarklet and the <video> will bring up your AirPlay options.
javascript:if(window.WebKitPlaybackTargetAvailabilityEvent){var videos=document.getElementsByTagName("video");if(videos.length>0)for(var airplayable=videos[0],i=0;i<videos.length;i++)if(!(airplayable=videos[i]).paused){airplayable.webkitShowPlaybackTargetPicker();break}}
if (window.WebKitPlaybackTargetAvailabilityEvent) {
var videos = document.getElementsByTagName("video");
if (videos.length > 0) {
var airplayable = videos[0];
for (var i = 0; i < videos.length; i++) {
airplayable = videos[i];
if (airplayable.paused) {
continue;
}
airplayable.webkitShowPlaybackTargetPicker();
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment