Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SkAudioPlayer Class Referenceabstract

#include <SkAudioPlayer.h>

Public Types

enum class  State { kPlaying , kStopped , kPaused }
 

Public Member Functions

virtual ~SkAudioPlayer ()
 
double duration () const
 
double time () const
 
double setTime (double)
 
double normalizedTime () const
 
double setNormalizedTime (double t)
 
State state () const
 
float volume () const
 
float rate () const
 
State setState (State)
 
float setRate (float)
 
float setVolume (float)
 
void play ()
 
void pause ()
 
void stop ()
 
bool isPlaying () const
 
bool isPaused () const
 
bool isStopped () const
 

Static Public Member Functions

static std::unique_ptr< SkAudioPlayerMake (sk_sp< SkData >)
 

Protected Member Functions

 SkAudioPlayer ()
 
virtual double onGetDuration () const =0
 
virtual double onGetTime () const =0
 
virtual double onSetTime (double)=0
 
virtual State onSetState (State)=0
 
virtual float onSetRate (float)=0
 
virtual float onSetVolume (float)=0
 

Detailed Description

Definition at line 12 of file SkAudioPlayer.h.

Member Enumeration Documentation

◆ State

enum class SkAudioPlayer::State
strong
Enumerator
kPlaying 
kStopped 
kPaused 

Definition at line 27 of file SkAudioPlayer.h.

27 {
28 kPlaying,
29 kStopped,
30 kPaused,
31 };

Constructor & Destructor Documentation

◆ ~SkAudioPlayer()

SkAudioPlayer::~SkAudioPlayer ( )
virtual

Definition at line 12 of file SkAudioPlayer.cpp.

12{}

◆ SkAudioPlayer()

SkAudioPlayer::SkAudioPlayer ( )
inlineprotected

Definition at line 49 of file SkAudioPlayer.h.

49{} // only called by subclasses

Member Function Documentation

◆ duration()

double SkAudioPlayer::duration ( ) const
inline

Definition at line 20 of file SkAudioPlayer.h.

20{ return this->onGetDuration(); }
virtual double onGetDuration() const =0

◆ isPaused()

bool SkAudioPlayer::isPaused ( ) const
inline

Definition at line 45 of file SkAudioPlayer.h.

45{ return this->state() == State::kPaused; }
State state() const
Definition: SkAudioPlayer.h:32

◆ isPlaying()

bool SkAudioPlayer::isPlaying ( ) const
inline

Definition at line 44 of file SkAudioPlayer.h.

44{ return this->state() == State::kPlaying; }

◆ isStopped()

bool SkAudioPlayer::isStopped ( ) const
inline

Definition at line 46 of file SkAudioPlayer.h.

46{ return this->state() == State::kStopped; }

◆ Make()

std::unique_ptr< SkAudioPlayer > SkAudioPlayer::Make ( sk_sp< SkData src)
static

Definition at line 11 of file SkAudioPlayer_none.cpp.

11 {
12 return nullptr;
13}

◆ normalizedTime()

double SkAudioPlayer::normalizedTime ( ) const
inline

Definition at line 24 of file SkAudioPlayer.h.

24{ return this->time() / this->duration(); }
double time() const
Definition: SkAudioPlayer.h:21
double duration() const
Definition: SkAudioPlayer.h:20

◆ onGetDuration()

virtual double SkAudioPlayer::onGetDuration ( ) const
protectedpure virtual

◆ onGetTime()

virtual double SkAudioPlayer::onGetTime ( ) const
protectedpure virtual

◆ onSetRate()

virtual float SkAudioPlayer::onSetRate ( float  )
protectedpure virtual

◆ onSetState()

virtual State SkAudioPlayer::onSetState ( State  )
protectedpure virtual

◆ onSetTime()

virtual double SkAudioPlayer::onSetTime ( double  )
protectedpure virtual

◆ onSetVolume()

virtual float SkAudioPlayer::onSetVolume ( float  )
protectedpure virtual

◆ pause()

void SkAudioPlayer::pause ( )
inline

Definition at line 41 of file SkAudioPlayer.h.

41{ this->setState(State::kPaused); }
State setState(State)

◆ play()

void SkAudioPlayer::play ( )
inline

Definition at line 40 of file SkAudioPlayer.h.

40{ this->setState(State::kPlaying); }

◆ rate()

float SkAudioPlayer::rate ( ) const
inline

Definition at line 34 of file SkAudioPlayer.h.

34{ return fRate; } // multiplier (e.g. 1.0 is default)

◆ setNormalizedTime()

double SkAudioPlayer::setNormalizedTime ( double  t)

Definition at line 25 of file SkAudioPlayer.cpp.

25 {
26 this->setTime(t * this->duration());
27 return this->normalizedTime();
28}
double setTime(double)
double normalizedTime() const
Definition: SkAudioPlayer.h:24

◆ setRate()

float SkAudioPlayer::setRate ( float  r)

Definition at line 37 of file SkAudioPlayer.cpp.

37 {
38 r = std::min(std::max(r, 0.f), 1.f);
39 if (!std::isfinite(r)) {
40 r = fRate;
41 }
42 if (r != fRate) {
43 fRate = this->onSetRate(r);
44 }
45 return fRate;
46}
virtual float onSetRate(float)=0
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003

◆ setState()

SkAudioPlayer::State SkAudioPlayer::setState ( State  s)

Definition at line 30 of file SkAudioPlayer.cpp.

30 {
31 if (s != fState) {
32 fState = this->onSetState(s);
33 }
34 return fState;
35}
virtual State onSetState(State)=0
struct MyStruct s

◆ setTime()

double SkAudioPlayer::setTime ( double  t)

Definition at line 14 of file SkAudioPlayer.cpp.

14 {
15 t = std::min(std::max(t, 0.0), this->duration());
16 if (!std::isfinite(t)) {
17 t = this->time();
18 }
19 if (t != this->time()) {
20 t = this->onSetTime(t);
21 }
22 return t;
23}
virtual double onSetTime(double)=0

◆ setVolume()

float SkAudioPlayer::setVolume ( float  v)

Definition at line 48 of file SkAudioPlayer.cpp.

48 {
49 v = std::min(std::max(v, 0.f), 1.f);
50 if (!std::isfinite(v)) {
51 v = fVolume;
52 }
53 if (v != fVolume) {
54 fVolume = this->onSetVolume(v);
55 }
56 return fVolume;
57}
virtual float onSetVolume(float)=0

◆ state()

State SkAudioPlayer::state ( ) const
inline

Definition at line 32 of file SkAudioPlayer.h.

32{ return fState; }

◆ stop()

void SkAudioPlayer::stop ( )
inline

Definition at line 42 of file SkAudioPlayer.h.

42{ this->setState(State::kStopped); }

◆ time()

double SkAudioPlayer::time ( ) const
inline

Definition at line 21 of file SkAudioPlayer.h.

21{ return this->onGetTime(); } // 0...duration()
virtual double onGetTime() const =0

◆ volume()

float SkAudioPlayer::volume ( ) const
inline

Definition at line 33 of file SkAudioPlayer.h.

33{ return fVolume; } // 0...1

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