From a87213d827e6e7be5f91a76ec85b0f92050a80c8 Mon Sep 17 00:00:00 2001 From: Wassim Gharbi Date: Thu, 20 Jul 2017 14:51:11 -0700 Subject: [PATCH] Implemented enterFullscreen and exitFullscreen for all video players + bug fixes and iOS compatibility --- extensions/amp-3q-player/0.1/amp-3q-player.js | 16 +++- .../amp-brid-player/0.1/amp-brid-player.js | 16 +++- .../amp-dailymotion/0.1/amp-dailymotion.js | 30 +++++++- extensions/amp-ima-video/0.1/amp-ima-video.js | 18 ++++- .../0.1/amp-nexxtv-player.js | 16 +++- .../0.1/amp-ooyala-player.js | 16 +++- extensions/amp-video/0.1/amp-video.js | 76 +++++++++++-------- extensions/amp-youtube/0.1/amp-youtube.js | 23 +++++- src/dom.js | 44 ++++++++--- src/service/video-manager-impl.js | 24 ++---- src/video-interface.js | 16 ++++ 11 files changed, 227 insertions(+), 68 deletions(-) diff --git a/extensions/amp-3q-player/0.1/amp-3q-player.js b/extensions/amp-3q-player/0.1/amp-3q-player.js index 564def9fc1428..dd6dce4e07d6e 100644 --- a/extensions/amp-3q-player/0.1/amp-3q-player.js +++ b/extensions/amp-3q-player/0.1/amp-3q-player.js @@ -17,7 +17,7 @@ import {isLayoutSizeDefined} from '../../../src/layout'; import {tryParseJson} from '../../../src/json'; import {user, dev} from '../../../src/log'; -import {removeElement} from '../../../src/dom'; +import {removeElement, fullscreenEnter, fullscreenExit} from '../../../src/dom'; import { installVideoManagerForDoc, } from '../../../src/service/video-manager-impl'; @@ -215,6 +215,20 @@ class Amp3QPlayer extends AMP.BaseElement { this.sdnPostMessage_('hideControlbar'); } + /** + * @override + */ + fullscreenEnter() { + fullscreenEnter(this.iframe_); + } + + /** + * @override + */ + fullscreenExit() { + fullscreenExit(this.iframe_); + } + /** @override */ getCurrentTime() { // Not supported. diff --git a/extensions/amp-brid-player/0.1/amp-brid-player.js b/extensions/amp-brid-player/0.1/amp-brid-player.js index 91adc4584abca..dee633ea503b8 100644 --- a/extensions/amp-brid-player/0.1/amp-brid-player.js +++ b/extensions/amp-brid-player/0.1/amp-brid-player.js @@ -22,7 +22,7 @@ import { import {VideoEvents} from '../../../src/video-interface'; import {Services} from '../../../src/services'; import {assertAbsoluteHttpOrHttpsUrl} from '../../../src/url'; -import {removeElement} from '../../../src/dom'; +import {removeElement, fullscreenEnter, fullscreenExit} from '../../../src/dom'; import {getData, listen} from '../../../src/event-helper'; /** @@ -286,6 +286,20 @@ class AmpBridPlayer extends AMP.BaseElement { // Not supported. } + /** + * @override + */ + fullscreenEnter() { + fullscreenEnter(this.iframe_); + } + + /** + * @override + */ + fullscreenExit() { + fullscreenExit(this.iframe_); + } + /** @override */ getCurrentTime() { // Not supported. diff --git a/extensions/amp-dailymotion/0.1/amp-dailymotion.js b/extensions/amp-dailymotion/0.1/amp-dailymotion.js index e4a7f11502672..174646c077e22 100644 --- a/extensions/amp-dailymotion/0.1/amp-dailymotion.js +++ b/extensions/amp-dailymotion/0.1/amp-dailymotion.js @@ -28,7 +28,11 @@ import { addParamsToUrl, addParamToUrl, } from '../../../src/url'; -import {getDataParamsFromAttributes} from '../../../src/dom'; +import { + getDataParamsFromAttributes, + fullscreenEnter, + fullscreenExit, +} from '../../../src/dom'; /** * Player events reverse-engineered from the Dailymotion API @@ -337,6 +341,30 @@ class AmpDailymotion extends AMP.BaseElement { // Not supported } + /** + * @override + */ + fullscreenEnter() { + const platform = Services.platformFor(this.win); + if (platform.isSafari() || platform.isIos()) { + this.sendCommand_('fullscreen', [true]); + } else { + fullscreenEnter(this.iframe_); + } + } + + /** + * @override + */ + fullscreenExit() { + const platform = Services.platformFor(this.win); + if (platform.isSafari() || platform.isIos()) { + this.sendCommand_('fullscreen', [false]); + } else { + fullscreenExit(this.iframe_); + } + } + /** @override */ getCurrentTime() { // Not supported. diff --git a/extensions/amp-ima-video/0.1/amp-ima-video.js b/extensions/amp-ima-video/0.1/amp-ima-video.js index 67d282cbb5b5f..d8a75184272b1 100644 --- a/extensions/amp-ima-video/0.1/amp-ima-video.js +++ b/extensions/amp-ima-video/0.1/amp-ima-video.js @@ -30,7 +30,7 @@ import { listen, } from '../../../src/event-helper'; import {dict} from '../../../src/utils/object'; -import {removeElement} from '../../../src/dom'; +import {removeElement, fullscreenEnter, fullscreenExit} from '../../../src/dom'; import {user} from '../../../src/log'; import {VideoEvents} from '../../../src/video-interface'; import {Services} from '../../../src/services'; @@ -273,6 +273,22 @@ class AmpImaVideo extends AMP.BaseElement { // Not supported. } + /** + * @override + */ + fullscreenEnter() { + // TODO(@aghassemi) Make internal