A working demo application can be found here:
The code is included in the git repository.
License | Build status | Code coverage |
---|---|---|
Since version 16.1, the dependency graph between the project has changed.
The ng-video-player
package no longer depends on ng-youtube-player
, ng-vimeo-player
and ng-soundcloud-player
. But now it's the other way around. See the installation instructions below for the updated packages.
Run the corresponding commands, depending on what players you want to support in your application:
npm i @mintplayer/ng-video-player
npm i @mintplayer/youtube-player
npm i @mintplayer/vimeo-player
npm i @mintplayer/soundcloud-player
npm i @mintplayer/spotify-player
npm i @mintplayer/twitch-player
npm i @mintplayer/facebook-player
npm i @mintplayer/mixcloud-player
npm i @mintplayer/streamable-player
npm i @mintplayer/vidyard-player
npm i @mintplayer/wistia-player
npm i @mintplayer/file-player
Import the modules for which you want to support a player:
@NgModule({
...,
imports: [
...,
VideoPlayerComponent,
]
providers: [
provideVideoApis(
youtubePlugin,
vimeoPlugin,
soundCloudPlugin,
mixCloudPlugin,
twitchPlugin,
spotifyPlugin,
streamablePlugin,
facebookPlugin,
filePlugin,
vidyardPlugin,
wistiaPlugin
)
]
})
Use the component in the template:
<video-player [width]="width" [height]="height" [autoplay]="true"
[(volume)]="volume" [(mute)]="isMuted" [(playerState)]="playerState"
(progressChange)="onProgressChange($event)" (isPipChange)="isPip = $event" #player1></video-player>
@ViewChild('player1') player1!: VideoPlayerComponent;
playVideo(video: string) {
// This will replay the video when the url is the same.
this.player1.setUrl(video);
return false;
}
Or use the url
input binding:
<video-player [width]="width" [height]="height" [autoplay]="true" [url]="url"
[(volume)]="volume" [(mute)]="isMuted" [(playerState)]="playerState"
(progressChange)="onProgressChange($event)" (isPipChange)="isPip = $event"></video-player>
url: string | null = null;
playVideo(video: string) {
// This will not replay the video when the url is the same.
this.url = video;
return false;
}
All components are showcased in the angular app included in the project. You can simply run
npm start -- --open
to discover them.
Make sure you have NodeJS installed. Then run following commands
git clone https://github.com/MintPlayer/mintplayer-ng-video-player
npm i
npm start -- --open
You can run the docker image which is published to the GitHub Container Registry
docker run -p 4200:80 ghcr.io/mintplayer/mintplayer-ng-video-player:master
and visit http://localhost:4200.