vime-js / vime

Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
https://vimejs.com
MIT License
2.75k stars 154 forks source link

play function inside angular code doesn't work #307

Open izetrom opened 2 years ago

izetrom commented 2 years ago

hi, I'm trying to play audios with vime player with angular I can load a new url dynamically (using behaviorsubject), but i can't play it using player.play(), only with the play button of the player. I can see the new audio source being loaded in the player (the time of the audio source in the player changes). If I click on play button of the player, it plays the good one, but when I'm trying to play it with code, it only plays the first url I loaded at the beginning, and the player doesn't pass in play mode (the play button doesn't change, and the time indicator doesn't increase). The url is passed through a subject and an observable. Here is the angular code:

this.audioService.isPlayCalled$.subscribe(() => { this.player.play(); }); this.audioService.isPauseCalled$.subscribe(() => { this.player.pause(); }) this.audioService.isNewMusicSet$.subscribe(() => { this.audioService.getDataSource(); this.player.canAutoplay().then(canPlay => { if (canPlay) { console.log("New music to play: " + this.url); this.player.play(); } })

and this is my html :

`<vm-player theme="light" style="--vm-player-theme: #7D3C98;"

player>

<vm-audio>
    <source
    [attr.data-src]="url"
    type="audio/wav;audio/x-wav;audio/mpeg3;audio/x-mpeg-3"/>
    </vm-audio>
    <vm-ui>
        <vm-controls>
            <vm-playback-control (click)="onClick()"></vm-playback-control>
            <vm-time-progress separator="/"></vm-time-progress>
            <vm-scrubber-control></vm-scrubber-control>
            <vm-volume-control></vm-volume-control>
        </vm-controls>
        <vm-loading-screen></vm-loading-screen>
    </vm-ui>
</vm-player>`

if anyone knows what i am doing wrong :/

rnicholls commented 2 years ago

is "player" the ViewChild?