react-native-nitro-player 1.4.4-alpha.0 → 1.5.0-alpha.0

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.
Files changed (67) hide show
  1. package/NitroPlayer.podspec +6 -0
  2. package/README.md +113 -0
  3. package/android/build.gradle +8 -0
  4. package/android/src/main/AndroidManifest.xml +11 -0
  5. package/android/src/main/java/com/margelo/nitro/nitroplayer/HybridCast.kt +79 -0
  6. package/android/src/main/java/com/margelo/nitro/nitroplayer/core/ExoPlayerCore.kt +10 -7
  7. package/android/src/main/java/com/margelo/nitro/nitroplayer/core/TrackPlayerCast.kt +122 -0
  8. package/android/src/main/java/com/margelo/nitro/nitroplayer/core/TrackPlayerCore.kt +13 -0
  9. package/android/src/main/java/com/margelo/nitro/nitroplayer/core/TrackPlayerSetup.kt +7 -0
  10. package/android/src/main/java/com/margelo/nitro/nitroplayer/media/CastSessionController.kt +160 -0
  11. package/android/src/main/java/com/margelo/nitro/nitroplayer/media/NitroCastConfig.kt +23 -0
  12. package/android/src/main/java/com/margelo/nitro/nitroplayer/media/NitroCastOptionsProvider.kt +30 -0
  13. package/android/src/main/java/com/margelo/nitro/nitroplayer/media/NitroMediaItemConverter.kt +53 -0
  14. package/android/src/main/java/com/margelo/nitro/nitroplayer/media/PlaybackService.kt +33 -0
  15. package/ios/HybridCast.swift +63 -0
  16. package/ios/core/CastSessionManager.swift +367 -0
  17. package/ios/core/TrackPlayerCast.swift +109 -0
  18. package/ios/core/TrackPlayerCore.swift +23 -2
  19. package/ios/core/TrackPlayerPlayback.swift +32 -0
  20. package/ios/core/TrackPlayerQueue.swift +8 -1
  21. package/ios/core/TrackPlayerQueueBuild.swift +21 -0
  22. package/lib/components/CastButton.d.ts +44 -0
  23. package/lib/components/CastButton.js +100 -0
  24. package/lib/hooks/castCallbackManager.d.ts +19 -0
  25. package/lib/hooks/castCallbackManager.js +43 -0
  26. package/lib/hooks/index.d.ts +3 -0
  27. package/lib/hooks/index.js +3 -0
  28. package/lib/hooks/useCastState.d.ts +27 -0
  29. package/lib/hooks/useCastState.js +49 -0
  30. package/lib/hooks/useIsCasting.d.ts +17 -0
  31. package/lib/hooks/useIsCasting.js +43 -0
  32. package/lib/index.d.ts +5 -0
  33. package/lib/index.js +4 -1
  34. package/lib/specs/Cast.nitro.d.ts +58 -0
  35. package/lib/specs/Cast.nitro.js +1 -0
  36. package/nitro.json +10 -0
  37. package/nitrogen/generated/android/NitroPlayer+autolinking.cmake +3 -1
  38. package/nitrogen/generated/android/NitroPlayerOnLoad.cpp +18 -0
  39. package/nitrogen/generated/android/c++/JCastState.hpp +64 -0
  40. package/nitrogen/generated/android/c++/JFunc_void_CastState_std__optional_std__variant_nitro__NullType__std__string__.hpp +83 -0
  41. package/nitrogen/generated/android/c++/JHybridCastSpec.cpp +115 -0
  42. package/nitrogen/generated/android/c++/JHybridCastSpec.hpp +69 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroplayer/CastState.kt +25 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroplayer/Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__.kt +80 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroplayer/HybridCastSpec.kt +85 -0
  46. package/nitrogen/generated/ios/NitroPlayer-Swift-Cxx-Bridge.cpp +38 -13
  47. package/nitrogen/generated/ios/NitroPlayer-Swift-Cxx-Bridge.hpp +176 -125
  48. package/nitrogen/generated/ios/NitroPlayer-Swift-Cxx-Umbrella.hpp +8 -0
  49. package/nitrogen/generated/ios/NitroPlayerAutolinking.mm +8 -0
  50. package/nitrogen/generated/ios/NitroPlayerAutolinking.swift +12 -0
  51. package/nitrogen/generated/ios/c++/HybridCastSpecSwift.cpp +11 -0
  52. package/nitrogen/generated/ios/c++/HybridCastSpecSwift.hpp +133 -0
  53. package/nitrogen/generated/ios/swift/CastState.swift +48 -0
  54. package/nitrogen/generated/ios/swift/Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__.swift +65 -0
  55. package/nitrogen/generated/ios/swift/HybridCastSpec.swift +61 -0
  56. package/nitrogen/generated/ios/swift/HybridCastSpec_cxx.swift +254 -0
  57. package/nitrogen/generated/shared/c++/CastState.hpp +84 -0
  58. package/nitrogen/generated/shared/c++/HybridCastSpec.cpp +27 -0
  59. package/nitrogen/generated/shared/c++/HybridCastSpec.hpp +75 -0
  60. package/package.json +3 -3
  61. package/src/components/CastButton.tsx +196 -0
  62. package/src/hooks/castCallbackManager.ts +55 -0
  63. package/src/hooks/index.ts +5 -0
  64. package/src/hooks/useCastState.ts +67 -0
  65. package/src/hooks/useIsCasting.ts +47 -0
  66. package/src/index.ts +9 -0
  67. package/src/specs/Cast.nitro.ts +72 -0
@@ -8,6 +8,8 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `CastState` to properly resolve imports.
12
+ namespace margelo::nitro::nitroplayer { enum class CastState; }
11
13
  // Forward declaration of `CurrentPlayingType` to properly resolve imports.
12
14
  namespace margelo::nitro::nitroplayer { enum class CurrentPlayingType; }
13
15
  // Forward declaration of `DownloadConfig` to properly resolve imports.
@@ -40,6 +42,8 @@ namespace margelo::nitro::nitroplayer { struct EqualizerState; }
40
42
  namespace margelo::nitro::nitroplayer { struct GainRange; }
41
43
  // Forward declaration of `HybridAudioRoutePickerSpec` to properly resolve imports.
42
44
  namespace margelo::nitro::nitroplayer { class HybridAudioRoutePickerSpec; }
45
+ // Forward declaration of `HybridCastSpec` to properly resolve imports.
46
+ namespace margelo::nitro::nitroplayer { class HybridCastSpec; }
43
47
  // Forward declaration of `HybridDownloadManagerSpec` to properly resolve imports.
44
48
  namespace margelo::nitro::nitroplayer { class HybridDownloadManagerSpec; }
45
49
  // Forward declaration of `HybridEqualizerSpec` to properly resolve imports.
@@ -72,6 +76,8 @@ namespace margelo::nitro::nitroplayer { enum class TrackPlayerState; }
72
76
  // Forward declarations of Swift defined types
73
77
  // Forward declaration of `HybridAudioRoutePickerSpec_cxx` to properly resolve imports.
74
78
  namespace NitroPlayer { class HybridAudioRoutePickerSpec_cxx; }
79
+ // Forward declaration of `HybridCastSpec_cxx` to properly resolve imports.
80
+ namespace NitroPlayer { class HybridCastSpec_cxx; }
75
81
  // Forward declaration of `HybridDownloadManagerSpec_cxx` to properly resolve imports.
76
82
  namespace NitroPlayer { class HybridDownloadManagerSpec_cxx; }
77
83
  // Forward declaration of `HybridEqualizerSpec_cxx` to properly resolve imports.
@@ -82,6 +88,7 @@ namespace NitroPlayer { class HybridPlayerQueueSpec_cxx; }
82
88
  namespace NitroPlayer { class HybridTrackPlayerSpec_cxx; }
83
89
 
84
90
  // Include C++ defined types
91
+ #include "CastState.hpp"
85
92
  #include "CurrentPlayingType.hpp"
86
93
  #include "DownloadConfig.hpp"
87
94
  #include "DownloadError.hpp"
@@ -98,6 +105,7 @@ namespace NitroPlayer { class HybridTrackPlayerSpec_cxx; }
98
105
  #include "EqualizerState.hpp"
99
106
  #include "GainRange.hpp"
100
107
  #include "HybridAudioRoutePickerSpec.hpp"
108
+ #include "HybridCastSpec.hpp"
101
109
  #include "HybridDownloadManagerSpec.hpp"
102
110
  #include "HybridEqualizerSpec.hpp"
103
111
  #include "HybridPlayerQueueSpec.hpp"
@@ -152,48 +160,74 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
152
160
  return Result<void>::withError(error);
153
161
  }
154
162
 
155
- // pragma MARK: std::optional<StorageLocation>
163
+ // pragma MARK: std::shared_ptr<Promise<void>>
156
164
  /**
157
- * Specialized version of `std::optional<StorageLocation>`.
165
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
158
166
  */
159
- using std__optional_StorageLocation_ = std::optional<StorageLocation>;
160
- inline std::optional<StorageLocation> create_std__optional_StorageLocation_(const StorageLocation& value) noexcept {
161
- return std::optional<StorageLocation>(value);
162
- }
163
- inline bool has_value_std__optional_StorageLocation_(const std::optional<StorageLocation>& optional) noexcept {
164
- return optional.has_value();
167
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
168
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
169
+ return Promise<void>::create();
165
170
  }
166
- inline StorageLocation get_std__optional_StorageLocation_(const std::optional<StorageLocation>& optional) noexcept {
167
- return optional.value();
171
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
172
+ return PromiseHolder<void>(std::move(promise));
168
173
  }
169
174
 
170
- // pragma MARK: std::optional<double>
175
+ // pragma MARK: std::function<void()>
171
176
  /**
172
- * Specialized version of `std::optional<double>`.
177
+ * Specialized version of `std::function<void()>`.
173
178
  */
174
- using std__optional_double_ = std::optional<double>;
175
- inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
176
- return std::optional<double>(value);
177
- }
178
- inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
179
- return optional.has_value();
179
+ using Func_void = std::function<void()>;
180
+ /**
181
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
182
+ */
183
+ class Func_void_Wrapper final {
184
+ public:
185
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
186
+ inline void call() const noexcept {
187
+ _function->operator()();
188
+ }
189
+ private:
190
+ std::unique_ptr<std::function<void()>> _function;
191
+ } SWIFT_NONCOPYABLE;
192
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
193
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
194
+ return Func_void_Wrapper(std::move(value));
180
195
  }
181
- inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
182
- return optional.value();
196
+
197
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
198
+ /**
199
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
200
+ */
201
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
202
+ /**
203
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
204
+ */
205
+ class Func_void_std__exception_ptr_Wrapper final {
206
+ public:
207
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
208
+ inline void call(std::exception_ptr error) const noexcept {
209
+ _function->operator()(error);
210
+ }
211
+ private:
212
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
213
+ } SWIFT_NONCOPYABLE;
214
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
215
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
216
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
183
217
  }
184
218
 
185
- // pragma MARK: std::optional<bool>
219
+ // pragma MARK: std::optional<std::string>
186
220
  /**
187
- * Specialized version of `std::optional<bool>`.
221
+ * Specialized version of `std::optional<std::string>`.
188
222
  */
189
- using std__optional_bool_ = std::optional<bool>;
190
- inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
191
- return std::optional<bool>(value);
223
+ using std__optional_std__string_ = std::optional<std::string>;
224
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
225
+ return std::optional<std::string>(value);
192
226
  }
193
- inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
227
+ inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
194
228
  return optional.has_value();
195
229
  }
196
- inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
230
+ inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
197
231
  return optional.value();
198
232
  }
199
233
 
@@ -241,6 +275,121 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
241
275
  return optional.value();
242
276
  }
243
277
 
278
+ // pragma MARK: std::function<void(CastState /* state */, const std::optional<std::variant<nitro::NullType, std::string>>& /* deviceName */)>
279
+ /**
280
+ * Specialized version of `std::function<void(CastState, const std::optional<std::variant<nitro::NullType, std::string>>&)>`.
281
+ */
282
+ using Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__ = std::function<void(CastState /* state */, const std::optional<std::variant<nitro::NullType, std::string>>& /* deviceName */)>;
283
+ /**
284
+ * Wrapper class for a `std::function<void(CastState / * state * /, const std::optional<std::variant<nitro::NullType, std::string>>& / * deviceName * /)>`, this can be used from Swift.
285
+ */
286
+ class Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string___Wrapper final {
287
+ public:
288
+ explicit Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string___Wrapper(std::function<void(CastState /* state */, const std::optional<std::variant<nitro::NullType, std::string>>& /* deviceName */)>&& func): _function(std::make_unique<std::function<void(CastState /* state */, const std::optional<std::variant<nitro::NullType, std::string>>& /* deviceName */)>>(std::move(func))) {}
289
+ inline void call(int state, std::optional<std::variant<nitro::NullType, std::string>> deviceName) const noexcept {
290
+ _function->operator()(static_cast<CastState>(state), deviceName);
291
+ }
292
+ private:
293
+ std::unique_ptr<std::function<void(CastState /* state */, const std::optional<std::variant<nitro::NullType, std::string>>& /* deviceName */)>> _function;
294
+ } SWIFT_NONCOPYABLE;
295
+ Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__ create_Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__(void* NON_NULL swiftClosureWrapper) noexcept;
296
+ inline Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string___Wrapper wrap_Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__(Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string__ value) noexcept {
297
+ return Func_void_CastState_std__optional_std__variant_nitro__NullType__std__string___Wrapper(std::move(value));
298
+ }
299
+
300
+ // pragma MARK: std::shared_ptr<HybridCastSpec>
301
+ /**
302
+ * Specialized version of `std::shared_ptr<HybridCastSpec>`.
303
+ */
304
+ using std__shared_ptr_HybridCastSpec_ = std::shared_ptr<HybridCastSpec>;
305
+ std::shared_ptr<HybridCastSpec> create_std__shared_ptr_HybridCastSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
306
+ void* NON_NULL get_std__shared_ptr_HybridCastSpec_(std__shared_ptr_HybridCastSpec_ cppType);
307
+
308
+ // pragma MARK: std::weak_ptr<HybridCastSpec>
309
+ using std__weak_ptr_HybridCastSpec_ = std::weak_ptr<HybridCastSpec>;
310
+ inline std__weak_ptr_HybridCastSpec_ weakify_std__shared_ptr_HybridCastSpec_(const std::shared_ptr<HybridCastSpec>& strong) noexcept { return strong; }
311
+
312
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
313
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
314
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
315
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
316
+ }
317
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
318
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
319
+ }
320
+
321
+ // pragma MARK: Result<bool>
322
+ using Result_bool_ = Result<bool>;
323
+ inline Result_bool_ create_Result_bool_(bool value) noexcept {
324
+ return Result<bool>::withValue(std::move(value));
325
+ }
326
+ inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) noexcept {
327
+ return Result<bool>::withError(error);
328
+ }
329
+
330
+ // pragma MARK: Result<CastState>
331
+ using Result_CastState_ = Result<CastState>;
332
+ inline Result_CastState_ create_Result_CastState_(CastState value) noexcept {
333
+ return Result<CastState>::withValue(std::move(value));
334
+ }
335
+ inline Result_CastState_ create_Result_CastState_(const std::exception_ptr& error) noexcept {
336
+ return Result<CastState>::withError(error);
337
+ }
338
+
339
+ // pragma MARK: Result<std::variant<nitro::NullType, std::string>>
340
+ using Result_std__variant_nitro__NullType__std__string__ = Result<std::variant<nitro::NullType, std::string>>;
341
+ inline Result_std__variant_nitro__NullType__std__string__ create_Result_std__variant_nitro__NullType__std__string__(const std::variant<nitro::NullType, std::string>& value) noexcept {
342
+ return Result<std::variant<nitro::NullType, std::string>>::withValue(value);
343
+ }
344
+ inline Result_std__variant_nitro__NullType__std__string__ create_Result_std__variant_nitro__NullType__std__string__(const std::exception_ptr& error) noexcept {
345
+ return Result<std::variant<nitro::NullType, std::string>>::withError(error);
346
+ }
347
+
348
+ // pragma MARK: std::optional<StorageLocation>
349
+ /**
350
+ * Specialized version of `std::optional<StorageLocation>`.
351
+ */
352
+ using std__optional_StorageLocation_ = std::optional<StorageLocation>;
353
+ inline std::optional<StorageLocation> create_std__optional_StorageLocation_(const StorageLocation& value) noexcept {
354
+ return std::optional<StorageLocation>(value);
355
+ }
356
+ inline bool has_value_std__optional_StorageLocation_(const std::optional<StorageLocation>& optional) noexcept {
357
+ return optional.has_value();
358
+ }
359
+ inline StorageLocation get_std__optional_StorageLocation_(const std::optional<StorageLocation>& optional) noexcept {
360
+ return optional.value();
361
+ }
362
+
363
+ // pragma MARK: std::optional<double>
364
+ /**
365
+ * Specialized version of `std::optional<double>`.
366
+ */
367
+ using std__optional_double_ = std::optional<double>;
368
+ inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
369
+ return std::optional<double>(value);
370
+ }
371
+ inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
372
+ return optional.has_value();
373
+ }
374
+ inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
375
+ return optional.value();
376
+ }
377
+
378
+ // pragma MARK: std::optional<bool>
379
+ /**
380
+ * Specialized version of `std::optional<bool>`.
381
+ */
382
+ using std__optional_bool_ = std::optional<bool>;
383
+ inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
384
+ return std::optional<bool>(value);
385
+ }
386
+ inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
387
+ return optional.has_value();
388
+ }
389
+ inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
390
+ return optional.value();
391
+ }
392
+
244
393
  // pragma MARK: std::shared_ptr<Promise<std::string>>
245
394
  /**
246
395
  * Specialized version of `std::shared_ptr<Promise<std::string>>`.
@@ -275,28 +424,6 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
275
424
  return Func_void_std__string_Wrapper(std::move(value));
276
425
  }
277
426
 
278
- // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
279
- /**
280
- * Specialized version of `std::function<void(const std::exception_ptr&)>`.
281
- */
282
- using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
283
- /**
284
- * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
285
- */
286
- class Func_void_std__exception_ptr_Wrapper final {
287
- public:
288
- explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
289
- inline void call(std::exception_ptr error) const noexcept {
290
- _function->operator()(error);
291
- }
292
- private:
293
- std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
294
- } SWIFT_NONCOPYABLE;
295
- Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
296
- inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
297
- return Func_void_std__exception_ptr_Wrapper(std::move(value));
298
- }
299
-
300
427
  // pragma MARK: std::optional<std::shared_ptr<AnyMap>>
301
428
  /**
302
429
  * Specialized version of `std::optional<std::shared_ptr<AnyMap>>`.
@@ -312,21 +439,6 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
312
439
  return optional.value();
313
440
  }
314
441
 
315
- // pragma MARK: std::optional<std::string>
316
- /**
317
- * Specialized version of `std::optional<std::string>`.
318
- */
319
- using std__optional_std__string_ = std::optional<std::string>;
320
- inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
321
- return std::optional<std::string>(value);
322
- }
323
- inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
324
- return optional.has_value();
325
- }
326
- inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
327
- return optional.value();
328
- }
329
-
330
442
  // pragma MARK: std::vector<std::string>
331
443
  /**
332
444
  * Specialized version of `std::vector<std::string>`.
@@ -383,40 +495,6 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
383
495
  return vector;
384
496
  }
385
497
 
386
- // pragma MARK: std::shared_ptr<Promise<void>>
387
- /**
388
- * Specialized version of `std::shared_ptr<Promise<void>>`.
389
- */
390
- using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
391
- inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
392
- return Promise<void>::create();
393
- }
394
- inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
395
- return PromiseHolder<void>(std::move(promise));
396
- }
397
-
398
- // pragma MARK: std::function<void()>
399
- /**
400
- * Specialized version of `std::function<void()>`.
401
- */
402
- using Func_void = std::function<void()>;
403
- /**
404
- * Wrapper class for a `std::function<void()>`, this can be used from Swift.
405
- */
406
- class Func_void_Wrapper final {
407
- public:
408
- explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
409
- inline void call() const noexcept {
410
- _function->operator()();
411
- }
412
- private:
413
- std::unique_ptr<std::function<void()>> _function;
414
- } SWIFT_NONCOPYABLE;
415
- Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
416
- inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
417
- return Func_void_Wrapper(std::move(value));
418
- }
419
-
420
498
  // pragma MARK: std::variant<nitro::NullType, double>
421
499
  /**
422
500
  * Wrapper struct for `std::variant<nitro::NullType, double>`.
@@ -1017,15 +1095,6 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
1017
1095
  return Result<std::shared_ptr<Promise<std::vector<std::string>>>>::withError(error);
1018
1096
  }
1019
1097
 
1020
- // pragma MARK: Result<std::shared_ptr<Promise<void>>>
1021
- using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
1022
- inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
1023
- return Result<std::shared_ptr<Promise<void>>>::withValue(value);
1024
- }
1025
- inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
1026
- return Result<std::shared_ptr<Promise<void>>>::withError(error);
1027
- }
1028
-
1029
1098
  // pragma MARK: Result<std::variant<nitro::NullType, DownloadTask>>
1030
1099
  using Result_std__variant_nitro__NullType__DownloadTask__ = Result<std::variant<nitro::NullType, DownloadTask>>;
1031
1100
  inline Result_std__variant_nitro__NullType__DownloadTask__ create_Result_std__variant_nitro__NullType__DownloadTask__(const std::variant<nitro::NullType, DownloadTask>& value) noexcept {
@@ -1053,15 +1122,6 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
1053
1122
  return Result<DownloadQueueStatus>::withError(error);
1054
1123
  }
1055
1124
 
1056
- // pragma MARK: Result<bool>
1057
- using Result_bool_ = Result<bool>;
1058
- inline Result_bool_ create_Result_bool_(bool value) noexcept {
1059
- return Result<bool>::withValue(std::move(value));
1060
- }
1061
- inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) noexcept {
1062
- return Result<bool>::withError(error);
1063
- }
1064
-
1065
1125
  // pragma MARK: Result<DownloadState>
1066
1126
  using Result_DownloadState_ = Result<DownloadState>;
1067
1127
  inline Result_DownloadState_ create_Result_DownloadState_(DownloadState value) noexcept {
@@ -1314,15 +1374,6 @@ namespace margelo::nitro::nitroplayer::bridge::swift {
1314
1374
  return Result<std::vector<EqualizerPreset>>::withError(error);
1315
1375
  }
1316
1376
 
1317
- // pragma MARK: Result<std::variant<nitro::NullType, std::string>>
1318
- using Result_std__variant_nitro__NullType__std__string__ = Result<std::variant<nitro::NullType, std::string>>;
1319
- inline Result_std__variant_nitro__NullType__std__string__ create_Result_std__variant_nitro__NullType__std__string__(const std::variant<nitro::NullType, std::string>& value) noexcept {
1320
- return Result<std::variant<nitro::NullType, std::string>>::withValue(value);
1321
- }
1322
- inline Result_std__variant_nitro__NullType__std__string__ create_Result_std__variant_nitro__NullType__std__string__(const std::exception_ptr& error) noexcept {
1323
- return Result<std::variant<nitro::NullType, std::string>>::withError(error);
1324
- }
1325
-
1326
1377
  // pragma MARK: Result<std::shared_ptr<Promise<EqualizerState>>>
1327
1378
  using Result_std__shared_ptr_Promise_EqualizerState___ = Result<std::shared_ptr<Promise<EqualizerState>>>;
1328
1379
  inline Result_std__shared_ptr_Promise_EqualizerState___ create_Result_std__shared_ptr_Promise_EqualizerState___(const std::shared_ptr<Promise<EqualizerState>>& value) noexcept {
@@ -8,6 +8,8 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `CastState` to properly resolve imports.
12
+ namespace margelo::nitro::nitroplayer { enum class CastState; }
11
13
  // Forward declaration of `CurrentPlayingType` to properly resolve imports.
12
14
  namespace margelo::nitro::nitroplayer { enum class CurrentPlayingType; }
13
15
  // Forward declaration of `DownloadConfig` to properly resolve imports.
@@ -40,6 +42,8 @@ namespace margelo::nitro::nitroplayer { struct EqualizerState; }
40
42
  namespace margelo::nitro::nitroplayer { struct GainRange; }
41
43
  // Forward declaration of `HybridAudioRoutePickerSpec` to properly resolve imports.
42
44
  namespace margelo::nitro::nitroplayer { class HybridAudioRoutePickerSpec; }
45
+ // Forward declaration of `HybridCastSpec` to properly resolve imports.
46
+ namespace margelo::nitro::nitroplayer { class HybridCastSpec; }
43
47
  // Forward declaration of `HybridDownloadManagerSpec` to properly resolve imports.
44
48
  namespace margelo::nitro::nitroplayer { class HybridDownloadManagerSpec; }
45
49
  // Forward declaration of `HybridEqualizerSpec` to properly resolve imports.
@@ -72,6 +76,7 @@ namespace margelo::nitro::nitroplayer { struct TrackItem; }
72
76
  namespace margelo::nitro::nitroplayer { enum class TrackPlayerState; }
73
77
 
74
78
  // Include C++ defined types
79
+ #include "CastState.hpp"
75
80
  #include "CurrentPlayingType.hpp"
76
81
  #include "DownloadConfig.hpp"
77
82
  #include "DownloadError.hpp"
@@ -88,6 +93,7 @@ namespace margelo::nitro::nitroplayer { enum class TrackPlayerState; }
88
93
  #include "EqualizerState.hpp"
89
94
  #include "GainRange.hpp"
90
95
  #include "HybridAudioRoutePickerSpec.hpp"
96
+ #include "HybridCastSpec.hpp"
91
97
  #include "HybridDownloadManagerSpec.hpp"
92
98
  #include "HybridEqualizerSpec.hpp"
93
99
  #include "HybridPlayerQueueSpec.hpp"
@@ -127,6 +133,8 @@ namespace margelo::nitro::nitroplayer { enum class TrackPlayerState; }
127
133
  // Forward declarations of Swift defined types
128
134
  // Forward declaration of `HybridAudioRoutePickerSpec_cxx` to properly resolve imports.
129
135
  namespace NitroPlayer { class HybridAudioRoutePickerSpec_cxx; }
136
+ // Forward declaration of `HybridCastSpec_cxx` to properly resolve imports.
137
+ namespace NitroPlayer { class HybridCastSpec_cxx; }
130
138
  // Forward declaration of `HybridDownloadManagerSpec_cxx` to properly resolve imports.
131
139
  namespace NitroPlayer { class HybridDownloadManagerSpec_cxx; }
132
140
  // Forward declaration of `HybridEqualizerSpec_cxx` to properly resolve imports.
@@ -13,6 +13,7 @@
13
13
  #include "HybridPlayerQueueSpecSwift.hpp"
14
14
  #include "HybridTrackPlayerSpecSwift.hpp"
15
15
  #include "HybridAudioRoutePickerSpecSwift.hpp"
16
+ #include "HybridCastSpecSwift.hpp"
16
17
  #include "HybridDownloadManagerSpecSwift.hpp"
17
18
  #include "HybridEqualizerSpecSwift.hpp"
18
19
 
@@ -46,6 +47,13 @@
46
47
  return hybridObject;
47
48
  }
48
49
  );
50
+ HybridObjectRegistry::registerHybridObjectConstructor(
51
+ "Cast",
52
+ []() -> std::shared_ptr<HybridObject> {
53
+ std::shared_ptr<HybridCastSpec> hybridObject = NitroPlayer::NitroPlayerAutolinking::createCast();
54
+ return hybridObject;
55
+ }
56
+ );
49
57
  HybridObjectRegistry::registerHybridObjectConstructor(
50
58
  "DownloadManager",
51
59
  []() -> std::shared_ptr<HybridObject> {
@@ -48,6 +48,18 @@ public final class NitroPlayerAutolinking {
48
48
  return HybridAudioRoutePicker.self is any RecyclableView.Type
49
49
  }
50
50
 
51
+ public static func createCast() -> bridge.std__shared_ptr_HybridCastSpec_ {
52
+ let hybridObject = HybridCast()
53
+ return { () -> bridge.std__shared_ptr_HybridCastSpec_ in
54
+ let __cxxWrapped = hybridObject.getCxxWrapper()
55
+ return __cxxWrapped.getCxxPart()
56
+ }()
57
+ }
58
+
59
+ public static func isCastRecyclable() -> Bool {
60
+ return HybridCast.self is any RecyclableView.Type
61
+ }
62
+
51
63
  public static func createDownloadManager() -> bridge.std__shared_ptr_HybridDownloadManagerSpec_ {
52
64
  let hybridObject = HybridDownloadManager()
53
65
  return { () -> bridge.std__shared_ptr_HybridDownloadManagerSpec_ in
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridCastSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridCastSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::nitroplayer {
11
+ } // namespace margelo::nitro::nitroplayer
@@ -0,0 +1,133 @@
1
+ ///
2
+ /// HybridCastSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridCastSpec.hpp"
11
+
12
+ // Forward declaration of `HybridCastSpec_cxx` to properly resolve imports.
13
+ namespace NitroPlayer { class HybridCastSpec_cxx; }
14
+
15
+ // Forward declaration of `CastState` to properly resolve imports.
16
+ namespace margelo::nitro::nitroplayer { enum class CastState; }
17
+
18
+ #include <NitroModules/Promise.hpp>
19
+ #include <string>
20
+ #include <optional>
21
+ #include "CastState.hpp"
22
+ #include <NitroModules/Null.hpp>
23
+ #include <variant>
24
+ #include <functional>
25
+
26
+ #include "NitroPlayer-Swift-Cxx-Umbrella.hpp"
27
+
28
+ namespace margelo::nitro::nitroplayer {
29
+
30
+ /**
31
+ * The C++ part of HybridCastSpec_cxx.swift.
32
+ *
33
+ * HybridCastSpecSwift (C++) accesses HybridCastSpec_cxx (Swift), and might
34
+ * contain some additional bridging code for C++ <> Swift interop.
35
+ *
36
+ * Since this obviously introduces an overhead, I hope at some point in
37
+ * the future, HybridCastSpec_cxx can directly inherit from the C++ class HybridCastSpec
38
+ * to simplify the whole structure and memory management.
39
+ */
40
+ class HybridCastSpecSwift: public virtual HybridCastSpec {
41
+ public:
42
+ // Constructor from a Swift instance
43
+ explicit HybridCastSpecSwift(const NitroPlayer::HybridCastSpec_cxx& swiftPart):
44
+ HybridObject(HybridCastSpec::TAG),
45
+ _swiftPart(swiftPart) { }
46
+
47
+ public:
48
+ // Get the Swift part
49
+ inline NitroPlayer::HybridCastSpec_cxx& getSwiftPart() noexcept {
50
+ return _swiftPart;
51
+ }
52
+
53
+ public:
54
+ inline size_t getExternalMemorySize() noexcept override {
55
+ return _swiftPart.getMemorySize();
56
+ }
57
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
58
+ if (auto otherCast = std::dynamic_pointer_cast<HybridCastSpecSwift>(other)) {
59
+ return _swiftPart.equals(otherCast->_swiftPart);
60
+ }
61
+ return false;
62
+ }
63
+ void dispose() noexcept override {
64
+ _swiftPart.dispose();
65
+ }
66
+ std::string toString() override {
67
+ return _swiftPart.toString();
68
+ }
69
+
70
+ public:
71
+ // Properties
72
+
73
+
74
+ public:
75
+ // Methods
76
+ inline std::shared_ptr<Promise<void>> configure(const std::optional<std::string>& receiverApplicationId) override {
77
+ auto __result = _swiftPart.configure(receiverApplicationId);
78
+ if (__result.hasError()) [[unlikely]] {
79
+ std::rethrow_exception(__result.error());
80
+ }
81
+ auto __value = std::move(__result.value());
82
+ return __value;
83
+ }
84
+ inline bool isCasting() override {
85
+ auto __result = _swiftPart.isCasting();
86
+ if (__result.hasError()) [[unlikely]] {
87
+ std::rethrow_exception(__result.error());
88
+ }
89
+ auto __value = std::move(__result.value());
90
+ return __value;
91
+ }
92
+ inline CastState getCastState() override {
93
+ auto __result = _swiftPart.getCastState();
94
+ if (__result.hasError()) [[unlikely]] {
95
+ std::rethrow_exception(__result.error());
96
+ }
97
+ auto __value = std::move(__result.value());
98
+ return __value;
99
+ }
100
+ inline std::variant<nitro::NullType, std::string> getCastDeviceName() override {
101
+ auto __result = _swiftPart.getCastDeviceName();
102
+ if (__result.hasError()) [[unlikely]] {
103
+ std::rethrow_exception(__result.error());
104
+ }
105
+ auto __value = std::move(__result.value());
106
+ return __value;
107
+ }
108
+ inline void showCastPicker() override {
109
+ auto __result = _swiftPart.showCastPicker();
110
+ if (__result.hasError()) [[unlikely]] {
111
+ std::rethrow_exception(__result.error());
112
+ }
113
+ }
114
+ inline std::shared_ptr<Promise<void>> endCastSession() override {
115
+ auto __result = _swiftPart.endCastSession();
116
+ if (__result.hasError()) [[unlikely]] {
117
+ std::rethrow_exception(__result.error());
118
+ }
119
+ auto __value = std::move(__result.value());
120
+ return __value;
121
+ }
122
+ inline void onCastStateChange(const std::function<void(CastState /* state */, const std::optional<std::variant<nitro::NullType, std::string>>& /* deviceName */)>& callback) override {
123
+ auto __result = _swiftPart.onCastStateChange(callback);
124
+ if (__result.hasError()) [[unlikely]] {
125
+ std::rethrow_exception(__result.error());
126
+ }
127
+ }
128
+
129
+ private:
130
+ NitroPlayer::HybridCastSpec_cxx _swiftPart;
131
+ };
132
+
133
+ } // namespace margelo::nitro::nitroplayer