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.
|
/// Requires the `"builtin-queue"` feature.
|
||||||
///
|
///
|
||||||
/// [`Input`]: crate::input::Input
|
/// [`Input`]: crate::input::Input
|
||||||
pub fn enqueue_source(&mut self, source: Input) {
|
pub fn enqueue_source(&mut self, source: Input) -> TrackHandle {
|
||||||
let (mut track, _) = tracks::create_player(source);
|
let (track, handle) = tracks::create_player(source);
|
||||||
self.queue.add_raw(&mut track);
|
self.enqueue(track);
|
||||||
self.play(track);
|
|
||||||
|
handle
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an existing [`Track`] to this driver's built-in queue.
|
/// 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`.
|
/// 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) {
|
pub fn add_source(&self, source: Input, handler: &mut Driver) -> TrackHandle {
|
||||||
let (audio, _) = tracks::create_player(source);
|
let (track, handle) = tracks::create_player(source);
|
||||||
self.add(audio, handler);
|
self.add(track, handler);
|
||||||
|
|
||||||
|
handle
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a [`Track`] object to the queue, to be played in the channel managed by `handler`.
|
/// Adds a [`Track`] object to the queue, to be played in the channel managed by `handler`.
|
||||||
|
|||||||
Reference in New Issue
Block a user