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
11
#include "
ocean/media/avfoundation/AVFoundation.h
"
12
#include "
ocean/media/avfoundation/AVFMedium.h
"
13
14
#include "
ocean/base/Callback.h
"
15
16
#include "
ocean/media/Audio.h
"
17
18
/**
19
* Delegate for audio playing events.
20
*/
21
@interface
OceanMediaAVFAudioAVAudioPlayerDelegate
:
NSObject
<
AVAudioPlayerDelegate
>
22
@end
23
24
namespace
Ocean
25
{
26
27
namespace
Media
28
{
29
30
namespace
AVFoundation
31
{
32
33
/**
34
* This class implements an AVFoundation audio object.
35
* @ingroup mediaavf
36
*/
37
class
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
*/
48
using
FinishedPlayingCallback
=
Callback<void>
;
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
*/
158
void
onFinishedPlaying
();
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
AVFMedium.h
AVFoundation.h
Audio.h
Callback.h
AVAudioPlayerDelegate-p
NSObject
Ocean::Callback< void >
Ocean::Media::AVFoundation::AVFAudio
This class implements an AVFoundation audio object.
Definition
AVFAudio.h:40
Ocean::Media::AVFoundation::AVFAudio::normalDuration
double normalDuration() const override
Returns the duration of the movie medium without speed consideration.
Ocean::Media::AVFoundation::AVFAudio::duration
double duration() const override
Returns the duration of the movie medium.
Ocean::Media::AVFoundation::AVFAudio::soundMute
bool soundMute() const override
Returns whether the movie medium is in a mute state.
Ocean::Media::AVFoundation::AVFAudio::setSoundVolume
bool setSoundVolume(const float volume) override
Sets the volume of the sound in db.
Ocean::Media::AVFoundation::AVFAudio::soundVolume
float soundVolume() const override
Returns the volume of the sound in db.
Ocean::Media::AVFoundation::AVFAudio::position
double position() const override
Returns the recent position of the movie medium.
Ocean::Media::AVFoundation::AVFAudio::speed
float speed() const override
Returns the speed of the movie medium.
Ocean::Media::AVFoundation::AVFAudio::clone
MediumRef clone() const override
Clones this movie medium and returns a new independent instance of this medium.
Ocean::Media::AVFoundation::AVFAudio::onFinishedPlaying
void onFinishedPlaying()
Event function for.
Ocean::Media::AVFoundation::AVFAudio::setSoundMute
bool setSoundMute(const bool mute) override
Sets or unsets the movie medium to a mute state.
Ocean::Media::AVFoundation::AVFAudio::internalPause
bool internalPause() override
Internally pauses the medium.
Ocean::Media::AVFoundation::AVFAudio::~AVFAudio
~AVFAudio() override
Destructs a AVFMovie object.
Ocean::Media::AVFoundation::AVFAudio::internalStop
bool internalStop() override
Internally stops the medium.
Ocean::Media::AVFoundation::AVFAudio::setPosition
bool setPosition(const double position) override
Sets the recent position of the movie medium.
Ocean::Media::AVFoundation::AVFAudio::setSpeed
bool setSpeed(const float speed) override
Sets the speed of the movie medium.
Ocean::Media::AVFoundation::AVFAudio::internalStart
bool internalStart() override
Internally starts the medium.
Ocean::Media::AVFoundation::AVFAudio::setLoop
bool setLoop(const bool value) override
Sets whether the medium has to be played in a loop.
Ocean::Media::AVFoundation::AVFAudio::AVFAudio
AVFAudio(const std::string &url)
Creates a new audio by a given url.
Ocean::Media::AVFoundation::AVFLibrary
This class implements the AVFoundation library.
Definition
AVFLibrary.h:32
Ocean::Media::AVFoundation::AVFMedium
This is the base class for all AVFoundation mediums.
Definition
AVFMedium.h:36
Ocean::Media::Audio
This class is the base class for all audio mediums.
Definition
Audio.h:38
Ocean::ObjectRef< Medium >
OceanMediaAVFAudioAVAudioPlayerDelegate
Delegate for audio playing events.
Definition
AVFAudio.h:21
Ocean
The namespace covering the entire Ocean framework.
Definition
Accessor.h:15
impl
ocean
media
avfoundation
AVFAudio.h
Generated on Tue Nov 4 2025 06:04:19 for Ocean by
1.9.8