Angular
A component for embedding Kinescope Player in Angular. It uses an iframe and the IFrame API under the hood. Repository: kinescope/angular-kinescope-player .
Installation
npm install @kinescope/angular-kinescope-player --save
Quick start
import { KinescopePlayerComponent } from '@kinescope/angular-kinescope-player'
@NgModule({
imports: [KinescopePlayerComponent],
})
export class AppModule {}
import { AfterViewInit, Component, ViewChild } from '@angular/core'
import {
KinescopePlayerComponent,
KinescopePlayerConfig,
} from '@kinescope/angular-kinescope-player'
@Component({
template: `<kinescope-player #kinescope [config]="config"></kinescope-player>`,
})
export class PlayerComponent implements AfterViewInit {
config: KinescopePlayerConfig = {
videoId: 'VIDEO_ID',
}
@ViewChild('kinescope') private kinescope!: KinescopePlayerComponent
ngAfterViewInit() {
// Methods are available after the player is initialized.
// void this.kinescope.play()
}
}
Config (props)
Pass the parameters as an object to [config].
| Field | Type | Default | Required |
|---|---|---|---|
videoId | string | — | yes |
className | string | — | no |
style | any | — | no |
title | string | — | no |
subtitle | string | — | no |
poster | string | — | no |
chapters | Chapter[] | — | no |
vtt | Vtt[] | — | no |
width | number | string | 100% | no |
height | number | string | 100% | no |
autoPlay | boolean | 'viewable' | false | no |
autoPause | boolean | 'reset' | true | no |
loop | boolean | false | no |
playsInline | boolean | true | no |
muted | boolean | false | no |
language | 'en' | 'ru' | auto | no |
controls | boolean | true | no |
mainPlayButton | boolean | true | no |
playbackRateButton | boolean | false | no |
externalId | string | — | no |
drmAuthToken | string | — | no |
actions | Action[] | — | no |
bookmarks | Bookmark[] | — | no |
watermark | Watermark | — | no |
localStorage | boolean | true | no |
Config types
Chapter
type Chapter = {
position: number
title: string
}
Vtt
type Vtt = {
label: string
src: string
srcLang: string
}
Action
type Action = ActionToolBar | ActionCallToAction
type ActionToolBar = {
id: string
type: 'tool'
title?: string
icon: 'note'
}
type ActionCallToAction = {
id: string
type: 'cta'
title: string
description?: string
skipable?: boolean
buttonStyle?: CSSProperties
trigger: {
percentages: number[]
timePoints: number[]
pause: boolean
}
}
Bookmark
type Bookmark = {
id: string
time: number
title?: string
}
Watermark
type Watermark =
| string
| {
text: string
mode?: 'random' | 'stripes'
scale?: number
displayTimeout?: number | { visible: number; hidden: number }
}
Events
| Event | Data |
|---|---|
onJSLoad | — |
onJSLoadError | — |
onReady | { currentTime, duration, quality, qualityLevels } |
onQualityChanged | { quality } |
onAutoQualityChanged | { quality } |
onSeekChapter | { position } |
onSizeChanged | { width, height } |
onPlay | — |
onPlaying | — |
onWaiting | — |
onPause | — |
onEnded | — |
onTimeUpdate | { currentTime } |
onProgress | { bufferedTime } |
onDurationChange | { duration } |
onVolumeChange | { muted, volume } |
onPlaybackRateChange | { playbackRate } |
onSeeking | — |
onFullscreenChange | { isFullscreen, video } |
onCallAction | { id, title?, type } |
onCallBookmark | { id, time, title? } |
onError | { error } |
onDestroy | — |
Methods
Call methods through @ViewChild, for example, this.kinescope.play().
| Method | Parameters | Result |
|---|---|---|
isPaused | — | Promise<boolean> |
isEnded | — | Promise<boolean> |
play | — | Promise<void> |
pause | — | Promise<boolean> |
stop | — | Promise<void> |
getCurrentTime | — | Promise<number> |
getDuration | — | Promise<number> |
seekTo | (time: number) | Promise<void> |
isMuted | — | Promise<boolean> |
mute | — | Promise<void> |
unmute | — | Promise<void> |
getVolume | — | Promise<number> |
setVolume | (value: number) | Promise<void> |
getPlaybackRate | — | Promise<number> |
setPlaybackRate | (value: number) | Promise<void> |
getVideoQualityList | — | Promise<VideoQuality[]> |
getCurrentVideoQuality | — | Promise<VideoQuality> |
setVideoQuality | (quality: VideoQuality) | Promise<void> |
enableTextTrack | (lang: string) | Promise<void> |
disableTextTrack | — | Promise<void> |
closeCTA | — | Promise<void> |
isFullscreen | — | Promise<boolean> |
setFullscreen | (fullscreen: boolean) | Promise<void> |