Richienb / audic

Play some audio.
MIT License
68 stars 9 forks source link

Play / Pause sometimes get mixed up #29

Open eedefeed opened 2 months ago

eedefeed commented 2 months ago

Play and pause sometimes get mixed up, meaning that play causes playback to pause and pause causes playback to play.

I presume this is because of VLC's http API not having independent calls. From the VLC http API wiki page

toggle pause. If current state was 'stop', play item :

?command=pl_pause&id=

NB: ?command=pl_pause NB: seems largely ignored ? stream often continues. (May depend on whether camera obeys pause command - NB this command may only cause a PAUSE to be sent out to the video stream source, so result will depend on whether source obeys.)

Does the API return any indication of success / failure ? If so perhaps that can be used to fix this.

eedefeed commented 1 month ago

To add to this, I found a way to trigger this bug (inconsistently) by attempting to pause a song when it is first 'playing'. (Apologies if this code is wrong, I've edited it down a bit from my wrapper class.)


function loadTrack(fullTrackPath) {

        let track  = new Audic(fullTrackPath);

        this.track.addEventListener("playing", () => {
            console.log("shouldn't be playing, attempted pause", track.playing);
                track.pause();
                console.log("after:", track.playing);
            }
        }, {"once": true});
}