Skip to content

Commit

Permalink
Merge branch 'feature/modern-ui-base' into feature/improve-mobile-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
stonko1994 committed Dec 20, 2024
2 parents fea5db4 + 77d2044 commit 74d33a9
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 111 deletions.
4 changes: 2 additions & 2 deletions spec/components/settingspanel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ describe('SettingsPanel', () => {
const selectBox = new SelectBox();
const closeDropdownSpy = jest.spyOn(selectBox, 'closeDropdown');

settingsPanel.getActivePage().addComponent(new SettingsPanelItem({ label: new Label(), setting: selectBox }));
settingsPanel.getActivePage().addComponent(new SettingsPanelItem({ label: new Label(), setting: new VolumeSlider() }));
settingsPanel.getActivePage().addComponent(new SettingsPanelItem({ label: new Label(), settingComponent: selectBox }));
settingsPanel.getActivePage().addComponent(new SettingsPanelItem({ label: new Label(), settingComponent: new VolumeSlider() }));

settingsPanel['hideHoveredSelectBoxes']();

Expand Down
7 changes: 6 additions & 1 deletion src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ <h4 class="card-title">
const playgroundConfig = getConfigFromStorage();

// Add UI
uiManager = bitmovin.playerui.UIFactory[playgroundConfig.uiOption || 'buildDefaultUI'](player, uiConfig);
if (playgroundConfig.uiOption != null && bitmovin.playerui.UIFactory[playgroundConfig.uiOption] != null) {
uiManager = bitmovin.playerui.UIFactory[playgroundConfig.uiOption](player, uiConfig);
} else {
localStorage.clear();
uiManager = bitmovin.playerui.UIFactory.buildDefaultUI(player, uiConfig);
}

player.load(sources[playgroundConfig.source || 'fullyFeatured']).then(function() {
console.log('source successfully loaded');
Expand Down
2 changes: 1 addition & 1 deletion src/scss/skin-super-modern/_skin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
@import 'components/spacer';
@import 'components/subtitlesettings/subtitlesettings';
@import 'components/subtitlesettingspaneltogglebutton';
@import 'components/touch-control-overlay';
@import 'components/touchcontroloverlay';
@import 'components/smallcenteredplaybacktogglebutton';
@import 'skin-ads';
@import 'skin-cast-receiver';
Expand Down
8 changes: 6 additions & 2 deletions src/scss/skin-super-modern/components/_seekbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ $seekbar-height: .3125em;
@include hidden;
@include focusable;

border-radius: 1em;
cursor: pointer;
font-size: 1em;
height: $seekbar-height;
margin: calc((1em - $seekbar-height) / 2) 0;
overflow: hidden;
position: relative;
width: 100%;

.#{$prefix}-seekbar-bars {
@extend %bar;
border-radius: 1em;
overflow: hidden;
}

.#{$prefix}-seekbar-backdrop {
@extend %bar;
background-color: transparentize($color-primary, .8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

%seek-label {
@extend %opacity-transition;
font-size: .4em;
font-weight: 600;
@include hidden-animated;
font-weight: 500;
margin: 0;
opacity: 1;
position: absolute;
text-shadow: $color-shadow-seek-label;
}

.#{$prefix}-ui-touchcontrol-overlay {
.#{$prefix}-ui-touch-control-overlay {
@extend %ui-container;
@include layout-cover;

Expand All @@ -42,20 +42,14 @@

.#{$prefix}-seek-forward-label {
@extend %seek-label;
right: 15%;

&.#{$prefix}-hidden {
opacity: 0;
}
right: 10%;
}

.#{$prefix}-seek-backward-label {
@extend %seek-label;
left: 15%;

&.#{$prefix}-hidden {
opacity: 0;
}
left: 10%;
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/ts/components/dynamicsettingspanelitem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface DynamicSettingsPanelItemConfig extends SettingsPanelItemConfig
/**
* The list selector component which will be used to build the sub page.
*/
setting: ListSelector<ListSelectorConfig>;
settingComponent: ListSelector<ListSelectorConfig>;
/**
* The enclosing {@link SettingsPanel} where the sub page will be added.
*/
Expand All @@ -40,15 +40,15 @@ export interface DynamicSettingsPanelItemConfig extends SettingsPanelItemConfig
*/
export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsPanelItemConfig> {
private selectedOptionLabel: Label<LabelConfig>;
protected setting: ListSelector<ListSelectorConfig>;
protected settingComponent: ListSelector<ListSelectorConfig>;

private player: PlayerAPI;
private uimanager: UIInstanceManager;

constructor(config: DynamicSettingsPanelItemConfig) {
super(config);

this.setting = config.setting;
this.settingComponent = config.settingComponent;

this.selectedOptionLabel = new Label({
text: '-',
Expand Down Expand Up @@ -76,26 +76,26 @@ export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsP
this.config.label.opener.configure(player, uimanager);
}

if (this.setting != null) {
this.setting.configure(this.player, this.uimanager);
if (this.settingComponent != null) {
this.settingComponent.configure(this.player, this.uimanager);
}

const handleSelectedItemChanged = () => {
let selectedItem = this.setting.getItemForKey(this.setting.getSelectedItem());
let selectedItem = this.settingComponent.getItemForKey(this.settingComponent.getSelectedItem());
if (selectedItem == null) {
this.selectedOptionLabel.hide();
return;
}

this.selectedOptionLabel.show();
let selectedOptionLabelText = selectedItem.label;
if (this.setting instanceof SubtitleSelectBox) {
let availableSettings = this.setting.getItems().length;
if (this.settingComponent instanceof SubtitleSelectBox) {
let availableSettings = this.settingComponent.getItems().length;
selectedOptionLabelText = selectedOptionLabelText + ' (' + (availableSettings - 1) + ')';
}
this.selectedOptionLabel.setText(selectedOptionLabelText);
};
this.setting.onItemSelected.subscribe(handleSelectedItemChanged);
this.settingComponent.onItemSelected.subscribe(handleSelectedItemChanged);

handleSelectedItemChanged();

Expand All @@ -109,7 +109,7 @@ export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsP
}

private buildSubPanelPage(): SettingsPanelPage {
const menuOptions = this.setting.getItems();
const menuOptions = this.settingComponent.getItems();
const page = new SettingsPanelPage({ removeOnPop: true });

const text = this.config.label instanceof SubtitleSettingsLabel ? this.config.label.text : this.config.label;
Expand All @@ -129,7 +129,7 @@ export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsP
.map((option) => {
return new SettingsPanelSelectOption({
label: option.label,
setting: this.setting,
settingComponent: this.settingComponent,
settingsValue: option.key,
addSettingAsComponent: false,
});
Expand All @@ -141,7 +141,7 @@ export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsP

page.configure(this.player, this.uimanager);

const setting = this.setting;
const setting = this.settingComponent;
if (setting instanceof SubtitleSettingSelectBox) {
// Keep the preview subtitle overlay visible when the sub-page is for a subtitle setting
page.onActive.subscribe(() => setting.overlay.enablePreviewSubtitleLabel());
Expand Down
4 changes: 2 additions & 2 deletions src/ts/components/ecomodecontainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class EcoModeContainer extends Container<ContainerConfig> {
cssClass: 'ui-label-savedEnergy',
});

this.ecoModeToggleButtonItem = new SettingsPanelItem({ label: labelEcoMode, setting: ecoModeToggleButton });
this.ecoModeToggleButtonItem = new SettingsPanelItem({ label: labelEcoMode, settingComponent: ecoModeToggleButton });
this.ecoModeSavedEmissionsItem = new SettingsPanelItem({
label: 'Saved Emissions',
setting: this.emissionsSavedLabel,
settingComponent: this.emissionsSavedLabel,
hidden: true,
});

Expand Down
46 changes: 20 additions & 26 deletions src/ts/components/seekbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ export interface SeekBarConfig extends ComponentConfig {
* Bar will be vertical instead of horizontal if set to true.
*/
vertical?: boolean;
/**
* If set to true the seekBarPlaybackPositionMarker will be rendered
* directly inside the seekbar container. Necessary when using the super-modern-ui skin
* Default: false
*/
renderSeekBarPlaybackPositionMarkerInOuterSeekBar?: boolean;
/**
* The interval in milliseconds in which the playback position on the seek bar will be updated. The shorter the
* interval, the smoother it looks and the more resource intense it is. The update interval will be kept as steady
Expand Down Expand Up @@ -171,7 +165,6 @@ export class SeekBar extends Component<SeekBarConfig> {
snappingRange: 1,
enableSeekPreview: true,
snappingEnabled: true,
renderSeekBarPlaybackPositionMarkerInOuterSeekBar: false,
}, this.config);

this.label = this.config.label;
Expand Down Expand Up @@ -249,10 +242,17 @@ export class SeekBar extends Component<SeekBarConfig> {

uimanager.onControlsShow.subscribe(() => {
this.isUiShown = true;
if (!player.isLive() && !this.smoothPlaybackPositionUpdater.isActive()) {
playbackPositionHandler(null, true);
this.smoothPlaybackPositionUpdater.start();
}
});

uimanager.onControlsHide.subscribe(() => {
this.isUiShown = false;
if (this.smoothPlaybackPositionUpdater.isActive()) {
this.smoothPlaybackPositionUpdater.clear();
}
});

let isPlaying = false;
Expand Down Expand Up @@ -294,7 +294,7 @@ export class SeekBar extends Component<SeekBarConfig> {
// Update playback position only in paused state or in the initial startup state where player is neither
// paused nor playing. Playback updates are handled in the Timeout below.
const isInInitialStartupState = this.config.smoothPlaybackPositionUpdateIntervalMs === SeekBar.SMOOTH_PLAYBACK_POSITION_UPDATE_DISABLED
|| forceUpdate || player.isPaused();
|| forceUpdate || player.isPaused();
const isNeitherPausedNorPlaying = player.isPaused() === player.isPlaying();

if ((isInInitialStartupState || isNeitherPausedNorPlaying) && !this.isSeeking()) {
Expand Down Expand Up @@ -330,12 +330,12 @@ export class SeekBar extends Component<SeekBarConfig> {
scrubbing = false;
};

let onPlayerSeeked = (event: PlayerEventBase = null, forceUpdate: boolean = false ) => {
let onPlayerSeeked = (event: PlayerEventBase = null) => {
isPlayerSeeking = false;
this.setSeeking(false);

// update playback position when a seek has finished
playbackPositionHandler(event, forceUpdate);
playbackPositionHandler(event, true);
};

let restorePlayingState = function () {
Expand Down Expand Up @@ -668,6 +668,10 @@ export class SeekBar extends Component<SeekBarConfig> {
});
this.seekBar = seekBar;

const seekBarBarsContainer = new DOM('div', {
'class': this.prefixCss('seekbar-bars'),
});

// Indicator that shows the buffer fill level
let seekBarBufferLevel = new DOM('div', {
'class': this.prefixCss('seekbar-bufferlevel'),
Expand Down Expand Up @@ -703,12 +707,10 @@ export class SeekBar extends Component<SeekBarConfig> {
});
this.seekBarMarkersContainer = seekBarChapterMarkersContainer;

seekBar.append(this.seekBarBackdrop, this.seekBarBufferPosition, this.seekBarSeekPosition,
seekBarBarsContainer.append(this.seekBarBackdrop, this.seekBarBufferPosition, this.seekBarSeekPosition,
this.seekBarPlaybackPosition, this.seekBarMarkersContainer);

if (!this.config.renderSeekBarPlaybackPositionMarkerInOuterSeekBar) {
seekBar.append(this.seekBarPlaybackPositionMarker);
}
seekBar.append(seekBarBarsContainer, this.seekBarPlaybackPositionMarker);

let seeking = false;

Expand Down Expand Up @@ -747,16 +749,12 @@ export class SeekBar extends Component<SeekBarConfig> {
this.onSeekedEvent(targetPercentage);
};

// TODO: the problem is that the SeekbarLabel is also inside the seekbarContainer and therefore reacts to the
// TODO: mouse inputs.
let domElementToListen: DOM = this.config.renderSeekBarPlaybackPositionMarkerInOuterSeekBar ? seekBarContainer : seekBar;

// A seek always start with a touchstart or mousedown directly on the seekbar.
// To track a mouse seek also outside the seekbar (for touch events this works automatically),
// so the user does not need to take care that the mouse always stays on the seekbar, we attach the mousemove
// and mouseup handlers to the whole document. A seek is triggered when the user lifts the mouse key.
// A seek mouse gesture is thus basically a click with a long time frame between down and up events.
domElementToListen.on('touchstart mousedown', (e: MouseEvent | TouchEvent) => {
seekBar.on('touchstart mousedown', (e: MouseEvent | TouchEvent) => {
let isTouchEvent = BrowserUtils.isTouchSupported && this.isTouchEvent(e);

// Prevent selection of DOM elements (also prevents mousedown if current event is touchstart)
Expand All @@ -778,7 +776,7 @@ export class SeekBar extends Component<SeekBarConfig> {
});

// Display seek target indicator when mouse hovers or finger slides over seekbar
domElementToListen.on('touchmove mousemove', (e: MouseEvent | TouchEvent) => {
seekBar.on('touchmove mousemove', (e: MouseEvent | TouchEvent) => {
e.preventDefault();

if (seeking) {
Expand All @@ -796,7 +794,7 @@ export class SeekBar extends Component<SeekBarConfig> {
});

// Hide seek target indicator when mouse or finger leaves seekbar
domElementToListen.on('touchend mouseleave', (e: MouseEvent | TouchEvent) => {
seekBar.on('touchend mouseleave', (e: MouseEvent | TouchEvent) => {
e.preventDefault();

this.setSeekPosition(0);
Expand All @@ -812,10 +810,6 @@ export class SeekBar extends Component<SeekBarConfig> {
seekBarContainer.append(this.label.getDomElement());
}

if (this.config.renderSeekBarPlaybackPositionMarkerInOuterSeekBar) {
seekBarContainer.append(seekBarPlaybackPositionMarker);
}

return seekBarContainer;
}

Expand Down Expand Up @@ -1109,7 +1103,7 @@ export class SeekBar extends Component<SeekBarConfig> {
this.refreshPlaybackPosition();
}

/**
/**
* Checks if TouchEvent is supported.
* @returns {boolean} true if TouchEvent not undefined, else false
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ts/components/settingspanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class SettingsPanel extends Container<SettingsPanelConfig> {
*/
private hideHoveredSelectBoxes(): void {
this.getComputedItems()
.map(item => item['setting'])
.map(item => item['settingComponent'])
.filter(component => component instanceof SelectBox)
.forEach((selectBox: SelectBox) => selectBox.closeDropdown());
}
Expand Down
Loading

0 comments on commit 74d33a9

Please sign in to comment.