Raúl Jiménez
elecash@gmail.com
@elecash
Angular GDE
videogular
academy partner
toptal partner
Components
Directives
Services
Modules
VgPlayer
VgMedia
VgAPI
VgPlay
(click)
play()
<vg-player>
<vg-play-pause></vg-play-pause>
<video #videoRef
[vgMedia]="videoRef"
id="video"
src="http://static.videogular.com/assets/videos/videogular.mp4">
</video>
</vg-player>
Este es un player básico solo con un botón de play/pause
<vg-player>
<vg-overlay-play></vg-overlay-play>
<vg-controls>
<vg-play-pause></vg-play-pause>
<vg-time-display vgProperty="current" vgFormat="mm:ss"></vg-time-display>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
<vg-scrub-bar-buffering-time></vg-scrub-bar-buffering-time>
</vg-scrub-bar>
<vg-time-display vgProperty="left" vgFormat="mm:ss"></vg-time-display>
<vg-mute></vg-mute>
<vg-volume></vg-volume>
<vg-fullscreen></vg-fullscreen>
</vg-controls>
<video #media [vgMedia]="media" [vgHls]="streamingUrl" id="singleVideo" preload="auto"></video>
</vg-player>
Este es un player "full-equip" con controles, overlay play y streaming
crear un player simple
Como vimos en el ejemplo anterior podemos usar VgMedia en un elemento <video>
<vg-player>
<vg-controls>
<vg-play-pause></vg-play-pause>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
</vg-scrub-bar>
<vg-fullscreen></vg-fullscreen>
</vg-controls>
<video #videoRef
id="video"
[vgMedia]="videoRef"
src="http://static.videogular.com/assets/videos/videogular.mp4">
</video>
</vg-player>
<vg-player>
<vg-controls>
<vg-play-pause></vg-play-pause>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
</vg-scrub-bar>
<vg-fullscreen></vg-fullscreen>
</vg-controls>
<app-time-viewer #timerRef
id="timer"
[vgMedia]="timerRef"
[duration]="videoRef.duration">
</app-time-viewer>
</vg-player>
Podemos crear un @Component personalizado y los controles funcionarán automágicamente!!
custom media element
<vg-player>
<vg-controls>
<vg-play-pause></vg-play-pause>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
</vg-scrub-bar>
<vg-fullscreen></vg-fullscreen>
</vg-controls>
<video id="video"
#videoRef
[vgMedia]="videoRef"
src="http://static.videogular.com/assets/videos/videogular.mp4">
</video>
<app-time-viewer id="timer"
#timerRef
[vgMedia]="timerRef"
[duration]="videoRef.duration">
</app-time-viewer>
</vg-player>
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { VgAPI } from 'videogular2/core';
@Component({
selector: 'vg-pip',
templateUrl: './vg-pip.component.html',
styleUrls: [ './vg-pip.component.scss' ]
})
export class VgPipComponent implements OnInit {
media: MyCustomMedia = new MyCustomMedia();
constructor(private api: VgAPI) {}
ngOnInit() {
this.api.registerMedia(this.media);
}
}
usando dos VgMedia
Como podemos tener un número arbitrario de VgMedia, alguna preguntas pueden aparecer:
<vg-player>
<video #videoRef [vgMedia]="videoRef" [src]="source" id="myVideo"></video>
<audio #audioRef [vgMedia]="audioRef" [src]="source" id="myAudio"></audio>
<vg-play-pause></vg-play-pause>
<vg-mute vgFor="myVideo"></vg-mute>
</vg-player>
VgMaster & VgFor