Skip to content

About

Video.js 10 + Mux in Angular, with the player lazy-loaded via @defer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Video.js 10 + Mux in Angular

Plays a Mux video in Angular with Video.js 10 and loads the player only when it is shown.

Open in StackBlitz

How it works

  • src/app/video-player.ts imports the Video.js elements it uses (@videojs/html/video/player, @videojs/html/video/skin, @videojs/html/media/mux-video and @videojs/html/extensions/mux-data) and adds CUSTOM_ELEMENTS_SCHEMA.
  • src/app/app.ts renders that component inside @defer. @defer only lazy-loads Angular components, so the imports live in this wrapper component. Angular puts it and Video.js in a lazy chunk that loads only when the user clicks Load video.
  • <mux-video> takes the Mux source object through a property binding: [source]="{ playbackId }". It fires the standard media events, so (play) and (pause) work like they do on <video>.
  • <mux-data> turns on Mux Data monitoring. It reads metadata-* attributes such as metadata-video-title and metadata-viewer-user-id.

Run locally

npm install
npm start

Then open http://localhost:4200.

About

Video.js 10 + Mux in Angular, with the player lazy-loaded via @defer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages