pub struct Song {
pub id: u64,
pub title: String,
pub album: Option<String>,
pub artist: Option<String>,
pub track: Option<u64>,
pub year: Option<u64>,
pub genre: Option<String>,
pub size: u64,
pub duration: Option<u64>,
/* private fields */
}
Expand description
A work of music contained on a Subsonic server.
Fields
id: u64
Unique identifier for the song.
title: String
Title of the song. Prefers the song’s ID3 tags, but will fall back to the file name.
album: Option<String>
Album the song belongs to. Reads from the song’s ID3 tags.
artist: Option<String>
Credited artist for the song. Reads from the song’s ID3 tags.
track: Option<u64>
Position of the song in the album.
year: Option<u64>
Year the song was released.
genre: Option<String>
Genre of the song.
size: u64
File size of the song, in bytes.
duration: Option<u64>
Duration of the song, in seconds.
Implementations
sourceimpl Song
impl Song
sourcepub fn get(client: &Client, id: u64) -> Result<Song>
pub fn get(client: &Client, id: u64) -> Result<Song>
Returns a single song from the Subsonic server.
Errors
Aside from other errors the Client
may cause, the server will return
an error if there is no song matching the provided ID.
sourcepub fn similar<U>(&self, client: &Client, count: U) -> Result<Vec<Song>>where
U: Into<Option<usize>>,
pub fn similar<U>(&self, client: &Client, count: U) -> Result<Vec<Song>>where
U: Into<Option<usize>>,
Returns a number of random songs similar to this one.
last.fm suggests a number of similar songs to the one the method is
called on. Optionally takes a count
to specify the maximum number of
results to return.
sourcepub fn random<U>(client: &Client, size: U) -> Result<Vec<Song>>where
U: Into<Option<usize>>,
pub fn random<U>(client: &Client, size: U) -> Result<Vec<Song>>where
U: Into<Option<usize>>,
Returns a number of random songs. Optionally accepts a maximum number of results to return.
Some parts of the query can be modified. Use random_with
to be able
to set these optional fields.
sourcepub fn random_with<'a>(client: &Client) -> RandomSongs<'_>
pub fn random_with<'a>(client: &Client) -> RandomSongs<'_>
Creates a new builder to request a set of random songs.
See the struct level documentation for more information on how to use the builder.
sourcepub fn list_in_genre<U>(
client: &Client,
genre: &str,
page: SearchPage,
folder_id: U
) -> Result<Vec<Song>>where
U: Into<Option<u64>>,
pub fn list_in_genre<U>(
client: &Client,
genre: &str,
page: SearchPage,
folder_id: U
) -> Result<Vec<Song>>where
U: Into<Option<u64>>,
Lists all the songs in a provided genre. Supports paging through the result.
See the struct level documentation about paging for more.
sourcepub fn hls(&self, client: &Client, bit_rates: &[u64]) -> Result<HlsPlaylist>
pub fn hls(&self, client: &Client, bit_rates: &[u64]) -> Result<HlsPlaylist>
Creates an HLS (HTTP Live Streaming) playlist used for streaming video or audio. HLS is a streaming protocol implemented by Apple and works by breaking the overall stream into a sequence of small HTTP-based file downloads. It’s supported by iOS and newer versions of Android.
Returns an M3U8 playlist on success (content type “application/vnd.apple.mpegurl”).
The method also supports adaptive streaming; when supplied with multiple
bit rates, the server will create a variable playlist, suitable for
adaptive bitrate streaming. The playlist will support streaming at all
the specified bitrates. The bit_rate
parameter can be omitted (with an
empty array) to disable adaptive streaming, or given a single value to
force streaming at that bit rate.