Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Add support for iPad #22

Closed
wants to merge 1 commit into from
Closed

Add support for iPad #22

wants to merge 1 commit into from

Conversation

einarlove
Copy link

Is there a reason why iPad was not supported in the library? Videos are playing fine on my iPad.

Is there a reason why iPad was not supported in the library? Videos are playing fine on my iPad.
@fregante
Copy link
Owner

iPad plays video inline autonomously, you don't need this library. Are you using it for autoplay?

@einarlove
Copy link
Author

einarlove commented Apr 19, 2016

Yes, I'm using it for playing videos without user interaction. I've made a video carousel which changes to next video when the last one ends.
I've made a fork that I use, but if you do not want to open it for iPads, there could be an option instead which overrides the userAgent test.

@einarlove
Copy link
Author

If you know of a solution to using the native iPad player and make it possible to play/pause with javascript, please let me know.

@fregante
Copy link
Owner

fregante commented Apr 19, 2016

If you don't need audio, use this:

if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
    makeVideoPlayableInline(video, /*hasAudio*/ false, false /*this will will skip the integrated device test*/);
}

Edit: as an heads-up, the API will be changed to something like this in v2 (whenever that comes):

if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
    enableInlineVideo(video, {
        mute: true,
        enabled: 'always'
    });
}

@einarlove
Copy link
Author

Was not aware of the onlyWhenNeeded option. It solves my problem, thanks!

@einarlove einarlove closed this Apr 20, 2016
@einarlove einarlove deleted the patch-1 branch April 20, 2016 09:35
@fregante fregante mentioned this pull request May 19, 2016
@barm
Copy link

barm commented Oct 21, 2016

if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
    makeVideoPlayableInline(video, /*hasAudio*/ false, false /*this will will skip the integrated device test*/);
}

Won't think unnecessarily take over playback in cases where autoplay and inline are natively supported (i.e. iOS 10)?

I ended up writing a check around the makeVideoPlayableInline:

const supportsInlineVideo = matchMedia('(-webkit-video-playable-inline)').matches;
if (/iPhone|iPad|iPod/i.test(navigator.userAgent) && !supportsInlineVideo) {
  makeVideoPlayableInline(video, false, false);
}

Seems like some of the confusion comes from people (myself included) wanting to play inline, but also enable autoplay in browsers that don't natively support it, and the API is primarily focused on the playable inline use-case.

@fregante
Copy link
Owner

Good point! Thanks for the snippet :)

@fregante
Copy link
Owner

In the v2 beta I simplified the usage on iPad. Can you try it and let me know how it goes?

@fregante
Copy link
Owner

fregante commented Feb 5, 2017

v2.0.0 has been published :)

Now you can use the iPad option:

enableInlineVideo(video, {
    iPad: true
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants