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>
This is a basic player just with a play/pause button
<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>
This is a full-featured player with controls, overlay play and streaming
creating a simple player
As we saw before we can use VgMedia in a <video> 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 #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>
But we can use it in @Component and controls will work as expected!!
creating a 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);
}
}
using two VgMedia
Because we have an arbitrary number of VgMedia, some questions may appear:
<vg-player>
<video #videoRef
[vgMedia]="videoRef"
[src]="source"
id="myVideo">
</video>
<vg-play-pause></vg-play-pause>
<vg-mute vgFor="myVideo"></vg-mute>
</vg-player>
using VgMaster and VgFor
but first...
using VgMaster and VgFor