beep icon indicating copy to clipboard operation
beep copied to clipboard

Feature Request: Be able to cancel a Seq

Open gtaubman opened this issue 6 years ago • 1 comments

Hello!

Beep has been fantastic to use. However I'm having some difficulty with the following situation.

I have a Seq of a StreamSeekCloser followed by a BeepCallback() to tell me when the audio file is done. Sometimes I'd like to stop streaming early, but If I close the StreamSeekCloser then my BeepCallback gets called.

I took a look at the implementation of Seq and it doesn't look like I can alter the items of the sequence after creation, which means I can't purposefully remove the BeepCallback() and then close the stream.

Would you be open to adding the ability to cancel a Seq which would cancel the current stream and then not run any of the other streams?

Thanks!

gtaubman avatar Sep 21 '19 01:09 gtaubman

In the mean time, you can assign and change an identifier whenever cancelling a Seq:

streamer := beep.Seq(audioFile.Streamer, beep.Callback(func() {
	if playingFileID != thisFileID {
		return
	}

	go nextTrack()
}))

Full example from ditty: audio.go

tslocum avatar Jan 28 '20 01:01 tslocum