-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/complete-settings-menu' of https://github.com/b…
…itmovin/bitmovin-player-ui into feature/complete-settings-menu
- Loading branch information
Showing
9 changed files
with
428 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/scss/skin-super-modern/components/_smallcenteredplaybacktogglebutton.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
@import '../variables'; | ||
|
||
.#{$prefix}-ui-smallcenteredplaybacktogglebutton { | ||
@extend %ui-button; | ||
|
||
@keyframes #{$prefix}-fade-out { | ||
from { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
|
||
to { | ||
opacity: 0; | ||
transform: scale(2); | ||
visibility: hidden; | ||
} | ||
} | ||
|
||
@keyframes #{$prefix}-fade-in { | ||
from { | ||
opacity: 0; | ||
transform: scale(2); | ||
visibility: visible; | ||
} | ||
|
||
to { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
@keyframes #{$prefix}-breathe { | ||
30% { | ||
transform: scale(1.1); | ||
} | ||
|
||
60% { | ||
transform: scale(1); | ||
} | ||
} | ||
|
||
cursor: default; | ||
height: 2.5em; | ||
outline: none; | ||
overflow: hidden; // hide overflow from scale animation | ||
width: 2.5em; | ||
|
||
.#{$prefix}-image { | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: 4em; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
&.#{$prefix}-on { | ||
.#{$prefix}-image { | ||
background-image: url('../../assets/skin-super-modern/images/pause.svg'); | ||
} | ||
} | ||
|
||
&.#{$prefix}-off { | ||
.#{$prefix}-image { | ||
background-image: url('../../assets/skin-super-modern/images/play.svg'); | ||
} | ||
} | ||
|
||
&.#{$prefix}-no-transition-animations { | ||
&.#{$prefix}-on, | ||
&.#{$prefix}-off { | ||
.#{$prefix}-image { | ||
animation: none; | ||
transition: none; | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/scss/skin-super-modern/components/_touch-control-overlay.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@import '../variables'; | ||
@import '../mixins'; | ||
|
||
.#{$prefix}-ui-touchcontrol-overlay { | ||
@extend %ui-container; | ||
@include layout-cover; | ||
|
||
align-items: center; | ||
display: flex; | ||
justify-content: center; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import {PlaybackToggleButton, PlaybackToggleButtonConfig} from './playbacktogglebutton'; | ||
import {DOM} from '../dom'; | ||
import {UIInstanceManager} from '../uimanager'; | ||
import { PlayerAPI, PlayerEventBase, WarningEvent } from 'bitmovin-player'; | ||
import { i18n } from '../localization/i18n'; | ||
|
||
export class SmallCenteredPlaybackToggleButton extends PlaybackToggleButton { | ||
|
||
constructor(config: PlaybackToggleButtonConfig = {}) { | ||
super(config); | ||
|
||
this.config = this.mergeConfig(config, { | ||
cssClass: 'ui-smallcenteredplaybacktogglebutton', | ||
text: i18n.getLocalizer('playPause'), | ||
role: 'button', | ||
}, this.config); | ||
} | ||
|
||
configure(player: PlayerAPI, uimanager: UIInstanceManager): void { | ||
// Update button state through API events | ||
super.configure(player, uimanager, false); | ||
|
||
// Set enterFullscreenOnInitialPlayback if set in the uimanager config | ||
if (typeof uimanager.getConfig().enterFullscreenOnInitialPlayback === 'boolean') { | ||
this.config.enterFullscreenOnInitialPlayback = uimanager.getConfig().enterFullscreenOnInitialPlayback; | ||
} | ||
|
||
let togglePlayback = () => { | ||
if (player.isPlaying() || this.isPlayInitiated) { | ||
player.pause('ui'); | ||
} else { | ||
player.play('ui'); | ||
} | ||
}; | ||
|
||
let firstPlay = true; | ||
|
||
this.onClick.subscribe(() => { | ||
togglePlayback(); | ||
|
||
if (firstPlay && this.config.enterFullscreenOnInitialPlayback) { | ||
player.setViewMode(player.exports.ViewMode.Fullscreen); | ||
} | ||
}); | ||
|
||
player.on(player.exports.PlayerEvent.Playing, () => { | ||
// Playback has really started, we can disable the flag to switch to normal toggle button handling | ||
firstPlay = false; | ||
}); | ||
|
||
const suppressPlayButtonTransitionAnimation = () => { | ||
// Disable the current animation | ||
this.setTransitionAnimationsEnabled(false); | ||
|
||
// Enable the transition animations for the next state change | ||
this.onToggle.subscribeOnce(() => { | ||
this.setTransitionAnimationsEnabled(true); | ||
}); | ||
}; | ||
|
||
// Hide the play button animation when the UI is loaded (it should only be animated on state changes) | ||
suppressPlayButtonTransitionAnimation(); | ||
|
||
const isAutoplayEnabled = Boolean(player.getConfig().playback?.autoplay); | ||
// We only know if an autoplay attempt is upcoming if the player is not yet ready. If the player is already ready, | ||
// the attempt might be upcoming or might have already happened, but we don't have to handle that because we can | ||
// simply rely on isPlaying and the play state events. | ||
const isAutoplayUpcoming = !player.getSource() && isAutoplayEnabled; | ||
|
||
// Hide the play button when the player is already playing or autoplay is upcoming | ||
if (player.isPlaying() || isAutoplayUpcoming) { | ||
// Hide the play button (switch to playing state) | ||
this.on(); | ||
// Disable the animation of the playing state switch | ||
suppressPlayButtonTransitionAnimation(); | ||
|
||
// Show the play button without an animation if a play attempt is blocked | ||
player.on(player.exports.PlayerEvent.Warning, (event: WarningEvent) => { | ||
if (event.code === player.exports.WarningCode.PLAYBACK_COULD_NOT_BE_STARTED) { | ||
suppressPlayButtonTransitionAnimation(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
protected toDomElement(): DOM { | ||
let buttonElement = super.toDomElement(); | ||
|
||
// Add child that contains the play button image | ||
// Setting the image directly on the button does not work together with scaling animations, because the button | ||
// can cover the whole video player are and scaling would extend it beyond. By adding an inner element, confined | ||
// to the size if the image, it can scale inside the player without overshooting. | ||
buttonElement.append(new DOM('div', { | ||
'class': this.prefixCss('image'), | ||
})); | ||
|
||
return buttonElement; | ||
} | ||
|
||
/** | ||
* Enables or disables the play state transition animations of the play button image. Can be used to suppress | ||
* animations. | ||
* @param {boolean} enabled true to enable the animations (default), false to disable them | ||
*/ | ||
protected setTransitionAnimationsEnabled(enabled: boolean): void { | ||
const noTransitionAnimationsClass = this.prefixCss('no-transition-animations'); | ||
|
||
if (enabled) { | ||
this.getDomElement().removeClass(noTransitionAnimationsClass); | ||
} else if (!this.getDomElement().hasClass(noTransitionAnimationsClass)) { | ||
this.getDomElement().addClass(noTransitionAnimationsClass); | ||
} | ||
} | ||
} |
Oops, something went wrong.