Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove from queue #73

Open
rasmuslos opened this issue Apr 5, 2024 · 4 comments
Open

Remove from queue #73

rasmuslos opened this issue Apr 5, 2024 · 4 comments

Comments

@rasmuslos
Copy link

Thanks for this project it looks really promising! I want to use this for my audio playback application, but while it is possible to enqueue tracks it is not possible, at least using the public api, to dequeue them. Making this part of the public api would be great

@dimitris-c
Copy link
Owner

Hey, thanks for raising this.

Could you provide a set of possible methods you'd like to see?
The simplest case would be to only dequeue the last item added, but perhaps there may be more cases.

This will also be a good stress test for this library queue mechanism

@rasmuslos
Copy link
Author

rasmuslos commented Apr 5, 2024

I would love to use this library for my music streaming app. Naturally the user has quite a lot of control over the queue, so some methods are essential.
Right now I am using AVQueuePlayer, it has only a few methods, but they provide great functionality.

  • A insert(url, at) index function would be great, it would be useful if a user wants to modify the queue or play a track right after the current one, skipping the queue
  • A method to clear the queue would be nice, although not required
  • Some way to get the amount of tracks in the queue, either by returning all urls or just the count
  • Something like remove(at) to dequeue a track at a specific index, for example when a track is moved around

Thanks for the fast response!

@dimitris-c
Copy link
Owner

I think providing methods with index might complicate things, as you would have to have access to more underlying logic. This is why AVQueuePlayer handles everything with AVPlayerItem

We could almost create the same methods as AVQueuePlayer but instead of AVPlayerItem it will be URL or can make a somewhat breaking change and introduce a AudioPlayerItem that wraps a URL

var currentQueue: [URL] // or as a method

func queue(url: URL, after: URL?)

func remove(url: URL)

func playNextInQueue() // advanceToNextItem()

func stop(clearsQueue: Bool) // removeAllItems()

@rasmuslos
Copy link
Author

I literally had linked lists and queues / stacks as a topic in school about a year ago and my finals will also contain questions about them, so this is a certified smooth brain moment. I thought using the index would be simpler...

These methods would be awesome, as they would enable this library to be a more or less drop in replacement for AVQueuePlayer. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants