Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy ios webkit events into fullscreenchange #3644

Merged
merged 5 commits into from Sep 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 33 additions & 10 deletions src/js/tech/html5.js
Expand Up @@ -120,6 +120,10 @@ class Html5 extends Tech {
this.setControls(true);
}

// on iOS, we want to proxy `webkitbeginfullscreen` and `webkitendfullscreen`
// into a `fullscreenchange` event
this.proxyWebkitFullscreen_();

this.triggerReady();
}

Expand Down Expand Up @@ -574,6 +578,35 @@ class Html5 extends Tech {
return this.el_.offsetHeight;
}

/**
* Proxy iOS `webkitbeginfullscreen` and `webkitendfullscreen` into
* `fullscreenchange` event
*
* @private
* @method proxyWebkitFullscreen_
*/
proxyWebkitFullscreen_() {
if (!('webkitDisplayingFullscreen' in this.el_)) {
return;
}

const endFn = function() {
this.trigger('fullscreenchange', { isFullscreen: false });
};

const beginFn = function() {
this.one('webkitendfullscreen', endFn);

this.trigger('fullscreenchange', { isFullscreen: true });
};

this.on('webkitbeginfullscreen', beginFn);
this.on('dispose', () => {
this.off('webkitbeginfullscreen', beginFn);
this.off('webkitendfullscreen', endFn);
});
}

/**
* Get if there is fullscreen support
*
Expand All @@ -600,16 +633,6 @@ class Html5 extends Tech {
enterFullScreen() {
const video = this.el_;

if ('webkitDisplayingFullscreen' in video) {
this.one('webkitbeginfullscreen', function() {
this.one('webkitendfullscreen', function() {
this.trigger('fullscreenchange', { isFullscreen: false });
});

this.trigger('fullscreenchange', { isFullscreen: true });
});
}

if (video.paused && video.networkState <= video.HAVE_METADATA) {
// attempt to prime the video element for programmatic access
// this isn't necessary on the desktop but shouldn't hurt
Expand Down