Skip to content

Commit 183d118

Browse files
[GLAM-691] fix responsiveness issue
1 parent 291a9c1 commit 183d118

4 files changed

Lines changed: 20 additions & 39 deletions

File tree

src/app/shared/media-player/media-player.component.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
<div class="media-container d-flex" *ngIf="(isPlatformBrowser | async)">
2-
<div class="media-wrapper">
3-
<div class="h-100 w-100">
1+
<div class="media-container w-100 h-100 d-flex" *ngIf="(isPlatformBrowser | async)">
2+
<div class="media-wrapper h-100 w-100">
43
<ds-themed-loading *ngIf="!(isVideoPlayerInitialized$ | async) && !(isAudioPlayerInitialized$ | async)" [showMessage]="false"></ds-themed-loading>
54
<div class="overlay-onchange" *ngIf="isLoadingOnChange$ | async">
65
<ds-themed-loading [spinner]="true" [showMessage]="false"></ds-themed-loading>
76
</div>
8-
<div id="video-content-wrapper h-100 w-100" *ngIf="(isVideoPlayerInitialized$ | async) && (isVideo$ | async)">
9-
<video class="video-js vjs-big-play-centered vjs-fluid" id="video_player" controls playsinline
10-
preload="none"></video>
7+
<div #videoContainerRef>
8+
<div id="video-content-wrapper h-100 w-100" *ngIf="(isVideoPlayerInitialized$ | async) && (isVideo$ | async)">
9+
<video class="video-js vjs-big-play-centered" id="video_player" controls playsinline
10+
preload="none"></video>
11+
</div>
12+
<div id="audio-content-wrapper h-100 w-100" *ngIf="(isAudioPlayerInitialized$ | async) && !(isVideo$ | async)">
13+
<audio class="video-js" id="audio_player" controls preload="none"></audio>
14+
</div>
1115
</div>
12-
<div id="audio-content-wrapper h-100 w-100" *ngIf="(isAudioPlayerInitialized$ | async) && !(isVideo$ | async)">
13-
<audio class="video-js vjs-fluid" id="audio_player" controls playsinline preload="none"></audio>
14-
</div>
15-
</div>
16+
1617

1718
<ds-media-selection-bar *ngIf="isVideoPlayerInitialized$ | async"
1819
[startUUID]="startUUID"
@@ -21,7 +22,7 @@
2122
(selectItem)="setNewTimestamp($event)"></ds-media-selection-bar>
2223

2324
</div>
24-
<div class="playlist-wrapper w-100">
25+
<div #playlistContainerRef class="playlist-wrapper w-100">
2526
<ds-media-player-playlist [itemUUID]="itemUUID"
2627
[startUUID]="startUUID"
2728
(selectItem)="setNewMediaItem($event)"></ds-media-player-playlist>

src/app/shared/media-player/media-player.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
@import 'videojs-wavesurfer/dist/css/videojs.wavesurfer.css';
33

44
.media-container {
5+
max-height: 480px;
56
margin-bottom: 140px;
67
}
78

89

910
.media-wrapper {
1011
background-color: black;
1112
position: relative;
13+
flex-basis: 80%;
1214
}
1315

1416
.playlist-wrapper {
@@ -36,3 +38,7 @@
3638
padding-top: 1rem;
3739
}
3840
}
41+
42+
.video-js {
43+
width: 100%;
44+
}

src/app/shared/media-player/media-player.component.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export class MediaPlayerComponent implements OnInit, OnDestroy {
170170
this.currentItem$?.value
171171
);
172172
this.resizeMediaPlaylist();
173-
this.resizeMediaPlayer();
174173
}, 100);
175174

176175
} else {
@@ -270,18 +269,4 @@ export class MediaPlayerComponent implements OnInit, OnDestroy {
270269
private resizeMediaPlaylist(): void {
271270
this.playlistContainerRef.nativeElement.style.height = `${this.videoContainerRef.nativeElement.getBoundingClientRect().height}px`;
272271
}
273-
274-
/**
275-
* Resize the video container
276-
*/
277-
private resizeMediaPlayer(): void {
278-
const aspectRatio = parseInt(this.currentItem$?.value.bitstream.firstMetadataValue('bitstream.video.width'), 10) /
279-
parseInt(this.currentItem$?.value.bitstream.firstMetadataValue('bitstream.video.height'), 10);
280-
281-
if (aspectRatio < 1) {
282-
const playerWidth = `${this.videoContainerRef.nativeElement.getBoundingClientRect().width * aspectRatio}px`;
283-
this.videoContainerRef.nativeElement.style.setProperty('width', playerWidth, 'important');
284-
this.videoContainerRef.nativeElement.parentElement.style.setProperty('width', playerWidth, 'important');
285-
}
286-
}
287272
}

src/app/shared/media-player/services/browser-videojs.service.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export class BrowserVideojsService implements VideojsService {
4444
autoplay: false,
4545
loop: false,
4646
responsive: true,
47-
fluid: true,
48-
aspectRatio: undefined
47+
width: 600,
48+
height: 480,
4949
};
5050

5151
/**
@@ -67,17 +67,6 @@ export class BrowserVideojsService implements VideojsService {
6767
* Return an instance of videojs player for video media
6868
*/
6969
initVideoPlayer(element: HTMLElement, mediaItem: MediaViewerItem): any {
70-
const currentVideoRatio = parseInt(mediaItem.bitstream.firstMetadataValue('bitstream.video.width'), 10) /
71-
parseInt(mediaItem.bitstream.firstMetadataValue('bitstream.video.height'), 10);
72-
73-
if (currentVideoRatio < 1) {
74-
// videojs available ratios are '16:9', '9:16', '4:3', we set it only for portrait mode since the width would be off for those
75-
this.configVideo = {
76-
...this.configVideo,
77-
aspectRatio: '9:16'
78-
};
79-
}
80-
8170
const videoPlayer = videojs(element, this.configVideo, () => {
8271
videoPlayer.src({ src: mediaItem?.manifestUrl, type: 'application/dash+xml' });
8372
(videoPlayer as any).hlsQualitySelector();

0 commit comments

Comments
 (0)