Skip to content

Commit fd79c5d

Browse files
Merge pull request #117 from THEOplayer/bugfix/fullscreen-options
Always hide navigation UI when entering fullscreen
2 parents 81e3beb + 99e7200 commit fd79c5d

4 files changed

Lines changed: 26 additions & 18 deletions

File tree

.changeset/legal-cities-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@theoplayer/web-ui': patch
3+
---
4+
5+
When entering fullscreen, the player will now always hide the browser's navigation UI. (This can be overridden by setting [`ui.fullscreenOptions.navigationUI`](https://optiview.dolby.com/docs/theoplayer/v10/api-reference/web/interfaces/FullscreenOptions.html#navigationUI) in your player configuration.)

src/DefaultUI.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as shadyCss from '@webcomponents/shadycss';
2-
import type { ChromelessPlayer, PlayerConfiguration, SourceDescription } from 'theoplayer/chromeless';
2+
import type { ChromelessPlayer, SourceDescription, UIPlayerConfiguration } from 'theoplayer/chromeless';
33
import type { UIContainer } from './UIContainer';
44
import defaultUiCss from './DefaultUI.css';
55
import defaultUiHtml from './DefaultUI.html';
@@ -38,7 +38,7 @@ const template = createTemplate('theoplayer-default-ui', `<style>${defaultUiCss}
3838
* For more extensive customizations, we recommend defining your own custom UI using
3939
* a {@link UIContainer | `<theoplayer-ui>`}.
4040
*
41-
* @attribute `configuration` - The THEOplayer {@link theoplayer!PlayerConfiguration | PlayerConfiguration}, as a JSON string.
41+
* @attribute `configuration` - The THEOplayer {@link theoplayer!UIPlayerConfiguration | UIPlayerConfiguration}, as a JSON string.
4242
* @attribute `source` - The THEOplayer {@link theoplayer!SourceDescription | SourceDescription}, as a JSON string.
4343
* @attribute `fluid` - If set, the player automatically adjusts its height to fit the video's aspect ratio.
4444
* @attribute `muted` - If set, the player starts out as muted. Reflects `ui.player.muted`.
@@ -102,7 +102,7 @@ export class DefaultUI extends HTMLElement {
102102
* the underlying THEOplayer instance.
103103
* Can also be set later on through the {@link DefaultUI.configuration} property.
104104
*/
105-
constructor(configuration: PlayerConfiguration = {}) {
105+
constructor(configuration: UIPlayerConfiguration = {}) {
106106
super();
107107
this._shadowRoot = this.initShadowRoot();
108108

@@ -154,16 +154,16 @@ export class DefaultUI extends HTMLElement {
154154
*
155155
* Used to create the underlying THEOplayer instance.
156156
*/
157-
get configuration(): PlayerConfiguration {
157+
get configuration(): UIPlayerConfiguration {
158158
return this._ui.configuration;
159159
}
160160

161-
set configuration(configuration: PlayerConfiguration) {
161+
set configuration(configuration: UIPlayerConfiguration) {
162162
this.removeAttribute(Attribute.CONFIGURATION);
163163
this.setConfiguration_(configuration);
164164
}
165165

166-
private setConfiguration_(configuration: PlayerConfiguration) {
166+
private setConfiguration_(configuration: UIPlayerConfiguration) {
167167
this._ui.configuration = {
168168
...configuration,
169169
ads: {
@@ -287,7 +287,7 @@ export class DefaultUI extends HTMLElement {
287287
if (attrName === Attribute.SOURCE) {
288288
this._ui.source = newValue ? (JSON.parse(newValue) as SourceDescription) : undefined;
289289
} else if (attrName === Attribute.CONFIGURATION) {
290-
this.setConfiguration_(newValue ? (JSON.parse(newValue) as PlayerConfiguration) : {});
290+
this.setConfiguration_(newValue ? (JSON.parse(newValue) as UIPlayerConfiguration) : {});
291291
} else if (attrName === Attribute.MUTED) {
292292
this.muted = hasValue;
293293
} else if (attrName === Attribute.AUTOPLAY) {

src/THEOliveDefaultUI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import './components/theolive/quality/BadNetworkModeButton';
22
import './components/theolive/quality/BadNetworkModeMenu';
33
import css from './THEOliveDefaultUI.css';
44
import html from './THEOliveDefaultUI.html';
5-
import type { ErrorEvent, PlayerConfiguration } from 'theoplayer/chromeless';
5+
import type { ErrorEvent, UIPlayerConfiguration } from 'theoplayer/chromeless';
66
import { DefaultUI } from './DefaultUI';
77
import { READY_EVENT } from './events/ReadyEvent';
88
import { ErrorDisplay, PlayButton } from './components';
@@ -23,7 +23,7 @@ export class THEOliveDefaultUI extends DefaultUI {
2323
private readonly _playButton: PlayButton;
2424
private readonly _root: HTMLElement;
2525

26-
constructor(configuration: PlayerConfiguration = {}) {
26+
constructor(configuration: UIPlayerConfiguration = {}) {
2727
super(configuration);
2828
this._loading = this._shadowRoot.querySelector<HTMLParagraphElement>('#loading-announcement')!;
2929
this._offline = this._shadowRoot.querySelector<HTMLParagraphElement>('#offline-announcement')!;

src/UIContainer.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as shadyCss from '@webcomponents/shadycss';
2-
import { ChromelessPlayer, type MediaTrack, type PlayerConfiguration, type SourceDescription, type VideoQuality } from 'theoplayer/chromeless';
2+
import { ChromelessPlayer, type MediaTrack, type SourceDescription, type UIPlayerConfiguration, type VideoQuality } from 'theoplayer/chromeless';
33
import elementCss from './UIContainer.css';
44
import elementHtml from './UIContainer.html';
55
import {
@@ -70,7 +70,7 @@ const FULL_WINDOW_ROOT_CLASS = 'theoplayer-ui-full-window';
7070
*
7171
* The styling can be controlled using CSS custom properties (see below).
7272
*
73-
* @attribute `configuration` - The THEOplayer {@link theoplayer!PlayerConfiguration | PlayerConfiguration}, as a JSON string.
73+
* @attribute `configuration` - The THEOplayer {@link theoplayer!UIPlayerConfiguration | UIPlayerConfiguration}, as a JSON string.
7474
* @attribute `source` - The THEOplayer {@link theoplayer!SourceDescription | SourceDescription}, as a JSON string.
7575
* @attribute `fluid` - If set, the player automatically adjusts its height to fit the video's aspect ratio.
7676
* @attribute `muted` - If set, the player starts out as muted. Reflects `ui.player.muted`.
@@ -143,7 +143,7 @@ export class UIContainer extends HTMLElement {
143143
];
144144
}
145145

146-
private _configuration: PlayerConfiguration = {};
146+
private _configuration: UIPlayerConfiguration = {};
147147
private readonly _playerEl: HTMLElement;
148148
private readonly _menuEl: HTMLElement;
149149
private readonly _menuGroup: MenuGroup;
@@ -172,7 +172,7 @@ export class UIContainer extends HTMLElement {
172172
* the underlying THEOplayer instance.
173173
* Can also be set later on through the {@link UIContainer.configuration} property.
174174
*/
175-
constructor(configuration: PlayerConfiguration = {}) {
175+
constructor(configuration: UIPlayerConfiguration = {}) {
176176
super();
177177
const shadowRoot = this.attachShadow({ mode: 'open', delegatesFocus: true });
178178
shadowRoot.appendChild(template().content.cloneNode(true));
@@ -235,16 +235,16 @@ export class UIContainer extends HTMLElement {
235235
*
236236
* Used to create the underlying THEOplayer instance.
237237
*/
238-
get configuration(): PlayerConfiguration {
238+
get configuration(): UIPlayerConfiguration {
239239
return this._configuration;
240240
}
241241

242-
set configuration(playerConfiguration: PlayerConfiguration) {
242+
set configuration(playerConfiguration: UIPlayerConfiguration) {
243243
this.removeAttribute(Attribute.CONFIGURATION);
244244
this._setConfiguration(playerConfiguration);
245245
}
246246

247-
private _setConfiguration(playerConfiguration: PlayerConfiguration): void {
247+
private _setConfiguration(playerConfiguration: UIPlayerConfiguration): void {
248248
this._configuration = playerConfiguration ?? {};
249249
this.tryInitializePlayer_();
250250
}
@@ -491,7 +491,7 @@ export class UIContainer extends HTMLElement {
491491
}
492492
const hasValue = newValue != null;
493493
if (attrName === Attribute.CONFIGURATION) {
494-
this._setConfiguration(newValue ? (JSON.parse(newValue) as PlayerConfiguration) : {});
494+
this._setConfiguration(newValue ? (JSON.parse(newValue) as UIPlayerConfiguration) : {});
495495
} else if (attrName === Attribute.SOURCE) {
496496
this._setSource(newValue ? (JSON.parse(newValue) as SourceDescription) : undefined);
497497
} else if (attrName === Attribute.MUTED) {
@@ -726,7 +726,10 @@ export class UIContainer extends HTMLElement {
726726
const event = rawEvent as EnterFullscreenEvent;
727727
event.stopPropagation();
728728
if (fullscreenAPI && document[fullscreenAPI.fullscreenEnabled_] && this[fullscreenAPI.requestFullscreen_]) {
729-
const promise = this[fullscreenAPI.requestFullscreen_]();
729+
const promise = this[fullscreenAPI.requestFullscreen_]({
730+
navigationUI: 'hide',
731+
...this._configuration?.ui?.fullscreenOptions
732+
});
730733
if (promise && promise.then) {
731734
promise.then(noOp, noOp);
732735
}

0 commit comments

Comments
 (0)