0.0.16 • Published 11 months ago

kpoint-angular-player v0.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

kpoint-angular-player

An Angular component for embeding KPOINT video in your Angular application.

Usage

npm install kpoint-angular-player

Advance Embedding Template

   <kpoint-player #player
      [domain]="'service.domain'"
      [videoId]="'gcc-id'"
      [height]="'360px'"
      [width]="'640px'"
      [personalizationInfo]="'bmFtZTpWaXJhdDthbW91bnQ6MTAwMDAwOw=='"
      [videoParams]="{search: 'false', toc: 'false'}"
      [onStateChange]="onStateChange"
      [onTimeupdate]="onTimeupdate"
      [onload]="onload"
      [onError]="onError"
    >
    </kpoint-player>

Dynamic Embedding Template

   <kpoint-player #player
      [domain]="'service.domain'"
      [videoId]="'gcc-id'"
      [height]="'360px'"
      [width]="'640px'"
      [packageId]="'package-id'"
      [personalizationInfo]="'bmFtZTpWaXJhdDthbW91bnQ6MTAwMDAwOw=='"
      [onStateChange]="onStateChange"
      [onTimeupdate]="onTimeupdate"
      [onload]="onload"
      [onError]="onError"
    >
    </kpoint-player>

Input Properties

Input PropertiesDescriptionDefault
domainHost name of your kPoint server. Typically of the form acme.kpoint.com.""
videoIdId of the video to load.""
widthSet the width of the player640px
heightSet the height of the player360px
videoParamsSet the player parameters{}
widgetsConfigSet the widgets configuration{}
packageIdId of interactivity package created for the video""
personalizationInfoBase 64 encoded string of the personalized data""

Callback events

Callback events take a function that gets fired on various player events:

EventsDescription
onLoadCalled when media is loaded and ready to play.
onErrorCalled when an error occurs whilst attempting to play media
onStateChangeCalled when playback state updates (-1: Not started yet, 0: Playback Over, 1: Playing, 2: Paused, 3: Buffering, 5: Replay)
onTimeupdatecalled when playback time updates
MethodDescription
playVideoPlays video from current position. or if video has not started, starts video from beginning.
pauseVideoPauses video at the current position.
replayVideoReplays video from the beginning.
getCurrentTimeReturns current video position in milliseconds.
getDurationReturns the duration of the video in milliseconds.
getPlayerInfoReturn the video information like kvtoken,video-hostname,etc.
seekToJumps to specific point in video. Time argument in specified in milliseconds.
setAudioSets playback audio to specified language, available for the video (Language codes: 'hi': 'Hindi', 'en': 'English', 'mr': 'Marathi', 'te': 'Telgu'). For more follow ISO Language Code table.

Example of how to use callback props and Instance methods to control the player

import { Component, OnInit, ViewChild } from '@angular/core';
import { KpointAngularPlayerComponent } from 'kpoint-angular-player';

@Component({
  selector: 'app',
  template: `
    <button (click)="getVideoDuration()">Get Video Duration</button>
    <kpoint-player #player
      [domain]="'ktpl.kpoint.com'"
      [videoId]="'gcc-d9e8dbc3-5dfa-4f68-bf7a-97f25fb7632c'"
      [height]="'360px'"
      [width]="'640px'"
      [personalizationInfo]="'bmFtZTpWaXJhdDthbW91bnQ6MTAwMDAwOw=='"
      [videoParams]="{search: 'false', toc: 'false'}"
      [onStateChange]="onStateChange"
      [onTimeupdate]="onTimeupdate"
      [onload]="onload"
      [onError]="onError"
    >
    </kpoint-player>
  `,
})
export class AppComponent implements OnInit {
  @ViewChild('player', { static: true }) player!: KpointAngularPlayerComponent;

  ngOnInit() {}

  onTimeupdate = (timeMs: number) => {
    console.log('Time update, new time: ' + parseFloat(timeMs).toFixed(2));
  }

  onStateChange = (evt: any) => {
    console.log('onStateChange: ' + evt.data);
  }

  onError = (evt: any) => {
    console.log('onError: ' + evt.data);
  }

  Onload = () => {
    console.log('Video loaded');
  }

  getVideoDuration() {
    console.log(this.player.getDuration());
  }

  getPlayerInfo() {
    console.log(this.player.getPlayerInfo());
  }
  
  setAudio(langCode: any){
    console.log(this.player.setAudio(langCode));
  }

}

License

Angular is MIT licensed.

0.0.14

12 months ago

0.0.15

12 months ago

0.0.16

11 months ago

0.0.13

12 months ago

0.0.12

12 months ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago