driver, queue: return track handle when adding an Input to the queue (#116)

This commit is contained in:
Jan
2022-03-08 00:58:21 +01:00
committed by Kyle Simpson
parent ac20764157
commit bacf681465
2 changed files with 10 additions and 7 deletions

View File

@@ -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.

View File

@@ -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`.