Airplay with Custom html5 controls - html

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();
});
});
}

Sadly Apple hasn't implemented Airplay JavaScript event calls, this is mostly because when you use AirPlay in your native quicktime controls AirPlay prompts the user with near by AirPlay devices. Currently there isn't a Safari specific JS implementation to pull this data in your content and create buttons based on what's available.
As of Feb 2013, the only thing you can specify for AirPlay in HTML5 is if you wish to show or not show AirPlay controls.
https://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/AirPlayGuide/OptingInorOutofAirPlay/OptingInorOutofAirPlay.html
You can file a bug with Apple if this is a feature you would like in future releases:
https://bugreport.apple.com/
Hope this helps.

We can check webkitcurrentplaybacktargetiswirelesschanged event to catch switch off airplay device:
this.on(videoEl, 'webkitcurrentplaybacktargetiswirelesschanged', this.checkWireles);

Related

How to disable AirPlay button in Safari?

I'm trying to remove airplay button from native Safari video player on iOS and Mac and I was not able to find a working solution.
It seems imposible to disable it even though documentation says otherwise
I use an .m3u8 source for the video (an online stream from Wowza).
Safari ver. 12.1.1 on Mac, iOS 12.1
I have added x-webkit-wirelessvideoplaybackdisabled, x-webkit-airplay="deny" attributes.
https://developer.apple.com/library/archive/releasenotes/General/WhatsNewInSafari/Articles/Safari_7_0.html#//apple_ref/doc/uid/TP40014305-CH5-SW6
I also set disableRemotePlayback on video element object to true but the airPlay button is still present.
https://www.w3.org/TR/remote-playback/#dom-htmlmediaelement-disableremoteplayback
...
const $video = $(`<video style="width: 100%; height: 100%" class="ios-video" controls autoplay muted playsinline x-webkit-airplay="deny" x-webkit-wirelessvideoplaybackdisabled>`);
$video[0].disableRemotePlayback = true;
$video[0].src = stream;
$(self.playerSelector).append($video);
...
I expect that there would be no AirPlay button, but unfortunately even so the webkitWirelessVideoPlaybackDisabled attribute on video element in js is set to true an AirPlay button is still present.
Opting Into or Out of AirPlay
Video playing in your app or from your website can be enabled for AirPlay or not, at your discretion.
In apps compiled with the base SDK set to iOS 5.0 and later, AirPlay is enabled by default; if you do not want iOS-based devices to be able to play your video over Apple TV, you must disable AirPlay explicitly.
To explicitly opt out of AirPlay, set x-webkit-airplay attribute for the video tag or the airplay attribute for the embed tag to "deny", as shown in Listing 2-2.
x-webkit-airplay="deny"
I know you said you did that in your question, but that is the solution according to Apple.

Cordova, HTML5 Video not responding to touch inputs

Update:
I did a fully build via Android studios, and the HTML5 Video does not work at all. It may be related to it targeting a web site? Though I can have the app open a website from the app directly, so maybe something else I am missing. I also tried with the video in the app directory, but again, it did not seem to load at all.
I am building a Cordova/Framework7 app that I need to embed videos into.
The video loads, and I can scroll back and forth through the video, but the giant PLAY button does not respond when touching it in app.
<video id='video' controls>
<source src="https://website.com/FancyVideo.mp4" type="video/mp4">
Your browser does not support HTML5 video
</video>
I've tried to make an event listener to trigger the video (with and without the onload bi)
window.onload = function() {
var video = document.getElementById('video');
video.addEventListener('click', function () {
video.play();
}, false);
}
So I am not sure what to do, it should work.
I have followed several other question threads but none seem to work, or are mostly obsolete. I have also tried media plugins with similar results.
HTML5 element on Android
html5 videos not showing controls on android once loaded
Note:
I am using
PhoneGap desktop application, and a Galaxy S7 running Android 8.0.0
Cordova Android Version 7.1.0
Cordova Version 8.0.0
Framework 7 Version 3.0.1
PhoneGap Version 8.0.0

Audio tag without a volume slider or mute button?

I created an audio tag without a download button with
<audio controls controlslist="nodownload">
This was successful.
Now, how do I remove the volume slider (plus mute button) that comes up when I play the sound?
I tried
<audio controls controlslist="novolume">
without any luck.
Try this:
audio::-webkit-media-controls-mute-button {
display: none !important;
}
audio::-webkit-media-controls-volume-slider {
display: none !important;
}
The new controlslist attribute in the HTML5 standard can only accept three settings:
"nodownload", "nofullscreen" and "noremoteplayback".
There are none to control specific controls beside from that. The only (current) workaround for this is to build your own custom interface for the audio object and provide only the controls you want the user to access via the UI.
The attribute is currently only supported in Chrome and Opera, as well as Android. This of course being another incentive to build a custom UI for the audio (or use a library as suggested by Johannes).
For the HTML5 audio tag there is only controls or nothing, and each browser will display it a little differently. But there is not way to have only some of the controls displayed.
To achieve that, you'd have to use a javascript/jQuery player like jPlayer ( http://jplayer.org/) that allows complete individual cofiguration of the UI (but still uses HTML5 in the background).

HTML5 Video autoplay Not working in iPhone and Android?

I created a website for preview of HTML5 video autoplay, but it is not working on iPhone and Android 4+. Can anyone please let me know how can i make it work?
As of iOS 6.1, it is no longer possible to auto-play videos on the iPad.
My assumption as to why they've disabled the auto-play feature?
Well, as many device owners have data usage/bandwidth limits on their devices, I think Apple felt that the user themselves should decide when they initiate bandwidth usage.
After a bit of research I found the following extract in the Apple documentation in regard to auto-play on iOS devices to confirm my assumption:
"Apple has made the decision to disable the automatic playing of video on iOS devices, through both script and attribute implementations.
In Safari, on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and auto-play are disabled. No data is loaded until the user initiates it." - Apple documentation.
Here is a separate warning featured on the Safari HTML5 Reference page about why embedded media cannot be played in Safari on iOS:
Warning: To prevent unsolicited downloads over cellular networks at the user’s expense, embedded media cannot be played automatically in Safari on iOS—the user always initiates playback. A controller is automatically supplied on iPhone or iPod touch once playback in initiated, but for iPad you must either set the controls attribute or provide a controller using JavaScript.
What this means (in terms of code) is that Javascript's play() and load() methods are inactive until the user initiates playback, unless the play() or load() method is triggered by user action (e.g. a click event).
Basically, a user-initiated play button works, but an onLoad="play()" event does not.
For example, this would play the movie:
<input type="button" value="Play" onclick="document.myMovie.play()">
Whereas the following would do nothing on iOS:
<body onload="document.myMovie.play()">
Source taken from :
Can you autoplay HTML5 videos on the iPad?
but as for android,
here you go
http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/

Android webkit html video gioto fullscreen event

There's a problem: android webkit draws video-element and I want to catch transition to the fullscreen when I press on the fullscreen-button that situates on the bottom to the right of video element. I can't do that. There's no such event as 'fullscreen' or smth else like this. Can you help me? For catching events I use JavaScript codes.
Thx in advance.
I assume you use Android 3.1+ for testing?
http://developer.android.com/sdk/android-3.1.html
Previous versions did not support inline video. If you want to catch the event you will have to disable default controls and implement your own as there is no "enterFullscreen" event for the native controls (neither is there one for you own controls but you could start whatever you want upon clicking your own FS button) - again, this wont work on version 3.0 or earlier. AND you won't have native fullscreen afterwards. Android's implementation of html5 video is rather poor.
I did not yet test Android 4.0 on that matter, meaning it could be better there.