Skip to content
Advertisement

Videogular 2 onChangeFullscreen event

I need to know how do I use the VgFullscreenAPI. The official documentation doesn’t help.

This is what I have:

<vg-player 
    (onPlayerReady)="onPlayerReady($event)"
    (onChangeFullscreen)="toggleFullscreen($event)">
    <vg-play-pause #playBtn class="play-btn">
      <span class="vg-icon-play_arrow"></span>
    </vg-play-pause>
    <vg-controls [vgAutohide]="true" [vgAutohideTime]="4" >
      <vg-play-pause</vg-play-pause>
      <vg-mute></vg-mute>
      <vg-fullscreen class="ml-auto"></vg-fullscreen>
    </vg-controls>
    <video #media 
      [vgMedia]="media" 
      [attr.id]="post.id" 
      preload="none" 
      [poster]="post.thumbnail"
      (click)="onVideoClick()"
      loop>
      <source [src]="post.source" type="video/mp4">
    </video>
</vg-player>

toggleFullscreen($event){
  console.log($event);
}

I have tried using the output event emitter (onChangeFullscreen) on vg-plater, vg-fullscreen, and video tags.

Documentation

Advertisement

Answer

The event is provided by the VgFullscreenAPI service inside VgPlayer, you can access it like this inside your component class:

@ViewChild(VgPlayer) vgPlayer: VgPlayer;

ngAfterViewInit(): void {
  this.vgPlayer.fsAPI.onChangeFullscreen.subscribe((event) => {
    this.toggleFullscreen(event);
  });
}

Don’t really know why they made it an EventEmitter inside the service. Doesn’t seem like they really understand the new angular version yet 🙂

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement