GeneralPlayer

Struct GeneralPlayer 

Source
pub struct GeneralPlayer {
    pub backend: Backend,
    pub playlist: SharedPlaylist,
    pub config: SharedServerSettings,
    pub current_track_updated: bool,
    pub mpris: Option<Mpris>,
    pub discord: Option<Rpc>,
    pub db: Database,
    pub db_podcast: Database,
    pub cmd_tx: PlayerCmdSender,
    pub stream_tx: StreamTX,
    pub errors_since_last_progress: usize,
}

Fields§

§backend: Backend§playlist: SharedPlaylist§config: SharedServerSettings§current_track_updated: bool§mpris: Option<Mpris>§discord: Option<Rpc>§db: Database§db_podcast: Database§cmd_tx: PlayerCmdSender§stream_tx: StreamTX§errors_since_last_progress: usize

Keep track of continues backend errors (like NotFound) to not keep trying infinitely.

Implementations§

Source§

impl GeneralPlayer

Source

pub fn mpris_handler(&mut self, e: MediaControlEvent)

Source

pub fn mpris_handle_events(&mut self)

Handle Media-Controls events, if enabled to be used

Source

pub fn mpris_update_progress(&mut self, progress: &PlayerProgress)

Update Media-Controls reported Position & Status, if enabled to be reporting

Source

pub fn mpris_volume_update(&mut self)

Update Media-Controls reported volume, if enabled to be reporting

Source§

impl GeneralPlayer

Source

pub fn new_backend( backend: BackendSelect, config: SharedServerSettings, cmd_tx: PlayerCmdSender, stream_tx: StreamTX, playlist: SharedPlaylist, ) -> Result<Self>

Create a new GeneralPlayer, with the selected backend

§Errors
  • if connecting to the database fails
  • if config path creation fails
Source

pub fn increment_errors(&mut self)

Increment the errors that happened by one.

Source

pub fn reset_errors(&mut self)

Reset errors that happened back to 0

Source

pub fn new( config: SharedServerSettings, cmd_tx: PlayerCmdSender, stream_tx: StreamTX, playlist: SharedPlaylist, ) -> Result<Self>

Create a new GeneralPlayer, with the default Backend (BackendSelect::Rusty)

§Errors
  • if connecting to the database fails
  • if config path creation fails
Source

pub fn reload_config(&mut self) -> Result<()>

Reload the config from file, on fail continue to use the old

§Errors
  • if Config could not be parsed
Source

pub fn toggle_gapless(&mut self) -> bool

Source

pub fn start_play(&mut self)

Requires that the function is called on a thread with a entered tokio runtime

§Panics

if current_track_index in playlist is above u32

Source

pub fn metadata_changed(&mut self)

Handle PlayerCmd::MetadataChanged for all things the GeneralPlayer controls.

Source

pub fn enqueue_next_from_playlist(&mut self)

Source

pub fn next(&mut self)

Skip to the next track, if there is one

Source

pub fn previous(&mut self)

Switch & Play the previous track in the playlist

Source

pub fn toggle_pause(&mut self)

Resume playback if paused, pause playback if running

Source

pub fn pause(&mut self)

Pause playback if running

Source

pub fn play(&mut self)

Resume playback if paused

Source

pub fn seek_relative(&mut self, forward: bool)

§Panics

if the underlying “seek” returns a error (which current never happens)

Source

pub fn player_save_last_position(&mut self)

Source

pub fn player_restore_last_position(&mut self)

Source

pub fn update_progress(&mut self, progress: &PlayerProgress)

Update all the places that should be updated on a new Progress report.

Trait Implementations§

Source§

impl PlayerTrait for GeneralPlayer

Source§

fn pause(&mut self)

This function should not be used directly, use GeneralPlayer::pause

Source§

fn resume(&mut self)

This function should not be used directly, use GeneralPlayer::play

Source§

fn add_and_play<'life0, 'life1, 'async_trait>( &'life0 mut self, track: &'life1 Track, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add the given track, skip to it (if not already) and start playing
Source§

fn volume(&self) -> Volume

Get the currently set volume
Source§

fn add_volume(&mut self, volume: VolumeSigned) -> Volume

Add a relative amount to the current volume Read more
Source§

fn set_volume(&mut self, volume: Volume) -> Volume

Set the volume to a specific amount. Read more
Source§

fn is_paused(&self) -> bool

Source§

fn seek(&mut self, secs: i64) -> Result<()>

Seek relatively to the current time Read more
Source§

fn seek_to(&mut self, position: Duration)

Seek to a absolute position
Source§

fn set_speed(&mut self, speed: Speed) -> Speed

Set the speed to a specific amount. Read more
Source§

fn add_speed(&mut self, speed: SpeedSigned) -> Speed

Add a relative amount to the current speed Read more
Source§

fn speed(&self) -> Speed

Get the currently set speed
Source§

fn stop(&mut self)

Source§

fn get_progress(&self) -> Option<PlayerProgress>

Get current track time position
Source§

fn gapless(&self) -> bool

Source§

fn set_gapless(&mut self, to: bool)

Source§

fn skip_one(&mut self)

Source§

fn position(&self) -> Option<PlayerTimeUnit>

Quickly access the position. Read more
Source§

fn enqueue_next(&mut self, track: &Track)

Add the given URI to be played, but do not skip currently playing track
Source§

fn media_info(&self) -> MediaInfo

Get info of the current media

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,