Tracks: Allow custom UUID setting (#33)
This commit is contained in:
@@ -24,8 +24,8 @@ pub struct TrackHandle {
|
||||
struct InnerHandle {
|
||||
command_channel: UnboundedSender<TrackCommand>,
|
||||
seekable: bool,
|
||||
uuid: Uuid,
|
||||
metadata: Box<Metadata>,
|
||||
uuid: Uuid,
|
||||
}
|
||||
|
||||
impl TrackHandle {
|
||||
@@ -42,8 +42,8 @@ impl TrackHandle {
|
||||
let inner = Arc::new(InnerHandle {
|
||||
command_channel,
|
||||
seekable,
|
||||
uuid,
|
||||
metadata,
|
||||
uuid,
|
||||
});
|
||||
|
||||
Self { inner }
|
||||
|
||||
@@ -377,11 +377,19 @@ impl Track {
|
||||
///
|
||||
/// [`Track`]: Track
|
||||
/// [`TrackHandle`]: TrackHandle
|
||||
#[inline]
|
||||
pub fn create_player(source: Input) -> (Track, TrackHandle) {
|
||||
create_player_with_uuid(source, Uuid::new_v4())
|
||||
}
|
||||
|
||||
/// Refer to the documentation for [`create_player`] however, allows for a custom uuid to be inserted into the Track and Handle
|
||||
///
|
||||
/// [`create_player`]: create_player
|
||||
pub fn create_player_with_uuid(source: Input, uuid: Uuid) -> (Track, TrackHandle) {
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
let can_seek = source.is_seekable();
|
||||
let metadata = source.metadata.clone();
|
||||
let handle = TrackHandle::new(tx, can_seek, Uuid::new_v4(), metadata);
|
||||
let handle = TrackHandle::new(tx, can_seek, uuid, metadata);
|
||||
|
||||
let player = Track::new_raw(source, rx, handle.clone());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user