smnbbrv / ngx-plyr

Angular 6+ binding for Plyr video & audio player
https://smnbbrv.github.io/ngx-plyr/
MIT License
100 stars 65 forks source link

How to controll multiple videos? with or without custom control #91

Open naonvl opened 3 years ago

naonvl commented 3 years ago

image

i want to create a multiple player controls by one video or a custom controls, i manage to control play pause and stop but how do i control if user did seeking? i tried seeking and seeked but i think i use it wrong, here's how i implement customcontrol

  play(): void {
    this.isPlayed = true;
    this.plyr.toArray().forEach(plyr => plyr.player.play());
  }
 seeking(): void {
    // IF USER SEEKING
  }
  seeked(event: Plyr.PlyrEvent) {
    this.seeking()
  }

How can i do that?

metsehaf commented 2 years ago

@naonvl , this is how I did it for multiple players,

In your html you can pass the index of your selected video and seek like this `

<div style="padding-top: 2rem; padding-bottom: 2rem">
  <share-buttons theme="modern-light" show="11"></share-buttons>
</div>

` so in your component.ts, you can't really call a seek function cause it doesn't exist, but you can set the current time by specifiying or assigning it

` selectToThirty(i: number) { this.playerList[i].player.currentTime = 30; this.play(i); }

selectToSixty(i: number) { this.playerList[i].player.currentTime = 60; this.play(i); }

selectToNinety(i: number) { this.playerList[i].player.currentTime = 90; this.play(i); } `