From b92fe58a814d1cf3a2094d7ca8a92c5b4cbe819c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Wed, 17 Apr 2024 09:51:25 +0100 Subject: [PATCH] solved erro of displaying video controls on publications --- src/app/shared/swiper/swiper.page.html | 14 +++++--- src/app/shared/swiper/swiper.page.scss | 49 ++++++++++++++++++++++++- src/app/shared/swiper/swiper.page.ts | 50 ++++++++++++++++++++++++-- 3 files changed, 104 insertions(+), 9 deletions(-) diff --git a/src/app/shared/swiper/swiper.page.html b/src/app/shared/swiper/swiper.page.html index c929d3bd2..dc8119aa1 100644 --- a/src/app/shared/swiper/swiper.page.html +++ b/src/app/shared/swiper/swiper.page.html @@ -5,16 +5,20 @@ --> - +
+ [src]="'data:image/jpg;base64,' + files.FileBase64" loading="lazy"> -
diff --git a/src/app/shared/swiper/swiper.page.scss b/src/app/shared/swiper/swiper.page.scss index e49a6bec2..f2ed2538f 100644 --- a/src/app/shared/swiper/swiper.page.scss +++ b/src/app/shared/swiper/swiper.page.scss @@ -154,6 +154,8 @@ ion-toolbar { display: flex; justify-content: center; background: black; + position: relative; + } video { max-width: -webkit-fill-available; @@ -275,7 +277,6 @@ swiper-slide img { background: black; } - swiper-slide video { width: 100%; height: 100%; @@ -292,8 +293,15 @@ swiper-slide video { display: flex; justify-content: center; background: black; + text-align: end; } +.swiper-slide-active { + width: 100%; + text-align: center; + align-items: center; + justify-items: center; +} .swiper-container::part(button-next) { display: none !important; @@ -323,3 +331,42 @@ swiper-slide video { display: inline-block; /* Display dots in a row */ margin-right: 5px; } + +.play-button { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +video::-webkit-media-controls-enclosure { + /* width:100%; + display:flex; */ +} + +video::-webkit-media-controls-panel { + /* width: 100%; + align-items: center; + text-align: center; */ +} + +.hide-controls::-webkit-media-controls-panel { + /* display: none; */ +} + +.play-button { + width: 69px; + height: 69px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 10; + background-color: rgba(243, 241, 241, 0.5); + color: rgb(4, 4, 4); + border: none; + padding: 10px 20px; + cursor: pointer; + border-radius: 100px; + /* Add additional styles for your custom play button */ +} \ No newline at end of file diff --git a/src/app/shared/swiper/swiper.page.ts b/src/app/shared/swiper/swiper.page.ts index f67b741ce..063b3d1b9 100644 --- a/src/app/shared/swiper/swiper.page.ts +++ b/src/app/shared/swiper/swiper.page.ts @@ -2,6 +2,8 @@ import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; import { checkFileTypeService } from 'src/app/services/checkFileType.service'; import { StopvideoService } from 'src/app/services/stopvideo.service'; + + @Component({ selector: 'app-swiper', templateUrl: './swiper.page.html', @@ -18,23 +20,44 @@ export class SwiperPage implements OnInit { @ViewChild('swipers') swiperRef: ElementRef | undefined; + showControls: boolean = false; + previousIndex: number | undefined; + constructor( public checkFileType: checkFileTypeService, public stopvideoService: StopvideoService, ) { console.log('swieper', this.publicationList) - } + } ngOnInit() { console.log('swieper', this.publicationList) + } + onSlideChange() { - this.swiperIndex = this.swiperRef?.nativeElement.swiper.activeIndex; - console.log(this.swiperIndex) + + console.log('onchage') + if (this.swiperRef) { + + const swiper = this.swiperRef.nativeElement.swiper; + this.swiperIndex = swiper.activeIndex; + + // Check if the currentIndex is different from the previousIndex + if (this.swiperIndex !== this.previousIndex) { + console.log('Active index changed. New index:', this.swiperIndex); + // Update the previousIndex with the currentIndex + this.previousIndex = this.swiperIndex; + this.loadVideo() + + } + console.log(this.swiperIndex) + } } + goToSlide(index: number) { this.swiperIndex = this.swiperRef?.nativeElement.swiper.activeIndex; this.swiperRef?.nativeElement.swiper.slideTo(index); @@ -71,4 +94,25 @@ export class SwiperPage implements OnInit { } } + //This method does the refresh of all video(it was implement beacouse of the erro displaing the controls of the video while swipe) + //If you can find a better solution, please remove + loadVideo() { + var videos = document.querySelectorAll('video'); + + try { + // Pause each video + videos.forEach(function (video) { + video.load(); + }) + + const video: HTMLVideoElement = this.videoElements.nativeElement; + + video.load() + } catch (error) { + console.log(error) + } + } + } + +