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

player sources not played when updated from component #45

Closed Al-Sharif closed 4 years ago

Al-Sharif commented 4 years ago

The player should re-initialized or somehow be able to read the new video sources. my scenario is:

  1. I've empty source on init component.
  2. The player is shown with black (it's fine).
  3. User uploaded new video and this source pushed to sources array.
  4. Video still black.

How I fixed this issue? this.videoSources.push({ src: event.body, size: 1440, type: this.selectedFile.file.type }); this.plyr.player.source = { sources: this.videoSources, type: 'video' } this.plyr.player.play();

but i assume its should be re-initialized automatically if this.videoSources has changed.

smnbbrv commented 4 years ago

There is no way to detect the changes inside the same object passed as input. If you want to reinitialize everything you need to pass another array instead of pushing to the same one. This is not the specifics of this library; this is how angular works