NAP
Public Member Functions | Public Attributes | Protected Attributes | List of all members
SequencePlayer Class Reference

#include <sequenceplayer.h>

Public Member Functions

 SequencePlayer (SequenceService &service)
 
bool init (utility::ErrorState &errorState) override
 
bool save (const std::string &name, utility::ErrorState &errorState)
 
bool load (const std::string &name, utility::ErrorState &errorState)
 
bool loadBinary (const std::vector< nap::uint8 > &buffer, utility::ErrorState &errorState)
 
void setIsPlaying (bool isPlaying)
 
void setIsPaused (bool isPaused)
 
void setIsLooping (bool isLooping)
 
void setPlayerTime (double time)
 
void setPlaybackSpeed (float speed)
 
double getPlayerTime () const
 
double getDuration () const
 
bool getIsPlaying () const
 
bool getIsLooping () const
 
bool getIsPaused () const
 
float getPlaybackSpeed () const
 
void stop () override
 
bool start (utility::ErrorState &errorState) override
 
const SequencegetSequenceConst () const
 
const std::string & getSequenceFilename () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

Signal< SequencePlayer &, float > playbackSpeedChanged
 
Signal< SequencePlayer &, double > playerTimeChanged
 
Signal< SequencePlayer &, bool > playStateChanged
 
Signal< SequencePlayer &, bool > pauseStateChanged
 
Signal< SequencePlayer & > preTick
 
Signal< SequencePlayer & > postTick
 
Signal< SequencePlayer &, std::string > sequenceLoaded
 
Signal< SequencePlayer & > edited
 
std::string mSequenceFileName
 Property: 'Default Sequence' linked default Sequence file. More...
 
bool mCreateEmptySequenceOnLoadFail = true
 Property: 'Create Sequence on Failure' when true, the init will successes upon failure of loading default sequence and create an empty sequence. More...
 
std::vector< ResourcePtr< SequencePlayerOutput > > mOutputs
 Property: 'Outputs' linked outputs. More...
 
ResourcePtr< SequencePlayerClockmClock
 Property: 'Clock' Controls timing of playback. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Attributes

Signal< std::function< void(const std::string &, std::unique_ptr< SequencePlayerAdapter >)> & > adaptersCreated
 
SequenceServicemService
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

The sequence player is responsible for loading / playing and saving a sequence The player dispatches a thread which reads the sequence. Actions for each track of the sequence are handle by SequencePlayerAdapters A Sequence can only be edited by a derived class from SequenceController and SequenceEditor Sequence Player owns all Sequence objects

Inheritance diagram for SequencePlayer:
[legend]
Collaboration diagram for SequencePlayer:
[legend]

Constructor & Destructor Documentation

◆ SequencePlayer()

Constructor used by factory

Member Function Documentation

◆ getDuration()

double getDuration ( ) const
Returns
gets sequence total duration

◆ getIsLooping()

bool getIsLooping ( ) const
Returns
are we looping?

◆ getIsPaused()

bool getIsPaused ( ) const
Returns
are we paused ?

◆ getIsPlaying()

bool getIsPlaying ( ) const
Returns
are we playing?

◆ getPlaybackSpeed()

float getPlaybackSpeed ( ) const
Returns
current playback speed

◆ getPlayerTime()

double getPlayerTime ( ) const
Returns
the current player time

◆ getSequenceConst()

const Sequence& getSequenceConst ( ) const

returns a const reference to the current sequence, not thread-safe. Only call this from the main thread

Returns
get const reference to sequence

◆ getSequenceFilename()

const std::string& getSequenceFilename ( ) const
Returns
returns current sequence filename, not thread-safe. Only call this from the main thread

◆ init()

bool init ( utility::ErrorState errorState)
overridevirtual

Evaluates the data of the player. It loads the linked default sequence. Upon failure of loading show, it can create a new default ( empty ) sequence

Parameters
errorStatecontains information about eventual failure
Returns
true if data valid

Reimplemented from Object.

◆ load()

bool load ( const std::string &  name,
utility::ErrorState errorState 
)

Load a sequence

Parameters
nameof the sequence
errorStatecontains error upon failure
Returns
true on success

◆ loadBinary()

bool loadBinary ( const std::vector< nap::uint8 > &  buffer,
utility::ErrorState errorState 
)

Load a sequence serialized as a binary blob

Parameters
bufferreference to binary data
errorStatecontains error upon failure
Returns
true on success

◆ save()

bool save ( const std::string &  name,
utility::ErrorState errorState 
)

Saves current sequence to disk

Parameters
nameof the sequence
errorStatecontains error upon failure
Returns
true on success

◆ setIsLooping()

void setIsLooping ( bool  isLooping)

Start from beginning when player reaches end of sequence

Parameters
isLoopingloop

◆ setIsPaused()

void setIsPaused ( bool  isPaused)

Pauses the player. Note that if we are still playing, adapters will still get called but time will not advance ( when paused )

Parameters
isPausedpaused

◆ setIsPlaying()

void setIsPlaying ( bool  isPlaying)

Play or stop the player. Note that player can still be paused, so adapters will be called but time will not advance

Parameters
isPlayingtrue is start playing

◆ setPlaybackSpeed()

void setPlaybackSpeed ( float  speed)

sets playback speed ( 1.0 is normal speed )

Parameters
speedspeed

◆ setPlayerTime()

void setPlayerTime ( double  time)

sets player time manually

Parameters
timethe new time

◆ start()

bool start ( utility::ErrorState errorState)
overridevirtual

starts player thread, called after successfully initialization This starts the actual player thread

Reimplemented from Device.

◆ stop()

void stop ( )
overridevirtual

called before deconstruction. This stops the actual player thread. To stop the player but NOT the player thread call setIsPlaying( false )

Reimplemented from Device.

Member Data Documentation

◆ adaptersCreated

Signal<std::function<void(const std::string&, std::unique_ptr<SequencePlayerAdapter>)>&> adaptersCreated
protected

adptersCreated Signal is triggered from main thread, after creating adapters This is useful for creating your own custom outputs & adapters for custom tracks if necessary You should do so only when writing your own player extended on SequencePlayer It passes a reference to a lambda function that you can call to add an adapter to mAdapters member of SequencePlayer

◆ edited

edited Signal is dispatched when the Sequence has been edited

◆ mClock

Property: 'Clock' Controls timing of playback.

◆ mCreateEmptySequenceOnLoadFail

bool mCreateEmptySequenceOnLoadFail = true

Property: 'Create Sequence on Failure' when true, the init will successes upon failure of loading default sequence and create an empty sequence.

◆ mOutputs

std::vector<ResourcePtr<SequencePlayerOutput> > mOutputs

Property: 'Outputs' linked outputs.

◆ mSequenceFileName

std::string mSequenceFileName

Property: 'Default Sequence' linked default Sequence file.

◆ mService

SequenceService& mService
protected

◆ pauseStateChanged

Signal<SequencePlayer&, bool> pauseStateChanged

◆ playbackSpeedChanged

Signal<SequencePlayer&, float> playbackSpeedChanged

◆ playerTimeChanged

Signal<SequencePlayer&, double> playerTimeChanged

◆ playStateChanged

Signal<SequencePlayer&, bool> playStateChanged

◆ postTick

Signal<SequencePlayer&> postTick

postTick Signal is triggered on player thread, after updating the adapters

◆ preTick

◆ sequenceLoaded

Signal<SequencePlayer&, std::string> sequenceLoaded