Trait bliss_audio::Library[][src]

pub trait Library {
    fn get_songs_paths(&self) -> Result<Vec<String>, BlissError>;
fn store_song(&mut self, song: &Song) -> Result<(), BlissError>;
fn store_error_song(
        &mut self,
        song_path: String,
        error: BlissError
    ) -> Result<(), BlissError>;
fn get_stored_songs(&self) -> Result<Vec<Song>, BlissError>; fn playlist_from_song(
        &self,
        first_song: Song,
        playlist_length: usize
    ) -> Result<Vec<Song>, BlissError> { ... }
fn analyze_paths(&mut self, paths: Vec<String>) -> Result<(), BlissError> { ... }
fn analyze_library(&mut self) -> Result<(), BlissError> { ... } }
Expand description

Library trait to make creating plug-ins for existing audio players easier.

Required methods

Return the absolute path of all the songs in an audio player’s music library.

Store an analyzed Song object in some (cold) storage, e.g. a database, a file…

Log and / or store that an error happened while trying to decode and analyze a song.

Retrieve a list of all the stored Songs.

This should work only after having run analyze_library at least once.

Provided methods

Return a list of songs that are similar to first_song.

Arguments

  • first_song - The song the playlist will be built from.
  • playlist_length - The playlist length. If there are not enough songs in the library, it will be truncated to the size of the library.

Returns

A vector of playlist_length Songs, including first_song, that you most likely want to plug in your audio player by using something like ret.map(|song| song.path.to_owned()).collect::<Vec<String>>().

Analyze and store songs in paths, using store_song and store_error_song implementations.

Note: this is mostly useful for updating a song library. For the first run, you probably want to use analyze_library.

Analyzes a song library, using get_songs_paths, store_song and store_error_song implementations.

Implementors