pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Attributes | List of all members
Media::PlayerWrapper Class Reference

The Player class is abstract, and is implemented several different ways (ffmpeg, gstreamer, AVFoundation...). More...

#include <playerwrapper.h>

Inheritance diagram for Media::PlayerWrapper:
Inheritance graph
[legend]
Collaboration diagram for Media::PlayerWrapper:
Collaboration graph
[legend]

Public Member Functions

 PlayerWrapper (Player *)
 
 PlayerWrapper (std::unique_ptr< Player > &&)
 
virtual void pause (void) override
 Pause playback. If already paused, do nothing. More...
 
virtual void abort (void) override
 Don't play the rest of the song. More...
 
virtual void setVolume (float volume) override
 Adjust volume in decibels. More...
 
virtual void cue (void) override
 Starts thread in paused mode. More...
 
virtual void play (void) override
 Start playback or resume playback if paused. If already playing, continue. More...
 
virtual float trackDuration (void) const override
 Length of track in seconds, or a negative number if unknown. More...
 
virtual float playPoint (void) const override
 Seconds from start, or a negative value if unknown. More...
 
virtual float playRemaining (void) const override
 Seconds left in playback, or a negative number if unknown. More...
 
virtual RESPONSE_CODE completionStatus (void) override
 
virtual State currentState (void) const override
 
virtual time_t getPauseTimeout (void) override
 When paused, get the time at which the song will expire. More...
 
- Public Member Functions inherited from Media::Player
virtual ~Player (void)
 
bool ready (void) const
 Indicate if player has finished initializing. More...
 
bool playbackComplete (void) const
 Indicate if playback is complete and ready for cleanup. More...
 

Private Attributes

std::unique_ptr< Playerinherited
 

Additional Inherited Members

- Public Types inherited from Media::Player
enum  State {
  DoesNotExist , Initializing , Cueing , Playing ,
  Done
}
 
- Static Public Member Functions inherited from Media::Player
static Media::PlayergetPlayer (const AudioSettings &settings, const std::string &media_url, float initial_gain)
 Get the a media player currently compiled in the code. More...
 

Detailed Description

The Player class is abstract, and is implemented several different ways (ffmpeg, gstreamer, AVFoundation...).

Exactly what's in use is blackboxed from the sources, but that isolation also means we can't specialize them through inheritance. Losing the encapsulation would create a maintenance nightmare.

We could add some delegates, but that also means repeated implementations in each of the different player types.

So, we have this stupid wrapper. It's the least of the bad choices. It accepts a player instance, and simply forwards every request onto the player. A source that wants to customize, can wrap its player in a wrapper that's been specialized to its needs.

Constructor & Destructor Documentation

◆ PlayerWrapper() [1/2]

Media::PlayerWrapper::PlayerWrapper ( Player player)

◆ PlayerWrapper() [2/2]

Media::PlayerWrapper::PlayerWrapper ( std::unique_ptr< Player > &&  player)

Member Function Documentation

◆ abort()

void Media::PlayerWrapper::abort ( void  )
overridevirtual

Don't play the rest of the song.

Implements Media::Player.

◆ completionStatus()

RESPONSE_CODE Media::PlayerWrapper::completionStatus ( void  )
overridevirtual

Implements Media::Player.

◆ cue()

void Media::PlayerWrapper::cue ( void  )
overridevirtual

Starts thread in paused mode.

Implements Media::Player.

◆ currentState()

Player::State Media::PlayerWrapper::currentState ( void  ) const
overridevirtual

Implements Media::Player.

◆ getPauseTimeout()

time_t Media::PlayerWrapper::getPauseTimeout ( void  )
overridevirtual

When paused, get the time at which the song will expire.

Reimplemented from Media::Player.

◆ pause()

void Media::PlayerWrapper::pause ( void  )
overridevirtual

Pause playback. If already paused, do nothing.

Implements Media::Player.

◆ play()

void Media::PlayerWrapper::play ( void  )
overridevirtual

Start playback or resume playback if paused. If already playing, continue.

Implements Media::Player.

◆ playPoint()

float Media::PlayerWrapper::playPoint ( void  ) const
overridevirtual

Seconds from start, or a negative value if unknown.

Implements Media::Player.

◆ playRemaining()

float Media::PlayerWrapper::playRemaining ( void  ) const
overridevirtual

Seconds left in playback, or a negative number if unknown.

Determine the length of track remaining to play.

Returns
The length in seconds, floating point, or a negative number if the value could not be ascertained.
Note
Although it "shouldn't" happen, return value may also be negative if actual playpoint exceeds expected duration, which can happen if ID3 data is wrong, encoding is wrong, etc.

Reimplemented from Media::Player.

◆ setVolume()

void Media::PlayerWrapper::setVolume ( float  volume)
overridevirtual

Adjust volume in decibels.

Implements Media::Player.

◆ trackDuration()

float Media::PlayerWrapper::trackDuration ( void  ) const
overridevirtual

Length of track in seconds, or a negative number if unknown.

Implements Media::Player.

Member Data Documentation

◆ inherited

std::unique_ptr<Player> Media::PlayerWrapper::inherited
private

The documentation for this class was generated from the following files: