Skip to content

Commit

Permalink
driver, queue: return track handle when adding an Input to the queue (
Browse files Browse the repository at this point in the history
  • Loading branch information
vaporoxx authored and FelixMcFelix committed Jul 22, 2022
1 parent ac20764 commit bacf681
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,11 @@ impl Driver {
/// Requires the `"builtin-queue"` feature.
///
/// [`Input`]: crate::input::Input
pub fn enqueue_source(&mut self, source: Input) {
let (mut track, _) = tracks::create_player(source);
self.queue.add_raw(&mut track);
self.play(track);
pub fn enqueue_source(&mut self, source: Input) -> TrackHandle {
let (track, handle) = tracks::create_player(source);
self.enqueue(track);

handle
}

/// Adds an existing [`Track`] to this driver's built-in queue.
Expand Down
8 changes: 5 additions & 3 deletions src/tracks/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ impl TrackQueue {
}

/// Adds an audio source to the queue, to be played in the channel managed by `handler`.
pub fn add_source(&self, source: Input, handler: &mut Driver) {
let (audio, _) = tracks::create_player(source);
self.add(audio, handler);
pub fn add_source(&self, source: Input, handler: &mut Driver) -> TrackHandle {
let (track, handle) = tracks::create_player(source);
self.add(track, handler);

handle
}

/// Adds a [`Track`] object to the queue, to be played in the channel managed by `handler`.
Expand Down

0 comments on commit bacf681

Please sign in to comment.