Ocean
Loading...
Searching...
No Matches
AVFAudio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_MEDIA_AVF_AUDIO_H
9#define META_OCEAN_MEDIA_AVF_AUDIO_H
10
13
14#include "ocean/base/Callback.h"
15
16#include "ocean/media/Audio.h"
17
18/**
19 * Delegate for audio playing events.
20 */
22@end
23
24namespace Ocean
25{
26
27namespace Media
28{
29
30namespace AVFoundation
31{
32
33/**
34 * This class implements an AVFoundation audio object.
35 * @ingroup mediaavf
36 */
37class AVFAudio :
38 virtual public AVFMedium,
39 virtual public Audio
40{
41 friend class AVFLibrary;
42
43 public:
44
45 /**
46 * Definition of a callback function for finished playing.
47 */
49
50 public:
51
52 /**
53 * Clones this movie medium and returns a new independent instance of this medium.
54 * @see Medium::clone()
55 */
56 MediumRef clone() const override;
57
58 /**
59 * Returns the duration of the movie medium.
60 * @see FiniteMedium::duration()
61 */
62 double duration() const override;
63
64 /**
65 * Returns the duration of the movie medium without speed consideration.
66 * @see FiniteMedium::normalDuration()
67 */
68 double normalDuration() const override;
69
70 /**
71 * Returns the recent position of the movie medium.
72 * @see FiniteMedium::position()
73 */
74 double position() const override;
75
76 /**
77 * Sets the recent position of the movie medium.
78 * @see FiniteMedium::setPosition()
79 */
80 bool setPosition(const double position) override;
81
82 /**
83 * Returns the speed of the movie medium.
84 * @see FiniteMedium::speed()
85 */
86 float speed() const override;
87
88 /**
89 * Sets the speed of the movie medium.
90 * @see FiniteMedium::setSpeed()
91 */
92 bool setSpeed(const float speed) override;
93
94 /**
95 * Sets whether the medium has to be played in a loop.
96 * @see FiniteMedium::setLoop().
97 */
98 bool setLoop(const bool value) override;
99
100 /**
101 * Returns the volume of the sound in db.
102 * @see SoundMedium::soundVolume()
103 */
104 float soundVolume() const override;
105
106 /**
107 * Returns whether the movie medium is in a mute state.
108 * @see SoundMedium::soundMute()
109 */
110 bool soundMute() const override;
111
112 /**
113 * Sets the volume of the sound in db.
114 * @see SoundMedium::setSoundVolume()
115 */
116 bool setSoundVolume(const float volume) override;
117
118 /**
119 * Sets or unsets the movie medium to a mute state.
120 * @see SoundMedium::setSoundMute()
121 */
122 bool setSoundMute(const bool mute) override;
123
124 protected:
125
126 /**
127 * Creates a new audio by a given url.
128 * @param url Url of the audio
129 */
130 explicit AVFAudio(const std::string& url);
131
132 /**
133 * Destructs a AVFMovie object.
134 */
135 ~AVFAudio() override;
136
137 /**
138 * Internally starts the medium.
139 * @see AVFMedium::internalStart()
140 */
141 bool internalStart() override;
142
143 /**
144 * Internally pauses the medium.
145 * @see AVFMedium::internalPause()
146 */
147 bool internalPause() override;
148
149 /**
150 * Internally stops the medium.
151 * @see AVFMedium::internalStop()
152 */
153 bool internalStop() override;
154
155 /**
156 * Event function for
157 */
159
160 protected:
161
162 /// The actual audio player.
163 AVAudioPlayer* avAudioPlayer_ = nullptr;
164
165 /// The delegate for audio playing events.
166 OceanMediaAVFAudioAVAudioPlayerDelegate* oceanMediaAVFAudioAVAudioPlayerDelegate_ = nullptr;
167
168 /// The volume before mute, -1 if invalid.
169 float volumeBeforeMute_ = -1.0f;
170};
171
172}
173
174}
175
176}
177
178#endif // META_OCEAN_MEDIA_AVF_AUDIO_H
This class implements a container for callback functions.
Definition Callback.h:3456
This class implements an AVFoundation audio object.
Definition AVFAudio.h:40
double normalDuration() const override
Returns the duration of the movie medium without speed consideration.
double duration() const override
Returns the duration of the movie medium.
bool soundMute() const override
Returns whether the movie medium is in a mute state.
bool setSoundVolume(const float volume) override
Sets the volume of the sound in db.
float soundVolume() const override
Returns the volume of the sound in db.
double position() const override
Returns the recent position of the movie medium.
float speed() const override
Returns the speed of the movie medium.
MediumRef clone() const override
Clones this movie medium and returns a new independent instance of this medium.
void onFinishedPlaying()
Event function for.
bool setSoundMute(const bool mute) override
Sets or unsets the movie medium to a mute state.
bool internalPause() override
Internally pauses the medium.
~AVFAudio() override
Destructs a AVFMovie object.
bool internalStop() override
Internally stops the medium.
bool setPosition(const double position) override
Sets the recent position of the movie medium.
bool setSpeed(const float speed) override
Sets the speed of the movie medium.
Callback< void > FinishedPlayingCallback
Definition of a callback function for finished playing.
Definition AVFAudio.h:48
bool internalStart() override
Internally starts the medium.
bool setLoop(const bool value) override
Sets whether the medium has to be played in a loop.
AVFAudio(const std::string &url)
Creates a new audio by a given url.
This class implements the AVFoundation library.
Definition AVFLibrary.h:32
This is the base class for all AVFoundation mediums.
Definition AVFMedium.h:36
This class is the base class for all audio mediums.
Definition Audio.h:38
Delegate for audio playing events.
Definition AVFAudio.h:21
The namespace covering the entire Ocean framework.
Definition Accessor.h:15