@neoskola/auto-play 0.2.18 → 0.3.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.
- package/ios/hybrid/HybridNowPlayingTemplate.swift +90 -0
- package/ios/templates/NowPlayingTemplate.swift +191 -0
- package/lib/specs/NowPlayingTemplate.nitro.d.ts +6 -0
- package/lib/templates/NowPlayingTemplate.d.ts +8 -0
- package/lib/templates/NowPlayingTemplate.js +18 -0
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +2 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridNowPlayingTemplateSpec.cpp +92 -0
- package/nitrogen/generated/android/c++/JHybridNowPlayingTemplateSpec.hpp +6 -0
- package/nitrogen/generated/android/c++/JNowPlayingTemplateConfig.hpp +27 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_double_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridNowPlayingTemplateSpec.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NowPlayingTemplateConfig.kt +11 -5
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +58 -0
- package/nitrogen/generated/ios/c++/HybridNowPlayingTemplateSpecSwift.hpp +48 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridNowPlayingTemplateSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridNowPlayingTemplateSpec_cxx.swift +114 -0
- package/nitrogen/generated/ios/swift/NowPlayingTemplateConfig.swift +83 -1
- package/nitrogen/generated/shared/c++/HybridNowPlayingTemplateSpec.cpp +6 -0
- package/nitrogen/generated/shared/c++/HybridNowPlayingTemplateSpec.hpp +6 -0
- package/nitrogen/generated/shared/c++/NowPlayingTemplateConfig.hpp +10 -2
- package/package.json +1 -1
- package/src/specs/NowPlayingTemplate.nitro.ts +8 -0
- package/src/templates/NowPlayingTemplate.ts +26 -0
|
@@ -19,7 +19,7 @@ public extension NowPlayingTemplateConfig {
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a new instance of `NowPlayingTemplateConfig`.
|
|
21
21
|
*/
|
|
22
|
-
init(id: String, onWillAppear: ((_ animated: Bool?) -> Void)?, onWillDisappear: ((_ animated: Bool?) -> Void)?, onDidAppear: ((_ animated: Bool?) -> Void)?, onDidDisappear: ((_ animated: Bool?) -> Void)?, onPopped: (() -> Void)?, autoDismissMs: Double?, title: AutoText, subtitle: AutoText?, courseId: String, lessonId: String, image: Variant_GlyphImage_AssetImage?, isPlaying: Bool, onPlay: (() -> Void)?, onPause: (() -> Void)?, onSkipForward: (() -> Void)?, onSkipBackward: (() -> Void)?, onComplete: (() -> Void)?) {
|
|
22
|
+
init(id: String, onWillAppear: ((_ animated: Bool?) -> Void)?, onWillDisappear: ((_ animated: Bool?) -> Void)?, onDidAppear: ((_ animated: Bool?) -> Void)?, onDidDisappear: ((_ animated: Bool?) -> Void)?, onPopped: (() -> Void)?, autoDismissMs: Double?, title: AutoText, subtitle: AutoText?, courseId: String, lessonId: String, image: Variant_GlyphImage_AssetImage?, isPlaying: Bool, onPlay: (() -> Void)?, onPause: (() -> Void)?, onSkipForward: (() -> Void)?, onSkipBackward: (() -> Void)?, onComplete: (() -> Void)?, onProgressUpdate: ((_ currentTime: Double, _ duration: Double) -> Void)?, onPlaybackFinished: (() -> Void)?) {
|
|
23
23
|
self.init(std.string(id), { () -> bridge.std__optional_std__function_void_std__optional_bool_____animated______ in
|
|
24
24
|
if let __unwrappedValue = onWillAppear {
|
|
25
25
|
return bridge.create_std__optional_std__function_void_std__optional_bool_____animated______({ () -> bridge.Func_void_std__optional_bool_ in
|
|
@@ -135,6 +135,24 @@ public extension NowPlayingTemplateConfig {
|
|
|
135
135
|
} else {
|
|
136
136
|
return .init()
|
|
137
137
|
}
|
|
138
|
+
}(), { () -> bridge.std__optional_std__function_void_double____currentTime_____double____duration______ in
|
|
139
|
+
if let __unwrappedValue = onProgressUpdate {
|
|
140
|
+
return bridge.create_std__optional_std__function_void_double____currentTime_____double____duration______({ () -> bridge.Func_void_double_double in
|
|
141
|
+
let __closureWrapper = Func_void_double_double(__unwrappedValue)
|
|
142
|
+
return bridge.create_Func_void_double_double(__closureWrapper.toUnsafe())
|
|
143
|
+
}())
|
|
144
|
+
} else {
|
|
145
|
+
return .init()
|
|
146
|
+
}
|
|
147
|
+
}(), { () -> bridge.std__optional_std__function_void____ in
|
|
148
|
+
if let __unwrappedValue = onPlaybackFinished {
|
|
149
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
150
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
151
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
152
|
+
}())
|
|
153
|
+
} else {
|
|
154
|
+
return .init()
|
|
155
|
+
}
|
|
138
156
|
}())
|
|
139
157
|
}
|
|
140
158
|
|
|
@@ -613,4 +631,68 @@ public extension NowPlayingTemplateConfig {
|
|
|
613
631
|
}()
|
|
614
632
|
}
|
|
615
633
|
}
|
|
634
|
+
|
|
635
|
+
var onProgressUpdate: ((_ currentTime: Double, _ duration: Double) -> Void)? {
|
|
636
|
+
@inline(__always)
|
|
637
|
+
get {
|
|
638
|
+
return { () -> ((_ currentTime: Double, _ duration: Double) -> Void)? in
|
|
639
|
+
if bridge.has_value_std__optional_std__function_void_double____currentTime_____double____duration______(self.__onProgressUpdate) {
|
|
640
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_double____currentTime_____double____duration______(self.__onProgressUpdate)
|
|
641
|
+
return { () -> (Double, Double) -> Void in
|
|
642
|
+
let __wrappedFunction = bridge.wrap_Func_void_double_double(__unwrapped)
|
|
643
|
+
return { (__currentTime: Double, __duration: Double) -> Void in
|
|
644
|
+
__wrappedFunction.call(__currentTime, __duration)
|
|
645
|
+
}
|
|
646
|
+
}()
|
|
647
|
+
} else {
|
|
648
|
+
return nil
|
|
649
|
+
}
|
|
650
|
+
}()
|
|
651
|
+
}
|
|
652
|
+
@inline(__always)
|
|
653
|
+
set {
|
|
654
|
+
self.__onProgressUpdate = { () -> bridge.std__optional_std__function_void_double____currentTime_____double____duration______ in
|
|
655
|
+
if let __unwrappedValue = newValue {
|
|
656
|
+
return bridge.create_std__optional_std__function_void_double____currentTime_____double____duration______({ () -> bridge.Func_void_double_double in
|
|
657
|
+
let __closureWrapper = Func_void_double_double(__unwrappedValue)
|
|
658
|
+
return bridge.create_Func_void_double_double(__closureWrapper.toUnsafe())
|
|
659
|
+
}())
|
|
660
|
+
} else {
|
|
661
|
+
return .init()
|
|
662
|
+
}
|
|
663
|
+
}()
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
var onPlaybackFinished: (() -> Void)? {
|
|
668
|
+
@inline(__always)
|
|
669
|
+
get {
|
|
670
|
+
return { () -> (() -> Void)? in
|
|
671
|
+
if bridge.has_value_std__optional_std__function_void____(self.__onPlaybackFinished) {
|
|
672
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(self.__onPlaybackFinished)
|
|
673
|
+
return { () -> () -> Void in
|
|
674
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
675
|
+
return { () -> Void in
|
|
676
|
+
__wrappedFunction.call()
|
|
677
|
+
}
|
|
678
|
+
}()
|
|
679
|
+
} else {
|
|
680
|
+
return nil
|
|
681
|
+
}
|
|
682
|
+
}()
|
|
683
|
+
}
|
|
684
|
+
@inline(__always)
|
|
685
|
+
set {
|
|
686
|
+
self.__onPlaybackFinished = { () -> bridge.std__optional_std__function_void____ in
|
|
687
|
+
if let __unwrappedValue = newValue {
|
|
688
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
689
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
690
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
691
|
+
}())
|
|
692
|
+
} else {
|
|
693
|
+
return .init()
|
|
694
|
+
}
|
|
695
|
+
}()
|
|
696
|
+
}
|
|
697
|
+
}
|
|
616
698
|
}
|
|
@@ -18,6 +18,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
18
18
|
prototype.registerHybridMethod("updateNowPlayingTemplatePlaybackState", &HybridNowPlayingTemplateSpec::updateNowPlayingTemplatePlaybackState);
|
|
19
19
|
prototype.registerHybridMethod("updateNowPlayingTemplateInfo", &HybridNowPlayingTemplateSpec::updateNowPlayingTemplateInfo);
|
|
20
20
|
prototype.registerHybridMethod("updateNowPlayingTemplateElapsedTime", &HybridNowPlayingTemplateSpec::updateNowPlayingTemplateElapsedTime);
|
|
21
|
+
prototype.registerHybridMethod("playAudio", &HybridNowPlayingTemplateSpec::playAudio);
|
|
22
|
+
prototype.registerHybridMethod("pauseAudio", &HybridNowPlayingTemplateSpec::pauseAudio);
|
|
23
|
+
prototype.registerHybridMethod("resumeAudio", &HybridNowPlayingTemplateSpec::resumeAudio);
|
|
24
|
+
prototype.registerHybridMethod("seekForward", &HybridNowPlayingTemplateSpec::seekForward);
|
|
25
|
+
prototype.registerHybridMethod("seekBackward", &HybridNowPlayingTemplateSpec::seekBackward);
|
|
26
|
+
prototype.registerHybridMethod("stopAudio", &HybridNowPlayingTemplateSpec::stopAudio);
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
29
|
|
|
@@ -55,6 +55,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
55
55
|
virtual std::shared_ptr<Promise<void>> updateNowPlayingTemplatePlaybackState(const std::string& templateId, bool isPlaying) = 0;
|
|
56
56
|
virtual std::shared_ptr<Promise<void>> updateNowPlayingTemplateInfo(const std::string& templateId, const std::string& title, const std::string& subtitle) = 0;
|
|
57
57
|
virtual std::shared_ptr<Promise<void>> updateNowPlayingTemplateElapsedTime(const std::string& templateId, double elapsedTime, double duration) = 0;
|
|
58
|
+
virtual std::shared_ptr<Promise<bool>> playAudio(const std::string& templateId, const std::string& url, double startFrom) = 0;
|
|
59
|
+
virtual std::shared_ptr<Promise<void>> pauseAudio(const std::string& templateId) = 0;
|
|
60
|
+
virtual std::shared_ptr<Promise<void>> resumeAudio(const std::string& templateId) = 0;
|
|
61
|
+
virtual std::shared_ptr<Promise<void>> seekForward(const std::string& templateId, double seconds) = 0;
|
|
62
|
+
virtual std::shared_ptr<Promise<void>> seekBackward(const std::string& templateId, double seconds) = 0;
|
|
63
|
+
virtual std::shared_ptr<Promise<void>> stopAudio(const std::string& templateId) = 0;
|
|
58
64
|
|
|
59
65
|
protected:
|
|
60
66
|
// Hybrid Setup
|
|
@@ -63,10 +63,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
63
63
|
std::optional<std::function<void()>> onSkipForward SWIFT_PRIVATE;
|
|
64
64
|
std::optional<std::function<void()>> onSkipBackward SWIFT_PRIVATE;
|
|
65
65
|
std::optional<std::function<void()>> onComplete SWIFT_PRIVATE;
|
|
66
|
+
std::optional<std::function<void(double /* currentTime */, double /* duration */)>> onProgressUpdate SWIFT_PRIVATE;
|
|
67
|
+
std::optional<std::function<void()>> onPlaybackFinished SWIFT_PRIVATE;
|
|
66
68
|
|
|
67
69
|
public:
|
|
68
70
|
NowPlayingTemplateConfig() = default;
|
|
69
|
-
explicit NowPlayingTemplateConfig(std::string id, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillDisappear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidDisappear, std::optional<std::function<void()>> onPopped, std::optional<double> autoDismissMs, AutoText title, std::optional<AutoText> subtitle, std::string courseId, std::string lessonId, std::optional<std::variant<GlyphImage, AssetImage>> image, bool isPlaying, std::optional<std::function<void()>> onPlay, std::optional<std::function<void()>> onPause, std::optional<std::function<void()>> onSkipForward, std::optional<std::function<void()>> onSkipBackward, std::optional<std::function<void()>> onComplete): id(id), onWillAppear(onWillAppear), onWillDisappear(onWillDisappear), onDidAppear(onDidAppear), onDidDisappear(onDidDisappear), onPopped(onPopped), autoDismissMs(autoDismissMs), title(title), subtitle(subtitle), courseId(courseId), lessonId(lessonId), image(image), isPlaying(isPlaying), onPlay(onPlay), onPause(onPause), onSkipForward(onSkipForward), onSkipBackward(onSkipBackward), onComplete(onComplete) {}
|
|
71
|
+
explicit NowPlayingTemplateConfig(std::string id, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillDisappear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidDisappear, std::optional<std::function<void()>> onPopped, std::optional<double> autoDismissMs, AutoText title, std::optional<AutoText> subtitle, std::string courseId, std::string lessonId, std::optional<std::variant<GlyphImage, AssetImage>> image, bool isPlaying, std::optional<std::function<void()>> onPlay, std::optional<std::function<void()>> onPause, std::optional<std::function<void()>> onSkipForward, std::optional<std::function<void()>> onSkipBackward, std::optional<std::function<void()>> onComplete, std::optional<std::function<void(double /* currentTime */, double /* duration */)>> onProgressUpdate, std::optional<std::function<void()>> onPlaybackFinished): id(id), onWillAppear(onWillAppear), onWillDisappear(onWillDisappear), onDidAppear(onDidAppear), onDidDisappear(onDidDisappear), onPopped(onPopped), autoDismissMs(autoDismissMs), title(title), subtitle(subtitle), courseId(courseId), lessonId(lessonId), image(image), isPlaying(isPlaying), onPlay(onPlay), onPause(onPause), onSkipForward(onSkipForward), onSkipBackward(onSkipBackward), onComplete(onComplete), onProgressUpdate(onProgressUpdate), onPlaybackFinished(onPlaybackFinished) {}
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -96,7 +98,9 @@ namespace margelo::nitro {
|
|
|
96
98
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onPause")),
|
|
97
99
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onSkipForward")),
|
|
98
100
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onSkipBackward")),
|
|
99
|
-
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onComplete"))
|
|
101
|
+
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onComplete")),
|
|
102
|
+
JSIConverter<std::optional<std::function<void(double, double)>>>::fromJSI(runtime, obj.getProperty(runtime, "onProgressUpdate")),
|
|
103
|
+
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onPlaybackFinished"))
|
|
100
104
|
);
|
|
101
105
|
}
|
|
102
106
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::NowPlayingTemplateConfig& arg) {
|
|
@@ -119,6 +123,8 @@ namespace margelo::nitro {
|
|
|
119
123
|
obj.setProperty(runtime, "onSkipForward", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onSkipForward));
|
|
120
124
|
obj.setProperty(runtime, "onSkipBackward", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onSkipBackward));
|
|
121
125
|
obj.setProperty(runtime, "onComplete", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onComplete));
|
|
126
|
+
obj.setProperty(runtime, "onProgressUpdate", JSIConverter<std::optional<std::function<void(double, double)>>>::toJSI(runtime, arg.onProgressUpdate));
|
|
127
|
+
obj.setProperty(runtime, "onPlaybackFinished", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onPlaybackFinished));
|
|
122
128
|
return obj;
|
|
123
129
|
}
|
|
124
130
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -147,6 +153,8 @@ namespace margelo::nitro {
|
|
|
147
153
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onSkipForward"))) return false;
|
|
148
154
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onSkipBackward"))) return false;
|
|
149
155
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onComplete"))) return false;
|
|
156
|
+
if (!JSIConverter<std::optional<std::function<void(double, double)>>>::canConvert(runtime, obj.getProperty(runtime, "onProgressUpdate"))) return false;
|
|
157
|
+
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onPlaybackFinished"))) return false;
|
|
150
158
|
return true;
|
|
151
159
|
}
|
|
152
160
|
};
|
package/package.json
CHANGED
|
@@ -9,4 +9,12 @@ export interface NowPlayingTemplate extends HybridObject<{ android: 'kotlin'; io
|
|
|
9
9
|
updateNowPlayingTemplatePlaybackState(templateId: string, isPlaying: boolean): Promise<void>;
|
|
10
10
|
updateNowPlayingTemplateInfo(templateId: string, title: string, subtitle: string): Promise<void>;
|
|
11
11
|
updateNowPlayingTemplateElapsedTime(templateId: string, elapsedTime: number, duration: number): Promise<void>;
|
|
12
|
+
|
|
13
|
+
// Native audio playback
|
|
14
|
+
playAudio(templateId: string, url: string, startFrom: number): Promise<boolean>;
|
|
15
|
+
pauseAudio(templateId: string): Promise<void>;
|
|
16
|
+
resumeAudio(templateId: string): Promise<void>;
|
|
17
|
+
seekForward(templateId: string, seconds: number): Promise<void>;
|
|
18
|
+
seekBackward(templateId: string, seconds: number): Promise<void>;
|
|
19
|
+
stopAudio(templateId: string): Promise<void>;
|
|
12
20
|
}
|
|
@@ -25,6 +25,8 @@ export interface NitroNowPlayingTemplateConfig extends TemplateConfig {
|
|
|
25
25
|
onSkipForward?: () => void;
|
|
26
26
|
onSkipBackward?: () => void;
|
|
27
27
|
onComplete?: () => void;
|
|
28
|
+
onProgressUpdate?: (currentTime: number, duration: number) => void;
|
|
29
|
+
onPlaybackFinished?: () => void;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export type NowPlayingTemplateConfig = Omit<
|
|
@@ -63,4 +65,28 @@ export class NowPlayingTemplate extends Template<
|
|
|
63
65
|
public updateElapsedTime(elapsedTime: number, duration: number) {
|
|
64
66
|
return HybridNowPlayingTemplate.updateNowPlayingTemplateElapsedTime(this.id, elapsedTime, duration);
|
|
65
67
|
}
|
|
68
|
+
|
|
69
|
+
public playAudio(url: string, startFrom: number = 0): Promise<boolean> {
|
|
70
|
+
return HybridNowPlayingTemplate.playAudio(this.id, url, startFrom);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public pauseAudio(): Promise<void> {
|
|
74
|
+
return HybridNowPlayingTemplate.pauseAudio(this.id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public resumeAudio(): Promise<void> {
|
|
78
|
+
return HybridNowPlayingTemplate.resumeAudio(this.id);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public seekForward(seconds: number = 30): Promise<void> {
|
|
82
|
+
return HybridNowPlayingTemplate.seekForward(this.id, seconds);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public seekBackward(seconds: number = 30): Promise<void> {
|
|
86
|
+
return HybridNowPlayingTemplate.seekBackward(this.id, seconds);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public stopAudio(): Promise<void> {
|
|
90
|
+
return HybridNowPlayingTemplate.stopAudio(this.id);
|
|
91
|
+
}
|
|
66
92
|
}
|