Using Fluid Player with Angular

Fluid Player works with Angular out of the box. To start using Fluid Player in your Angular project, you will need to:

  • install Fluid Player using Yarn or NPM as outlined here; and

  • import Fluid Player module and attach it to video element of your choosing.

You can see an example of how to integrate Fluid Player and Angular in the example below. This is a simplified example to get you going quickly. Follow Angular best practices on how to create reusable components depending on the needs of your project.

app.component.html

<video #ref>
    <source
            src="https://cdn.fluidplayer.com/videos/valerian-1080p.mkv"
            data-fluid-hd
            title="1080p"
            type="video/mp4"
    >
</video>

Note: Safari does not support playback of .mkv files. To view this file type, consider using a different browser that supports the .mkv format.

app.component.ts

import {AfterViewChecked, Component, ElementRef, ViewChild} from '@angular/core';
import fluidPlayer from 'fluid-player';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewChecked {

  fluidPlayer: any;

  @ViewChild('ref') ref!: ElementRef;

  ngAfterViewChecked() {
    if (!this.fluidPlayer) {
      this.fluidPlayer = fluidPlayer(this.ref.nativeElement);
    }
  }
}

angular.json

Inside the options property:

Was this helpful?