Skip to content

Commit

Permalink
Docs: Fix module docs for songbird::tracks.
Browse files Browse the repository at this point in the history
Module docs mistakenly used the old doc-link format, so removing `create_player` never fired an error! These have also been partially rewritten to explain the role of `Track` and `TrackHandle`.

Includes some other misc fixes to links, mention of `TrackHandle::action` for metadata handling, etc.

Closes #140.
  • Loading branch information
FelixMcFelix committed Nov 20, 2023
1 parent d8061d5 commit c1d93f7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![docs-badge][]][docs] [![build badge]][build] [![guild-badge][]][guild] [![crates.io version]][crates.io link] [![rust 1.61.0+ badge]][rust 1.61.0+ link]
[![docs-badge][]][docs] [![next-docs-badge][]][next-docs] [![build badge]][build] [![guild-badge][]][guild] [![crates.io version]][crates.io link] [![rust 1.61.0+ badge]][rust 1.61.0+ link]

# Songbird

Expand Down Expand Up @@ -86,9 +86,12 @@ Songbird's logo is based upon the copyright-free image ["Black-Capped Chickadee"
[build badge]: https://img.shields.io/github/workflow/status/serenity-rs/songbird/CI?style=flat-square
[build]: https://github.com/serenity-rs/songbird/actions

[docs-badge]: https://img.shields.io/badge/docs-online-4d76ae.svg?style=flat-square
[docs-badge]: https://img.shields.io/badge/docs-current-4d76ae.svg?style=flat-square
[docs]: https://serenity-rs.github.io/songbird/current

[next-docs-badge]: https://img.shields.io/badge/docs-next-4d76ae.svg?style=flat-square
[next-docs]: https://serenity-rs.github.io/songbird/next

[guild]: https://discord.gg/9X7vCus
[guild-badge]: https://img.shields.io/discord/381880193251409931.svg?style=flat-square&colorB=7289DA

Expand Down
2 changes: 2 additions & 0 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ use tokio::runtime::Handle as TokioHandle;
///
/// // If we want to inspect metadata (and we can't use AuxMetadata for any reason), we have
/// // to parse the track ourselves.
/// //
/// // We can access it on a live track using `TrackHandle::action()`.
/// in_memory_input = in_memory_input
/// .make_playable_async(&CODEC_REGISTRY, &PROBE)
/// .await
Expand Down
4 changes: 2 additions & 2 deletions src/serenity.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Compatability and convenience methods for working with [serenity].
//! Compatibility and convenience methods for working with [serenity].
//! Requires the `"serenity"` feature.
//!
//! [serenity]: https://crates.io/crates/serenity/0.9.0-rc.2
//! [serenity]: https://crates.io/crates/serenity

use crate::{Config, Songbird};
use serenity::{
Expand Down
2 changes: 0 additions & 2 deletions src/tracks/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use uuid::Uuid;
/// Many method calls here are fallible; in most cases, this will be because
/// the underlying [`Track`] object has been discarded. Those which aren't refer
/// to shared data not used by the driver.
///
/// [`Track`]: Track
pub struct TrackHandle {
inner: Arc<InnerHandle>,
}
Expand Down
30 changes: 15 additions & 15 deletions src/tracks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
//! Live, controllable audio instances.
//!
//! Tracks add control and event data around the bytestreams offered by [`Input`],
//! where each represents a live audio source inside of the driver's mixer.
//! where each represents a live audio source inside of the driver's mixer. This includes
//! play state, volume, and looping behaviour.
//!
//! To prevent locking and stalling of the driver, tracks are controlled from your bot using a
//! [`TrackHandle`]. These handles remotely send commands from your bot's (a)sync
//! context to control playback, register events, and execute synchronous closures.
//! To configure an audio source as it is created, you can create a [`Track`] to set the
//! above playback state [from any `Input` or `T: Into<Input>`](Track#trait-implementations)
//! using `Track::from(...)`.
//!
//! If you want a new track from an [`Input`], i.e., for direct control before
//! playing your source on the driver, use [`create_player`].
//! To configure an audio source once it has been given to a [`Driver`], you are given a
//! [`TrackHandle`] once you hand the [`Input`] and state over to be played. These handles
//! remotely send commands from your bot's (a)sync context to control playback, register events,
//! and execute synchronous closures. This design prevents user code from being able to lock
//! or stall the audio mixer.
//!
//! [`Input`]: ../input/struct.Input.html
//! [`TrackHandle`]: struct.TrackHandle.html
//! [`create_player`]: fn.create_player.html
//! [`Driver`]: crate::driver::Driver

mod action;
mod command;
Expand Down Expand Up @@ -47,23 +49,21 @@ use uuid::Uuid;
/// [`Track`]s allow you to configure play modes, volume, event handlers, and other track state
/// before you pass an input to the [`Driver`].
///
/// Live track data is accesseed via a [`TrackHandle`], returned by [`Driver::play`] and
/// Live track data is accessed via a [`TrackHandle`], which is returned by [`Driver::play`] and
/// related methods.
///
/// # Example
///
/// ```rust,no_run
/// use songbird::{driver::Driver, input::File, tracks::Track};
///
/// # async {
/// // A Call is also valid here!
/// let mut handler: Driver = Default::default();
/// let mut driver: Driver = Default::default();
/// let source = File::new("../audio/my-favourite-song.mp3");
///
/// handler.play_only(Track::new(source.into()).volume(0.5));
/// let handle = driver.play_only(Track::from(source).volume(0.5));
///
/// // Future access occurs via audio_handle.
/// # };
/// // Future access occurs via audio.
/// ```
///
/// [`Driver`]: crate::driver::Driver
Expand Down

0 comments on commit c1d93f7

Please sign in to comment.