driver, queue: return track handle when adding an Input to the queue (#116)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user