react-native-audio-api 0.12.0-nightly-6a44b58-20260126 → 0.12.0-nightly-1a3c43b-20260128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNAudioAPI.podspec +8 -0
- package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -13
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +3 -2
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +12 -1
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +5 -1
- package/android/src/main/java/com/swmansion/audioapi/system/AudioEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +4 -4
- package/android/src/main/java/com/swmansion/audioapi/system/VolumeChangeListener.kt +1 -1
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +27 -18
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotificationReceiver.kt +13 -8
- package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +3 -2
- package/android/src/oldarch/NativeAudioAPIModuleSpec.java +2 -2
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +9 -12
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +4 -2
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.h +5 -1
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +38 -38
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +4 -2
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +8 -4
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.h +7 -1
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.cpp +6 -4
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.h +6 -2
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +8 -5
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h +5 -3
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +5 -3
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/DelayNodeHostObject.cpp +4 -3
- package/common/cpp/audioapi/HostObjects/effects/DelayNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/IIRFilterNodeHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/effects/IIRFilterNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.cpp +5 -2
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.cpp +9 -4
- package/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.cpp +3 -2
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +2 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +9 -6
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +4 -2
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +5 -2
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.cpp +5 -2
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.cpp +7 -3
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/utils/JsEnumParser.cpp +63 -0
- package/common/cpp/audioapi/HostObjects/utils/JsEnumParser.h +5 -0
- package/common/cpp/audioapi/core/AudioContext.cpp +2 -4
- package/common/cpp/audioapi/core/AudioNode.cpp +4 -4
- package/common/cpp/audioapi/core/AudioNode.h +6 -6
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +7 -22
- package/common/cpp/audioapi/core/BaseAudioContext.h +20 -22
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +3 -6
- package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +5 -2
- package/common/cpp/audioapi/core/analysis/AnalyserNode.h +4 -2
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.cpp +1 -1
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.h +1 -1
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +6 -6
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +2 -2
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +1 -1
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +2 -2
- package/common/cpp/audioapi/core/effects/DelayNode.cpp +1 -1
- package/common/cpp/audioapi/core/effects/DelayNode.h +2 -2
- package/common/cpp/audioapi/core/effects/GainNode.cpp +1 -1
- package/common/cpp/audioapi/core/effects/GainNode.h +2 -2
- package/common/cpp/audioapi/core/effects/IIRFilterNode.cpp +5 -3
- package/common/cpp/audioapi/core/effects/IIRFilterNode.h +2 -2
- package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +5 -2
- package/common/cpp/audioapi/core/effects/StereoPannerNode.h +2 -2
- package/common/cpp/audioapi/core/effects/WaveShaperNode.cpp +4 -2
- package/common/cpp/audioapi/core/effects/WaveShaperNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBuffer.h +1 -1
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +10 -4
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +13 -13
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +6 -5
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +2 -2
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +10 -2
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +11 -6
- package/common/cpp/audioapi/core/sources/OscillatorNode.h +2 -2
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +17 -4
- package/common/cpp/audioapi/core/sources/StreamerNode.h +4 -2
- package/common/cpp/audioapi/core/utils/AudioFileWriter.cpp +2 -3
- package/common/cpp/audioapi/core/utils/AudioRecorderCallback.cpp +3 -4
- package/common/cpp/audioapi/events/AudioEvent.h +30 -0
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +9 -20
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +7 -34
- package/common/cpp/audioapi/events/IAudioEventHandlerRegistry.h +5 -4
- package/common/cpp/audioapi/jsi/JsiUtils.cpp +21 -0
- package/common/cpp/audioapi/jsi/JsiUtils.h +17 -0
- package/{android/src/main/cpp/audioapi/android/core → common/cpp/audioapi}/utils/MiniaudioImplementation.cpp +1 -2
- package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +5 -10
- package/ios/audioapi/ios/AudioAPIModule.h +3 -1
- package/ios/audioapi/ios/AudioAPIModule.mm +7 -6
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -3
- package/ios/audioapi/ios/system/AudioSessionManager.h +3 -1
- package/ios/audioapi/ios/system/AudioSessionManager.mm +8 -1
- package/ios/audioapi/ios/system/SystemNotificationManager.mm +17 -8
- package/ios/audioapi/ios/system/notification/PlaybackNotification.mm +36 -33
- package/lib/commonjs/core/AudioDecoder.js +2 -2
- package/lib/commonjs/core/AudioDecoder.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +1 -1
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.web.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +1 -1
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/module/core/AudioDecoder.js +2 -2
- package/lib/module/core/AudioDecoder.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +1 -1
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.web.js.map +1 -1
- package/lib/module/system/AudioManager.js +1 -1
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/typescript/core/AudioDecoder.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +1 -17
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/types.d.ts +4 -3
- package/lib/typescript/system/notification/types.d.ts.map +1 -1
- package/lib/typescript/system/types.d.ts +8 -0
- package/lib/typescript/system/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/AudioDecoder.ts +2 -2
- package/src/core/AudioRecorder.ts +1 -1
- package/src/events/types.ts +1 -18
- package/src/specs/NativeAudioAPIModule.ts +3 -2
- package/src/specs/NativeAudioAPIModule.web.ts +2 -1
- package/src/system/AudioManager.ts +2 -1
- package/src/system/notification/types.ts +6 -4
- package/src/system/types.ts +8 -0
|
@@ -9,25 +9,14 @@ namespace audioapi {
|
|
|
9
9
|
AudioEventHandlerRegistry::AudioEventHandlerRegistry(
|
|
10
10
|
jsi::Runtime *runtime,
|
|
11
11
|
const std::shared_ptr<react::CallInvoker> &callInvoker)
|
|
12
|
-
: IAudioEventHandlerRegistry() {
|
|
13
|
-
runtime_ = runtime;
|
|
14
|
-
callInvoker_ = callInvoker;
|
|
15
|
-
|
|
16
|
-
for (const auto &eventName : SYSTEM_EVENT_NAMES) {
|
|
17
|
-
eventHandlers_[std::string(eventName)] = {};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (const auto &eventName : AUDIO_API_EVENT_NAMES) {
|
|
21
|
-
eventHandlers_[std::string(eventName)] = {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
12
|
+
: IAudioEventHandlerRegistry(), callInvoker_(callInvoker), runtime_(runtime) {}
|
|
24
13
|
|
|
25
14
|
AudioEventHandlerRegistry::~AudioEventHandlerRegistry() {
|
|
26
15
|
eventHandlers_.clear();
|
|
27
16
|
}
|
|
28
17
|
|
|
29
18
|
uint64_t AudioEventHandlerRegistry::registerHandler(
|
|
30
|
-
|
|
19
|
+
AudioEvent eventName,
|
|
31
20
|
const std::shared_ptr<jsi::Function> &handler) {
|
|
32
21
|
uint64_t listenerId = listenerIdCounter_++;
|
|
33
22
|
|
|
@@ -45,7 +34,7 @@ uint64_t AudioEventHandlerRegistry::registerHandler(
|
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
void AudioEventHandlerRegistry::unregisterHandler(
|
|
48
|
-
|
|
37
|
+
AudioEvent eventName,
|
|
49
38
|
uint64_t listenerId) {
|
|
50
39
|
if (callInvoker_ == nullptr || runtime_ == nullptr) {
|
|
51
40
|
// If callInvoker or runtime is not valid, we cannot unregister the handler
|
|
@@ -69,7 +58,7 @@ void AudioEventHandlerRegistry::unregisterHandler(
|
|
|
69
58
|
}
|
|
70
59
|
|
|
71
60
|
void AudioEventHandlerRegistry::invokeHandlerWithEventBody(
|
|
72
|
-
|
|
61
|
+
AudioEvent eventName,
|
|
73
62
|
const std::unordered_map<std::string, EventValue> &body) {
|
|
74
63
|
// callInvoker_ and runtime_ must be valid to invoke handlers
|
|
75
64
|
// this might happen when react-native is reloaded or the app is closed
|
|
@@ -100,7 +89,7 @@ void AudioEventHandlerRegistry::invokeHandlerWithEventBody(
|
|
|
100
89
|
jsi::Object eventObject(*runtime_);
|
|
101
90
|
// handle special logic for microphone, because we pass audio buffer
|
|
102
91
|
// which has significant size
|
|
103
|
-
if (eventName
|
|
92
|
+
if (eventName == AudioEvent::AUDIO_READY) {
|
|
104
93
|
auto bufferIt = body.find("buffer");
|
|
105
94
|
if (bufferIt != body.end()) {
|
|
106
95
|
auto bufferHostObject = std::static_pointer_cast<AudioBufferHostObject>(
|
|
@@ -117,14 +106,14 @@ void AudioEventHandlerRegistry::invokeHandlerWithEventBody(
|
|
|
117
106
|
throw;
|
|
118
107
|
} catch (...) {
|
|
119
108
|
printf(
|
|
120
|
-
"Unknown exception occurred while invoking handler for event: %
|
|
109
|
+
"Unknown exception occurred while invoking handler for event: %d\n", eventName);
|
|
121
110
|
}
|
|
122
111
|
}
|
|
123
112
|
});
|
|
124
113
|
}
|
|
125
114
|
|
|
126
115
|
void AudioEventHandlerRegistry::invokeHandlerWithEventBody(
|
|
127
|
-
|
|
116
|
+
AudioEvent eventName,
|
|
128
117
|
uint64_t listenerId,
|
|
129
118
|
const std::unordered_map<std::string, EventValue> &body) {
|
|
130
119
|
// callInvoker_ and runtime_ must be valid to invoke handlers
|
|
@@ -164,7 +153,7 @@ void AudioEventHandlerRegistry::invokeHandlerWithEventBody(
|
|
|
164
153
|
jsi::Object eventObject(*runtime_);
|
|
165
154
|
// handle special logic for microphone, because we pass audio buffer which
|
|
166
155
|
// has significant size
|
|
167
|
-
if (eventName
|
|
156
|
+
if (eventName == AudioEvent::AUDIO_READY) {
|
|
168
157
|
auto bufferIt = body.find("buffer");
|
|
169
158
|
if (bufferIt != body.end()) {
|
|
170
159
|
auto bufferHostObject = std::static_pointer_cast<AudioBufferHostObject>(
|
|
@@ -181,7 +170,7 @@ void AudioEventHandlerRegistry::invokeHandlerWithEventBody(
|
|
|
181
170
|
throw;
|
|
182
171
|
} catch (...) {
|
|
183
172
|
printf(
|
|
184
|
-
"Unknown exception occurred while invoking handler for event: %
|
|
173
|
+
"Unknown exception occurred while invoking handler for event: %d\n", eventName);
|
|
185
174
|
}
|
|
186
175
|
});
|
|
187
176
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <ReactCommon/CallInvoker.h>
|
|
4
|
+
#include <audioapi/events/AudioEvent.h>
|
|
4
5
|
#include <audioapi/events/IAudioEventHandlerRegistry.h>
|
|
5
6
|
#include <jsi/jsi.h>
|
|
6
7
|
#include <array>
|
|
@@ -23,16 +24,15 @@ class AudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
|
23
24
|
const std::shared_ptr<react::CallInvoker> &callInvoker);
|
|
24
25
|
~AudioEventHandlerRegistry() override;
|
|
25
26
|
|
|
26
|
-
uint64_t registerHandler(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
void unregisterHandler(const std::string &eventName, uint64_t listenerId) override;
|
|
27
|
+
uint64_t registerHandler(AudioEvent eventName, const std::shared_ptr<jsi::Function> &handler)
|
|
28
|
+
override;
|
|
29
|
+
void unregisterHandler(AudioEvent eventName, uint64_t listenerId) override;
|
|
30
30
|
|
|
31
31
|
void invokeHandlerWithEventBody(
|
|
32
|
-
|
|
32
|
+
AudioEvent eventName,
|
|
33
33
|
const std::unordered_map<std::string, EventValue> &body) override;
|
|
34
34
|
void invokeHandlerWithEventBody(
|
|
35
|
-
|
|
35
|
+
AudioEvent eventName,
|
|
36
36
|
uint64_t listenerId,
|
|
37
37
|
const std::unordered_map<std::string, EventValue> &body) override;
|
|
38
38
|
|
|
@@ -41,36 +41,9 @@ class AudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
|
41
41
|
|
|
42
42
|
std::shared_ptr<react::CallInvoker> callInvoker_;
|
|
43
43
|
jsi::Runtime *runtime_;
|
|
44
|
-
std::unordered_map<
|
|
44
|
+
std::unordered_map<AudioEvent, std::unordered_map<uint64_t, std::shared_ptr<jsi::Function>>>
|
|
45
45
|
eventHandlers_;
|
|
46
46
|
|
|
47
|
-
static constexpr std::array<std::string_view, 15> SYSTEM_EVENT_NAMES = {
|
|
48
|
-
"remotePlay",
|
|
49
|
-
"remotePause",
|
|
50
|
-
"remoteStop",
|
|
51
|
-
"remoteTogglePlayPause",
|
|
52
|
-
"remoteChangePlaybackRate",
|
|
53
|
-
"remoteNextTrack",
|
|
54
|
-
"remotePreviousTrack",
|
|
55
|
-
"remoteSkipForward",
|
|
56
|
-
"remoteSkipBackward",
|
|
57
|
-
"remoteSeekForward",
|
|
58
|
-
"remoteSeekBackward",
|
|
59
|
-
"remoteChangePlaybackPosition",
|
|
60
|
-
"routeChange",
|
|
61
|
-
"interruption",
|
|
62
|
-
"volumeChange",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
static constexpr std::array<std::string_view, 7> AUDIO_API_EVENT_NAMES = {
|
|
66
|
-
"ended",
|
|
67
|
-
"loopEnded",
|
|
68
|
-
"audioReady",
|
|
69
|
-
"positionChanged",
|
|
70
|
-
"bufferEnded",
|
|
71
|
-
"audioError",
|
|
72
|
-
"systemStateChanged"};
|
|
73
|
-
|
|
74
47
|
jsi::Object createEventObject(const std::unordered_map<std::string, EventValue> &body);
|
|
75
48
|
jsi::Object createEventObject(
|
|
76
49
|
const std::unordered_map<std::string, EventValue> &body,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <ReactCommon/CallInvoker.h>
|
|
4
|
+
#include <audioapi/events/AudioEvent.h>
|
|
4
5
|
#include <jsi/jsi.h>
|
|
5
6
|
#include <memory>
|
|
6
7
|
#include <string>
|
|
@@ -17,15 +18,15 @@ class IAudioEventHandlerRegistry {
|
|
|
17
18
|
virtual ~IAudioEventHandlerRegistry() = default;
|
|
18
19
|
|
|
19
20
|
virtual uint64_t registerHandler(
|
|
20
|
-
|
|
21
|
+
AudioEvent eventName,
|
|
21
22
|
const std::shared_ptr<facebook::jsi::Function> &handler) = 0;
|
|
22
|
-
virtual void unregisterHandler(
|
|
23
|
+
virtual void unregisterHandler(AudioEvent eventName, uint64_t listenerId) = 0;
|
|
23
24
|
|
|
24
25
|
virtual void invokeHandlerWithEventBody(
|
|
25
|
-
|
|
26
|
+
AudioEvent eventName,
|
|
26
27
|
const std::unordered_map<std::string, EventValue> &body) = 0;
|
|
27
28
|
virtual void invokeHandlerWithEventBody(
|
|
28
|
-
|
|
29
|
+
AudioEvent eventName,
|
|
29
30
|
uint64_t listenerId,
|
|
30
31
|
const std::unordered_map<std::string, EventValue> &body) = 0;
|
|
31
32
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#include <audioapi/jsi/JsiUtils.h>
|
|
2
|
+
#include <string>
|
|
3
|
+
|
|
4
|
+
namespace audioapi::jsiutils {
|
|
5
|
+
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
std::string argToString(
|
|
9
|
+
jsi::Runtime &runtime,
|
|
10
|
+
const jsi::Value *args,
|
|
11
|
+
size_t count,
|
|
12
|
+
size_t index,
|
|
13
|
+
const std::string &defaultValue) {
|
|
14
|
+
if (index < count && args[index].isString()) {
|
|
15
|
+
return args[index].asString(runtime).utf8(runtime);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return defaultValue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace audioapi::jsiutils
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
namespace audioapi::jsiutils {
|
|
7
|
+
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
std::string argToString(
|
|
11
|
+
jsi::Runtime &runtime,
|
|
12
|
+
const jsi::Value *args,
|
|
13
|
+
size_t count,
|
|
14
|
+
size_t index,
|
|
15
|
+
const std::string &defaultValue = "");
|
|
16
|
+
|
|
17
|
+
} // namespace audioapi::jsiutils
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// Miniaudio implementation
|
|
1
|
+
/// Miniaudio implementation
|
|
2
2
|
/// this define tells the miniaudio to also include the definitions and not only declarations.
|
|
3
3
|
/// Which should be done only once in the whole project.
|
|
4
4
|
/// This make its safe to include the header file in multiple places, without causing multiple definition errors.
|
|
5
|
-
/// TODO: Consider moving this file to common scope to re-use the miniaudio also for iOS platform.
|
|
6
5
|
#define MINIAUDIO_IMPLEMENTATION
|
|
7
6
|
#define MA_DEBUG_OUTPUT
|
|
8
7
|
#include <audioapi/libs/miniaudio/miniaudio.h>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <audioapi/events/AudioEvent.h>
|
|
3
4
|
#include <audioapi/events/IAudioEventHandlerRegistry.h>
|
|
4
5
|
#include <gmock/gmock.h>
|
|
5
6
|
#include <memory>
|
|
@@ -15,18 +16,12 @@ class MockAudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
|
15
16
|
MOCK_METHOD(
|
|
16
17
|
uint64_t,
|
|
17
18
|
registerHandler,
|
|
18
|
-
(
|
|
19
|
-
(override));
|
|
20
|
-
MOCK_METHOD(
|
|
21
|
-
void,
|
|
22
|
-
unregisterHandler,
|
|
23
|
-
(const std::string &eventName, uint64_t listenerId),
|
|
19
|
+
(AudioEvent eventName, const std::shared_ptr<facebook::jsi::Function> &handler),
|
|
24
20
|
(override));
|
|
21
|
+
MOCK_METHOD(void, unregisterHandler, (AudioEvent eventName, uint64_t listenerId), (override));
|
|
25
22
|
|
|
26
|
-
MOCK_METHOD2(
|
|
27
|
-
invokeHandlerWithEventBody,
|
|
28
|
-
void(const std::string &eventName, const EventMap &body));
|
|
23
|
+
MOCK_METHOD2(invokeHandlerWithEventBody, void(AudioEvent eventName, const EventMap &body));
|
|
29
24
|
MOCK_METHOD3(
|
|
30
25
|
invokeHandlerWithEventBody,
|
|
31
|
-
void(
|
|
26
|
+
void(AudioEvent eventName, uint64_t listenerId, const EventMap &body));
|
|
32
27
|
};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
8
8
|
|
|
9
9
|
#import <React/RCTEventEmitter.h>
|
|
10
|
+
#import <audioapi/events/AudioEvent.h>
|
|
10
11
|
|
|
11
12
|
@class AudioEngine;
|
|
12
13
|
@class SystemNotificationManager;
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
@property (nonatomic, strong) AudioSessionManager *audioSessionManager;
|
|
26
27
|
@property (nonatomic, strong) NotificationRegistry *notificationRegistry;
|
|
27
28
|
|
|
28
|
-
- (void)invokeHandlerWithEventName:(
|
|
29
|
+
- (void)invokeHandlerWithEventName:(audioapi::AudioEvent)eventName
|
|
30
|
+
eventBody:(NSDictionary *)eventBody;
|
|
29
31
|
|
|
30
32
|
@end
|
|
@@ -152,7 +152,8 @@ RCT_EXPORT_METHOD(
|
|
|
152
152
|
|
|
153
153
|
RCT_EXPORT_METHOD(
|
|
154
154
|
setAudioSessionOptions : (NSString *)category mode : (NSString *)mode options : (NSArray *)
|
|
155
|
-
options allowHaptics : (BOOL)allowHaptics)
|
|
155
|
+
options allowHaptics : (BOOL)allowHaptics notifyOthersOnDeactivation : (BOOL)
|
|
156
|
+
notifyOthersOnDeactivation)
|
|
156
157
|
{
|
|
157
158
|
if (!self.audioSessionManager.shouldManageSession) {
|
|
158
159
|
[self.audioSessionManager setShouldManageSession:true];
|
|
@@ -160,7 +161,8 @@ RCT_EXPORT_METHOD(
|
|
|
160
161
|
[self.audioSessionManager setAudioSessionOptions:category
|
|
161
162
|
mode:mode
|
|
162
163
|
options:options
|
|
163
|
-
allowHaptics:allowHaptics
|
|
164
|
+
allowHaptics:allowHaptics
|
|
165
|
+
notifyOthersOnDeactivation:notifyOthersOnDeactivation];
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
RCT_EXPORT_METHOD(observeAudioInterruptions : (NSString *)focusType enabled : (BOOL)enabled)
|
|
@@ -280,10 +282,9 @@ RCT_EXPORT_METHOD(
|
|
|
280
282
|
}
|
|
281
283
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
282
284
|
|
|
283
|
-
- (void)invokeHandlerWithEventName:(
|
|
285
|
+
- (void)invokeHandlerWithEventName:(audioapi::AudioEvent)eventName
|
|
286
|
+
eventBody:(NSDictionary *)eventBody
|
|
284
287
|
{
|
|
285
|
-
auto name = [eventName UTF8String];
|
|
286
|
-
|
|
287
288
|
std::unordered_map<std::string, EventValue> body = {};
|
|
288
289
|
|
|
289
290
|
for (NSString *key in eventBody) {
|
|
@@ -308,7 +309,7 @@ RCT_EXPORT_METHOD(
|
|
|
308
309
|
}
|
|
309
310
|
|
|
310
311
|
if (_eventHandler != nullptr) {
|
|
311
|
-
_eventHandler->invokeHandlerWithEventBody(
|
|
312
|
+
_eventHandler->invokeHandlerWithEventBody(eventName, body);
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
315
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
#define MINIAUDIO_IMPLEMENTATION
|
|
2
|
-
#import <audioapi/libs/miniaudio/miniaudio.h>
|
|
3
|
-
|
|
4
1
|
#include <audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h>
|
|
5
2
|
#include <audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h>
|
|
3
|
+
#include <audioapi/libs/miniaudio/miniaudio.h>
|
|
6
4
|
|
|
7
5
|
#include <audioapi/core/sources/AudioBuffer.h>
|
|
8
6
|
#include <audioapi/core/utils/AudioDecoder.h>
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
@property (nonatomic, assign) AVAudioSessionCategory desiredCategory;
|
|
18
18
|
@property (nonatomic, assign) AVAudioSessionCategoryOptions desiredOptions;
|
|
19
19
|
@property (nonatomic, assign) bool allowHapticsAndSounds;
|
|
20
|
+
@property (nonatomic, assign) bool notifyOthersOnDeactivation;
|
|
20
21
|
|
|
21
22
|
- (instancetype)init;
|
|
22
23
|
+ (instancetype)sharedInstance;
|
|
@@ -26,7 +27,8 @@
|
|
|
26
27
|
- (void)setAudioSessionOptions:(NSString *)category
|
|
27
28
|
mode:(NSString *)mode
|
|
28
29
|
options:(NSArray *)options
|
|
29
|
-
allowHaptics:(BOOL)allowHaptics
|
|
30
|
+
allowHaptics:(BOOL)allowHaptics
|
|
31
|
+
notifyOthersOnDeactivation:(BOOL)notifyOthersOnDeactivation;
|
|
30
32
|
|
|
31
33
|
- (bool)configureAudioSession;
|
|
32
34
|
- (bool)setActive:(bool)active error:(NSError **)error;
|
|
@@ -17,6 +17,7 @@ static AudioSessionManager *_sharedInstance = nil;
|
|
|
17
17
|
self.desiredMode = AVAudioSessionModeDefault;
|
|
18
18
|
self.desiredOptions = 0;
|
|
19
19
|
self.allowHapticsAndSounds = false;
|
|
20
|
+
self.notifyOthersOnDeactivation = true;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
_sharedInstance = self;
|
|
@@ -88,6 +89,7 @@ static AudioSessionManager *_sharedInstance = nil;
|
|
|
88
89
|
mode:(NSString *)modeStr
|
|
89
90
|
options:(NSArray *)optionsArray
|
|
90
91
|
allowHaptics:(BOOL)allowHaptics
|
|
92
|
+
notifyOthersOnDeactivation:(BOOL)notifyOthersOnDeactivation
|
|
91
93
|
{
|
|
92
94
|
AVAudioSessionCategory category = [self categoryFromString:categoryStr];
|
|
93
95
|
AVAudioSessionMode mode = [self modeFromString:modeStr];
|
|
@@ -103,6 +105,7 @@ static AudioSessionManager *_sharedInstance = nil;
|
|
|
103
105
|
self.desiredMode = mode;
|
|
104
106
|
self.desiredOptions = options;
|
|
105
107
|
self.allowHapticsAndSounds = allowHaptics;
|
|
108
|
+
self.notifyOthersOnDeactivation = notifyOthersOnDeactivation;
|
|
106
109
|
|
|
107
110
|
if (configChanged && self.isActive) {
|
|
108
111
|
[self configureAudioSession];
|
|
@@ -129,7 +132,11 @@ static AudioSessionManager *_sharedInstance = nil;
|
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
|
|
135
|
+
AVAudioSessionSetActiveOptions options = active
|
|
136
|
+
? 0
|
|
137
|
+
: (self.notifyOthersOnDeactivation ? AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
|
|
138
|
+
: 0);
|
|
139
|
+
success = [self.audioSession setActive:active withOptions:options error:error];
|
|
133
140
|
|
|
134
141
|
if (success) {
|
|
135
142
|
self.isActive = active;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#import <audioapi/events/AudioEvent.h>
|
|
1
2
|
#import <audioapi/ios/AudioAPIModule.h>
|
|
2
3
|
#import <audioapi/ios/system/AudioEngine.h>
|
|
3
4
|
#import <audioapi/ios/system/AudioSessionManager.h>
|
|
@@ -101,7 +102,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
101
102
|
if ([keyPath isEqualToString:@"outputVolume"]) {
|
|
102
103
|
NSDictionary *body = @{@"value" : [NSNumber numberWithFloat:[change[@"new"] floatValue]]};
|
|
103
104
|
if (self.volumeChangesObserved) {
|
|
104
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
105
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::VOLUME_CHANGE
|
|
106
|
+
eventBody:body];
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
}
|
|
@@ -124,7 +126,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
124
126
|
|
|
125
127
|
if (self.audioInterruptionsObserved) {
|
|
126
128
|
NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
|
|
127
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
129
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::INTERRUPTION
|
|
130
|
+
eventBody:body];
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
return;
|
|
@@ -134,7 +137,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
134
137
|
|
|
135
138
|
if (self.audioInterruptionsObserved) {
|
|
136
139
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @(shouldResume)};
|
|
137
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
140
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::INTERRUPTION
|
|
141
|
+
eventBody:body];
|
|
138
142
|
} else {
|
|
139
143
|
dispatch_async(dispatch_get_main_queue(), ^{ [audioEngine onInterruptionEnd:shouldResume]; });
|
|
140
144
|
}
|
|
@@ -155,7 +159,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
155
159
|
|
|
156
160
|
if (self.audioInterruptionsObserved) {
|
|
157
161
|
NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
|
|
158
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
162
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::INTERRUPTION
|
|
163
|
+
eventBody:body];
|
|
159
164
|
}
|
|
160
165
|
return;
|
|
161
166
|
}
|
|
@@ -164,7 +169,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
164
169
|
|
|
165
170
|
if (self.audioInterruptionsObserved) {
|
|
166
171
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @(shouldResume)};
|
|
167
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
172
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::INTERRUPTION
|
|
173
|
+
eventBody:body];
|
|
168
174
|
} else {
|
|
169
175
|
dispatch_async(dispatch_get_main_queue(), ^{ [audioEngine onInterruptionEnd:shouldResume]; });
|
|
170
176
|
}
|
|
@@ -208,7 +214,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
208
214
|
|
|
209
215
|
NSDictionary *body = @{@"reason" : reasonStr};
|
|
210
216
|
|
|
211
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
217
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::ROUTE_CHANGE
|
|
218
|
+
eventBody:body];
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
- (void)handleMediaServicesReset:(NSNotification *)notification
|
|
@@ -280,7 +287,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
280
287
|
NSDictionary *body = @{@"type" : @"began", @"shouldResume" : @false};
|
|
281
288
|
|
|
282
289
|
if (self.audioInterruptionsObserved) {
|
|
283
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
290
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::INTERRUPTION
|
|
291
|
+
eventBody:body];
|
|
284
292
|
}
|
|
285
293
|
|
|
286
294
|
return;
|
|
@@ -289,7 +297,8 @@ static NSString *NotificationManagerContext = @"SystemNotificationManagerContext
|
|
|
289
297
|
NSDictionary *body = @{@"type" : @"ended", @"shouldResume" : @true};
|
|
290
298
|
|
|
291
299
|
if (self.audioInterruptionsObserved) {
|
|
292
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
300
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::INTERRUPTION
|
|
301
|
+
eventBody:body];
|
|
293
302
|
} else {
|
|
294
303
|
dispatch_async(dispatch_get_main_queue(), ^{ [audioEngine onInterruptionEnd:true]; });
|
|
295
304
|
}
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
// Enable default remote commands
|
|
47
47
|
[self enableRemoteCommand:@"play" enabled:true];
|
|
48
48
|
[self enableRemoteCommand:@"pause" enabled:true];
|
|
49
|
-
[self enableRemoteCommand:@"
|
|
50
|
-
[self enableRemoteCommand:@"
|
|
49
|
+
[self enableRemoteCommand:@"nextTrack" enabled:true];
|
|
50
|
+
[self enableRemoteCommand:@"previousTrack" enabled:true];
|
|
51
51
|
[self enableRemoteCommand:@"skipForward" enabled:true];
|
|
52
52
|
[self enableRemoteCommand:@"skipBackward" enabled:true];
|
|
53
|
-
[self enableRemoteCommand:@"
|
|
53
|
+
[self enableRemoteCommand:@"seekTo" enabled:true];
|
|
54
54
|
|
|
55
55
|
_isInitialized = true;
|
|
56
56
|
return true;
|
|
@@ -109,7 +109,6 @@
|
|
|
109
109
|
[remoteCenter.playCommand removeTarget:self];
|
|
110
110
|
[remoteCenter.pauseCommand removeTarget:self];
|
|
111
111
|
[remoteCenter.stopCommand removeTarget:self];
|
|
112
|
-
[remoteCenter.togglePlayPauseCommand removeTarget:self];
|
|
113
112
|
[remoteCenter.nextTrackCommand removeTarget:self];
|
|
114
113
|
[remoteCenter.previousTrackCommand removeTarget:self];
|
|
115
114
|
[remoteCenter.skipForwardCommand removeTarget:self];
|
|
@@ -270,11 +269,12 @@
|
|
|
270
269
|
{
|
|
271
270
|
NSSet *validControls = [NSSet setWithObjects:@"play",
|
|
272
271
|
@"pause",
|
|
273
|
-
@"
|
|
274
|
-
@"
|
|
272
|
+
@"stop",
|
|
273
|
+
@"nextTrack",
|
|
274
|
+
@"previousTrack",
|
|
275
275
|
@"skipForward",
|
|
276
276
|
@"skipBackward",
|
|
277
|
-
@"
|
|
277
|
+
@"seekTo",
|
|
278
278
|
nil];
|
|
279
279
|
if ([validControls containsObject:control]) {
|
|
280
280
|
[self enableRemoteCommand:control enabled:enabled];
|
|
@@ -291,15 +291,11 @@
|
|
|
291
291
|
[self enableCommand:remoteCenter.pauseCommand withSelector:@selector(onPause:) enabled:enabled];
|
|
292
292
|
} else if ([name isEqualToString:@"stop"]) {
|
|
293
293
|
[self enableCommand:remoteCenter.stopCommand withSelector:@selector(onStop:) enabled:enabled];
|
|
294
|
-
} else if ([name isEqualToString:@"
|
|
295
|
-
[self enableCommand:remoteCenter.togglePlayPauseCommand
|
|
296
|
-
withSelector:@selector(onTogglePlayPause:)
|
|
297
|
-
enabled:enabled];
|
|
298
|
-
} else if ([name isEqualToString:@"next"]) {
|
|
294
|
+
} else if ([name isEqualToString:@"nextTrack"]) {
|
|
299
295
|
[self enableCommand:remoteCenter.nextTrackCommand
|
|
300
296
|
withSelector:@selector(onNextTrack:)
|
|
301
297
|
enabled:enabled];
|
|
302
|
-
} else if ([name isEqualToString:@"
|
|
298
|
+
} else if ([name isEqualToString:@"previousTrack"]) {
|
|
303
299
|
[self enableCommand:remoteCenter.previousTrackCommand
|
|
304
300
|
withSelector:@selector(onPreviousTrack:)
|
|
305
301
|
enabled:enabled];
|
|
@@ -321,7 +317,7 @@
|
|
|
321
317
|
[self enableCommand:remoteCenter.seekBackwardCommand
|
|
322
318
|
withSelector:@selector(onSeekBackward:)
|
|
323
319
|
enabled:enabled];
|
|
324
|
-
} else if ([name isEqualToString:@"
|
|
320
|
+
} else if ([name isEqualToString:@"seekTo"]) {
|
|
325
321
|
[self enableCommand:remoteCenter.changePlaybackPositionCommand
|
|
326
322
|
withSelector:@selector(onChangePlaybackPosition:)
|
|
327
323
|
enabled:enabled];
|
|
@@ -341,67 +337,72 @@
|
|
|
341
337
|
|
|
342
338
|
- (MPRemoteCommandHandlerStatus)onPlay:(MPRemoteCommandEvent *)event
|
|
343
339
|
{
|
|
344
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
340
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_PLAY
|
|
341
|
+
eventBody:@{}];
|
|
345
342
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
346
343
|
}
|
|
347
344
|
|
|
348
345
|
- (MPRemoteCommandHandlerStatus)onPause:(MPRemoteCommandEvent *)event
|
|
349
346
|
{
|
|
350
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
347
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_PAUSE
|
|
348
|
+
eventBody:@{}];
|
|
351
349
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
352
350
|
}
|
|
353
351
|
|
|
354
352
|
- (MPRemoteCommandHandlerStatus)onStop:(MPRemoteCommandEvent *)event
|
|
355
353
|
{
|
|
356
|
-
[self.audioAPIModule invokeHandlerWithEventName
|
|
357
|
-
return MPRemoteCommandHandlerStatusSuccess;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
- (MPRemoteCommandHandlerStatus)onTogglePlayPause:(MPRemoteCommandEvent *)event
|
|
361
|
-
{
|
|
362
|
-
[self.audioAPIModule invokeHandlerWithEventName:@"playbackNotificationTogglePlayPause"
|
|
354
|
+
[self.audioAPIModule invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_STOP
|
|
363
355
|
eventBody:@{}];
|
|
364
356
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
365
357
|
}
|
|
366
358
|
|
|
367
359
|
- (MPRemoteCommandHandlerStatus)onNextTrack:(MPRemoteCommandEvent *)event
|
|
368
360
|
{
|
|
369
|
-
[self.audioAPIModule
|
|
361
|
+
[self.audioAPIModule
|
|
362
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_NEXT_TRACK
|
|
363
|
+
eventBody:@{}];
|
|
370
364
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
371
365
|
}
|
|
372
366
|
|
|
373
367
|
- (MPRemoteCommandHandlerStatus)onPreviousTrack:(MPRemoteCommandEvent *)event
|
|
374
368
|
{
|
|
375
|
-
[self.audioAPIModule
|
|
369
|
+
[self.audioAPIModule
|
|
370
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_PREVIOUS_TRACK
|
|
371
|
+
eventBody:@{}];
|
|
376
372
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
377
373
|
}
|
|
378
374
|
|
|
379
375
|
- (MPRemoteCommandHandlerStatus)onSeekForward:(MPRemoteCommandEvent *)event
|
|
380
376
|
{
|
|
381
|
-
[self.audioAPIModule
|
|
377
|
+
[self.audioAPIModule
|
|
378
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_SEEK_FORWARD
|
|
379
|
+
eventBody:@{}];
|
|
382
380
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
383
381
|
}
|
|
384
382
|
|
|
385
383
|
- (MPRemoteCommandHandlerStatus)onSeekBackward:(MPRemoteCommandEvent *)event
|
|
386
384
|
{
|
|
387
|
-
[self.audioAPIModule
|
|
388
|
-
|
|
385
|
+
[self.audioAPIModule
|
|
386
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_SEEK_BACKWARD
|
|
387
|
+
eventBody:@{}];
|
|
389
388
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
390
389
|
}
|
|
391
390
|
|
|
392
391
|
- (MPRemoteCommandHandlerStatus)onSkipForward:(MPSkipIntervalCommandEvent *)event
|
|
393
392
|
{
|
|
394
393
|
NSDictionary *body = @{@"value" : @(event.interval)};
|
|
395
|
-
[self.audioAPIModule
|
|
396
|
-
|
|
394
|
+
[self.audioAPIModule
|
|
395
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_SKIP_FORWARD
|
|
396
|
+
eventBody:body];
|
|
397
397
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
- (MPRemoteCommandHandlerStatus)onSkipBackward:(MPSkipIntervalCommandEvent *)event
|
|
401
401
|
{
|
|
402
402
|
NSDictionary *body = @{@"value" : @(event.interval)};
|
|
403
|
-
[self.audioAPIModule
|
|
404
|
-
|
|
403
|
+
[self.audioAPIModule
|
|
404
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_SKIP_BACKWARD
|
|
405
|
+
eventBody:body];
|
|
405
406
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
406
407
|
}
|
|
407
408
|
|
|
@@ -409,7 +410,9 @@
|
|
|
409
410
|
(MPChangePlaybackPositionCommandEvent *)event
|
|
410
411
|
{
|
|
411
412
|
NSDictionary *body = @{@"value" : @(event.positionTime)};
|
|
412
|
-
[self.audioAPIModule
|
|
413
|
+
[self.audioAPIModule
|
|
414
|
+
invokeHandlerWithEventName:audioapi::AudioEvent::PLAYBACK_NOTIFICATION_SEEK_TO
|
|
415
|
+
eventBody:body];
|
|
413
416
|
return MPRemoteCommandHandlerStatusSuccess;
|
|
414
417
|
}
|
|
415
418
|
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.decodeAudioData = decodeAudioData;
|
|
7
7
|
exports.decodePCMInBase64 = decodePCMInBase64;
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
+
var _errors = require("../errors");
|
|
9
10
|
var _paths = require("../utils/paths");
|
|
10
11
|
var _AudioBuffer = _interopRequireDefault(require("./AudioBuffer"));
|
|
11
|
-
var _errors = require("../errors");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
class AudioDecoder {
|
|
14
14
|
static instance = null;
|
|
@@ -38,7 +38,7 @@ class AudioDecoder {
|
|
|
38
38
|
const buffer = await this.decoder.decodeWithMemoryBlock(new Uint8Array(arrayBuffer), sampleRate ?? 0);
|
|
39
39
|
return new _AudioBuffer.default(buffer);
|
|
40
40
|
}
|
|
41
|
-
if (!(typeof
|
|
41
|
+
if (!(typeof stringSource === 'string')) {
|
|
42
42
|
throw new TypeError('Input must be a module, uri or ArrayBuffer');
|
|
43
43
|
}
|
|
44
44
|
|