13.3.0 • Published 4 years ago

@flosportsinc/ng-video-events v13.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

FloVideoEvents

Use Dependency Injection to bind to arbitrary video player events for easy extensibility

NPM Installation

npm i @flosportsinc/ng-video-events

App

Inside your AppModule install SvgTransferStateModule like so:

import { NgModule } from '@angular/core'
import { FloVideoEventsModule, VIDEO_PLAYER_EVENT_BINDINGS } from '@flosportsinc/ng-video-events'

@NgModule({
  imports: [
    FloVideoEventsModule
  ],
  providers: [
    // define your event bindings via Angular dependency injection
    {
      provide: VIDEO_PLAYER_EVENT_BINDINGS,
      multi: true,
      useValue: {
        // every event has the following signature
        pause: (videoEvent: Event, videoElement: HTMLVideoElement, 
          videoInstanceId: string,  videoGroupId: string, 
          metadata: TMeta, emitFunc: (msg: TMessage) => void, 
          onDestroy: Observable<any>) => {
            // do stuff in here
        }
      }
    },
    {
      provide: VIDEO_PLAYER_EVENT_BINDINGS,
      multi: true,
      useFactory: (someService) => { // for AOT, you will need to make this an exported factory function
        return {
          pause: (...args) => {
            // do stuff here
            someService.doTheThing(arg[1])
          }
        }
      },
      deps: [SomeService] // pass in your services to do more interesting things!
    }
  ]
})
export class AppModule { }

Event handler signature

type FloVideoEventHandler<TMeta = any, TMessage = any> = (
  videoEvent: Event,
  videoElement: HTMLVideoElement,
  videoInstanceId: string,
  videoGroupId: string,
  metadata: TMeta,
  emitFunc: (msg: TMessage) => void,
  onDestroy: Observable<any>
) => void

Basic usage

Any event mappings providers will be bound and executed accoridingly during the video player lifecycle.

<video floVideoEvents></video>

With metadata

You can pass data from parent components through to your event binding functions if needed.

  // notice the "metadata" parameter
  (videoEvent: Event, videoElement: HTMLVideoElement, 
    videoInstanceId: string,  videoGroupId: string, 
    metadata: TMeta, emitFunc: (msg: TMessage) => void, 
    onDestroy: Observable<any>) => {
      // you can use it in your event binding
    }
<video [floVideoEvents]="{ property: 'some', property2: 'info' }"></video>

Emit changes from event bindings

You can emit messages from your event bindings and pass them back up to parent components if needed.

  // notice the "emitFunc" parameter
  (videoEvent: Event, videoElement: HTMLVideoElement, 
    videoInstanceId: string,  videoGroupId: string, 
    metadata: TMeta, emitFunc: (msg: TMessage) => void, 
    onDestroy: Observable<any>) => {
      // calling this will emit an event from the directive "floVideoEventMessage"
      emitFunc('whatever you want')
    }
<video floVideoEvents [floVideoEventMessage]="captureMessages($event)"></video>
13.3.0

4 years ago

13.2.4

4 years ago

13.2.3

4 years ago

13.2.2

5 years ago

13.2.1

5 years ago

13.2.0

5 years ago

13.1.0

5 years ago

13.0.1

5 years ago

13.0.0

5 years ago

12.1.1

5 years ago

12.1.0

5 years ago

12.0.3

5 years ago

12.0.2

5 years ago

12.0.1

5 years ago

12.0.0

5 years ago

11.4.0

5 years ago

11.3.1

5 years ago

11.3.0

5 years ago

11.2.6

5 years ago

11.2.5

5 years ago

11.2.4

5 years ago

11.2.3

5 years ago

11.2.2

5 years ago

11.2.1

5 years ago

11.2.0

5 years ago

11.1.0

5 years ago

11.0.0

5 years ago

10.0.0

5 years ago

9.8.0

5 years ago

9.7.3

5 years ago

9.7.2

5 years ago

9.7.1

5 years ago

9.7.0

5 years ago

9.6.0

5 years ago

9.5.2

5 years ago

9.5.1

5 years ago

9.5.0

5 years ago

9.4.3

5 years ago

9.4.2

5 years ago

9.4.1

5 years ago

9.4.0

5 years ago

9.3.0

5 years ago

9.2.5

5 years ago

9.2.4

5 years ago

9.2.3

5 years ago

9.2.2

5 years ago

9.2.1

5 years ago

9.2.0

5 years ago

9.1.1

5 years ago

9.1.0

5 years ago

9.0.0

5 years ago

8.1.1

5 years ago

8.1.0

5 years ago

8.0.1

5 years ago

8.0.0

5 years ago

7.5.5

5 years ago

7.5.4

5 years ago

7.5.3

5 years ago

7.5.2

5 years ago

7.5.1

5 years ago

7.5.0

5 years ago

7.4.2

5 years ago

7.4.1

5 years ago

7.4.0

5 years ago

7.3.1

5 years ago

7.3.0

5 years ago

7.2.2

5 years ago

7.2.1

5 years ago

7.2.0

5 years ago

7.1.0

5 years ago

7.0.0

5 years ago

6.11.0

5 years ago

6.10.0

5 years ago

6.9.3

5 years ago

6.9.2

5 years ago

6.9.1

5 years ago

6.9.0

5 years ago

6.8.1

5 years ago

6.8.0

5 years ago

6.7.0

5 years ago