1

I want to autoplay video like tik tok on slide change. After implementation Video thumbnails are displaying and audio is playing, but not video.

<ion-slides direction="vertical" #slides (ionSlideDidChange)="slideEvent(slides)" (ionSlideWillChange)="isLike(slides)">  
  <ion-slide *ngFor = "let videoUrl of mainArray" >         
    <video [id]="videoUrl.id" poster='{{videoUrl.thumbnailUrl}}' preload="none"> 
      <source src="{{videoUrl.url}}" type="video/mp4" autostart="false"/>  
    </video>
  </ion-slide>
</ion-slides>

and from ts trying to play video as -

playvideo() {
  let videoPlayer1: HTMLVideoElement = <HTMLVideoElement>document.getElementById(this.mainArray[this.index].id)
  videoPlayer1.pause();
  videoPlayer1.currentTime = 0;
  const playPromise = videoPlayer1.play();
  if (playPromise !== null){
     playPromise.catch(() => {
     videoPlayer1.play(); 
     videoPlayer1.autoplay = true;
   })
  } 
}

But only audio is playing not video.

0 Answers0