Does anyone know if there is a way to get Airplay to work on an html5 video that is using CUSTOM CONTROLS? That is the important part, I realize that you can just add the x-webkit-airplay="allow" attribute to the element if you are using the built in html5 controls. But my video player uses custom built controls.
It appears that Safari will put the Airplay button on the built in html5 controls, but is there a way to do it if I'm not using the built in controls? Here is a link to the html5 player I've written. Notice that the controls at the bottom are my own:
http://pluralsight.com/training/Player?author=keith-brown&name=aspdotnet-security&mode=live&clip=0&course=aspdotnet-security
Thanks!
Good news here! The feature has been implemented in Safari 9.
Safari 9.0 allows you to create custom controls for HTML5 media with JavaScript AirPlay support. Use Safari's
WebKitPlaybackTargetAvailabilityEvent
to detect Airplay availability and then add your own controls for streaming audio and video to AirPlay devices.
Via. What's New in Safari 9
Here's an example from HTML5 video и кнопка для AirPlay
// Detect if AirPlay is available
// Mac OS Safari 9+ only
if (window.WebKitPlaybackTargetAvailabilityEvent) {
video.addEventListener('webkitplaybacktargetavailabilitychanged', function(event) {
switch (event.availability) {
case "available":
AirPlayButton.show();
break;
default:
AirPlayButton.hide();
}
AirPlayButton.on('click', function() {
video.webkitShowPlaybackTargetPicker();
});
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With