@neoskola/auto-play 0.3.5 → 0.3.7
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/NowPlayingTemplate.kt +15 -5
- package/ios/templates/NowPlayingTemplate.swift +142 -20
- package/lib/templates/NowPlayingTemplate.d.ts +2 -0
- package/nitrogen/generated/android/c++/JNowPlayingTemplateConfig.hpp +25 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NowPlayingTemplateConfig.kt +10 -4
- package/nitrogen/generated/ios/swift/NowPlayingTemplateConfig.swift +83 -1
- package/nitrogen/generated/shared/c++/NowPlayingTemplateConfig.hpp +9 -1
- package/package.json +1 -1
- package/src/templates/NowPlayingTemplate.ts +2 -0
|
@@ -33,7 +33,17 @@ class NowPlayingTemplate(context: CarContext, config: NowPlayingTemplateConfig)
|
|
|
33
33
|
.build()
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// Onceki Bolum butonu
|
|
37
|
+
config.onPreviousTrack?.let { prevTrack ->
|
|
38
|
+
paneBuilder.addAction(
|
|
39
|
+
Action.Builder()
|
|
40
|
+
.setTitle(CarText.create("Önceki"))
|
|
41
|
+
.setOnClickListener { prevTrack() }
|
|
42
|
+
.build()
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Play/Pause butonu
|
|
37
47
|
val playPauseTitle = if (config.isPlaying) "Duraklat" else "Oynat"
|
|
38
48
|
paneBuilder.addAction(
|
|
39
49
|
Action.Builder()
|
|
@@ -48,12 +58,12 @@ class NowPlayingTemplate(context: CarContext, config: NowPlayingTemplateConfig)
|
|
|
48
58
|
.build()
|
|
49
59
|
)
|
|
50
60
|
|
|
51
|
-
//
|
|
52
|
-
config.
|
|
61
|
+
// Sonraki Bolum butonu
|
|
62
|
+
config.onNextTrack?.let { nextTrack ->
|
|
53
63
|
paneBuilder.addAction(
|
|
54
64
|
Action.Builder()
|
|
55
|
-
.setTitle(CarText.create("
|
|
56
|
-
.setOnClickListener {
|
|
65
|
+
.setTitle(CarText.create("Sonraki"))
|
|
66
|
+
.setOnClickListener { nextTrack() }
|
|
57
67
|
.build()
|
|
58
68
|
)
|
|
59
69
|
}
|
|
@@ -34,10 +34,10 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
34
34
|
init(config: NowPlayingTemplateConfig) {
|
|
35
35
|
self.config = config
|
|
36
36
|
|
|
37
|
-
// Custom player screen using CPListTemplate instead of CPNowPlayingTemplate.shared
|
|
38
37
|
let titleText = Parser.parseText(text: config.title) ?? "Now Playing"
|
|
39
38
|
let subtitleText = config.subtitle.flatMap { Parser.parseText(text: $0) } ?? ""
|
|
40
39
|
|
|
40
|
+
// Section 1: Bilgi — ders ve kurs adi
|
|
41
41
|
let infoItem = CPListItem(
|
|
42
42
|
text: titleText,
|
|
43
43
|
detailText: subtitleText,
|
|
@@ -45,28 +45,64 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
45
45
|
accessoryImage: nil,
|
|
46
46
|
accessoryType: .none
|
|
47
47
|
)
|
|
48
|
+
let infoSection = CPListSection(
|
|
49
|
+
items: [infoItem],
|
|
50
|
+
header: "Şimdi Oynatılıyor",
|
|
51
|
+
sectionIndexTitle: nil
|
|
52
|
+
)
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
// Section 2: Sure bilgisi
|
|
55
|
+
let timeItem = CPListItem(
|
|
50
56
|
text: "Yükleniyor...",
|
|
51
57
|
detailText: nil,
|
|
52
|
-
image: UIImage(systemName: "
|
|
58
|
+
image: UIImage(systemName: "clock"),
|
|
53
59
|
accessoryImage: nil,
|
|
54
60
|
accessoryType: .none
|
|
55
61
|
)
|
|
62
|
+
let timeSection = CPListSection(
|
|
63
|
+
items: [timeItem],
|
|
64
|
+
header: nil,
|
|
65
|
+
sectionIndexTitle: nil
|
|
66
|
+
)
|
|
56
67
|
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
// Section 3: Kontroller — onceki, oynat/duraklat, sonraki
|
|
69
|
+
let prevItem = CPListItem(
|
|
70
|
+
text: "Önceki Bölüm",
|
|
71
|
+
detailText: nil,
|
|
72
|
+
image: UIImage(systemName: "backward.end.fill"),
|
|
73
|
+
accessoryImage: nil,
|
|
74
|
+
accessoryType: .none
|
|
75
|
+
)
|
|
76
|
+
let playPauseItem = CPListItem(
|
|
77
|
+
text: "Oynat",
|
|
78
|
+
detailText: nil,
|
|
79
|
+
image: UIImage(systemName: "play.circle.fill"),
|
|
80
|
+
accessoryImage: nil,
|
|
81
|
+
accessoryType: .none
|
|
82
|
+
)
|
|
83
|
+
let nextItem = CPListItem(
|
|
84
|
+
text: "Sonraki Bölüm",
|
|
85
|
+
detailText: nil,
|
|
86
|
+
image: UIImage(systemName: "forward.end.fill"),
|
|
87
|
+
accessoryImage: nil,
|
|
88
|
+
accessoryType: .none
|
|
89
|
+
)
|
|
90
|
+
let controlSection = CPListSection(
|
|
91
|
+
items: [prevItem, playPauseItem, nextItem],
|
|
59
92
|
header: nil,
|
|
60
93
|
sectionIndexTitle: nil
|
|
61
94
|
)
|
|
62
95
|
|
|
63
96
|
template = CPListTemplate(
|
|
64
97
|
title: "Now Playing",
|
|
65
|
-
sections: [
|
|
98
|
+
sections: [infoSection, timeSection, controlSection],
|
|
66
99
|
assistantCellConfiguration: nil,
|
|
67
100
|
id: config.id
|
|
68
101
|
)
|
|
69
102
|
|
|
103
|
+
// Handler'lari ayarla
|
|
104
|
+
setupListItemHandlers(prevItem: prevItem, playPauseItem: playPauseItem, nextItem: nextItem)
|
|
105
|
+
|
|
70
106
|
DispatchQueue.main.async { [weak self] in
|
|
71
107
|
guard let self = self else { return }
|
|
72
108
|
NowPlayingSessionManager.shared.ensureSessionActive()
|
|
@@ -80,12 +116,41 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
80
116
|
}
|
|
81
117
|
}
|
|
82
118
|
|
|
119
|
+
// MARK: - List Item Handlers
|
|
120
|
+
|
|
121
|
+
private func setupListItemHandlers(prevItem: CPListItem, playPauseItem: CPListItem, nextItem: CPListItem) {
|
|
122
|
+
prevItem.handler = { [weak self] _, completion in
|
|
123
|
+
self?.config.onPreviousTrack?()
|
|
124
|
+
completion()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
playPauseItem.handler = { [weak self] _, completion in
|
|
128
|
+
DispatchQueue.main.async {
|
|
129
|
+
guard let self = self else { completion(); return }
|
|
130
|
+
if self.config.isPlaying {
|
|
131
|
+
self.pauseAudio()
|
|
132
|
+
self.config.onPause?()
|
|
133
|
+
} else {
|
|
134
|
+
self.resumeAudio()
|
|
135
|
+
self.config.onPlay?()
|
|
136
|
+
}
|
|
137
|
+
completion()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
nextItem.handler = { [weak self] _, completion in
|
|
142
|
+
self?.config.onNextTrack?()
|
|
143
|
+
completion()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
83
147
|
// MARK: - Player UI
|
|
84
148
|
|
|
85
149
|
private func updatePlayerUI() {
|
|
86
150
|
let titleText = Parser.parseText(text: config.title) ?? "Now Playing"
|
|
87
151
|
let subtitleText = config.subtitle.flatMap { Parser.parseText(text: $0) } ?? ""
|
|
88
152
|
|
|
153
|
+
// Section 1: Bilgi
|
|
89
154
|
let infoItem = CPListItem(
|
|
90
155
|
text: titleText,
|
|
91
156
|
detailText: subtitleText,
|
|
@@ -93,34 +158,73 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
93
158
|
accessoryImage: nil,
|
|
94
159
|
accessoryType: .none
|
|
95
160
|
)
|
|
161
|
+
let infoSection = CPListSection(
|
|
162
|
+
items: [infoItem],
|
|
163
|
+
header: "Şimdi Oynatılıyor",
|
|
164
|
+
sectionIndexTitle: nil
|
|
165
|
+
)
|
|
96
166
|
|
|
97
|
-
|
|
98
|
-
let
|
|
167
|
+
// Section 2: Sure
|
|
168
|
+
let elapsed = formatTime(currentElapsedTime)
|
|
169
|
+
let total = currentDuration > 0 ? formatTime(currentDuration) : "--:--"
|
|
170
|
+
let timeText: String
|
|
171
|
+
let timeIcon: String
|
|
99
172
|
if config.isPlaying {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
statusText = "Playing \(elapsed) / \(total)"
|
|
103
|
-
statusIcon = "play.circle.fill"
|
|
173
|
+
timeText = "\(elapsed) / \(total)"
|
|
174
|
+
timeIcon = "waveform"
|
|
104
175
|
} else {
|
|
105
|
-
|
|
106
|
-
|
|
176
|
+
timeText = "Duraklatıldı \(elapsed) / \(total)"
|
|
177
|
+
timeIcon = "pause.circle"
|
|
107
178
|
}
|
|
179
|
+
let timeItem = CPListItem(
|
|
180
|
+
text: timeText,
|
|
181
|
+
detailText: nil,
|
|
182
|
+
image: UIImage(systemName: timeIcon),
|
|
183
|
+
accessoryImage: nil,
|
|
184
|
+
accessoryType: .none
|
|
185
|
+
)
|
|
186
|
+
let timeSection = CPListSection(
|
|
187
|
+
items: [timeItem],
|
|
188
|
+
header: nil,
|
|
189
|
+
sectionIndexTitle: nil
|
|
190
|
+
)
|
|
108
191
|
|
|
109
|
-
|
|
110
|
-
|
|
192
|
+
// Section 3: Kontroller
|
|
193
|
+
let prevItem = CPListItem(
|
|
194
|
+
text: "Önceki Bölüm",
|
|
111
195
|
detailText: nil,
|
|
112
|
-
image: UIImage(systemName:
|
|
196
|
+
image: UIImage(systemName: "backward.end.fill"),
|
|
113
197
|
accessoryImage: nil,
|
|
114
198
|
accessoryType: .none
|
|
115
199
|
)
|
|
116
200
|
|
|
117
|
-
let
|
|
118
|
-
|
|
201
|
+
let playPauseText = config.isPlaying ? "Duraklat" : "Oynat"
|
|
202
|
+
let playPauseIcon = config.isPlaying ? "pause.circle.fill" : "play.circle.fill"
|
|
203
|
+
let playPauseItem = CPListItem(
|
|
204
|
+
text: playPauseText,
|
|
205
|
+
detailText: nil,
|
|
206
|
+
image: UIImage(systemName: playPauseIcon),
|
|
207
|
+
accessoryImage: nil,
|
|
208
|
+
accessoryType: .none
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
let nextItem = CPListItem(
|
|
212
|
+
text: "Sonraki Bölüm",
|
|
213
|
+
detailText: nil,
|
|
214
|
+
image: UIImage(systemName: "forward.end.fill"),
|
|
215
|
+
accessoryImage: nil,
|
|
216
|
+
accessoryType: .none
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
setupListItemHandlers(prevItem: prevItem, playPauseItem: playPauseItem, nextItem: nextItem)
|
|
220
|
+
|
|
221
|
+
let controlSection = CPListSection(
|
|
222
|
+
items: [prevItem, playPauseItem, nextItem],
|
|
119
223
|
header: nil,
|
|
120
224
|
sectionIndexTitle: nil
|
|
121
225
|
)
|
|
122
226
|
|
|
123
|
-
template.updateSections([
|
|
227
|
+
template.updateSections([infoSection, timeSection, controlSection])
|
|
124
228
|
}
|
|
125
229
|
|
|
126
230
|
private func formatTime(_ seconds: Double) -> String {
|
|
@@ -436,6 +540,22 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
436
540
|
return .success
|
|
437
541
|
}
|
|
438
542
|
|
|
543
|
+
// Sonraki bolum
|
|
544
|
+
commandCenter.nextTrackCommand.isEnabled = true
|
|
545
|
+
commandCenter.nextTrackCommand.removeTarget(nil)
|
|
546
|
+
commandCenter.nextTrackCommand.addTarget { [weak self] _ in
|
|
547
|
+
self?.config.onNextTrack?()
|
|
548
|
+
return .success
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// Onceki bolum
|
|
552
|
+
commandCenter.previousTrackCommand.isEnabled = true
|
|
553
|
+
commandCenter.previousTrackCommand.removeTarget(nil)
|
|
554
|
+
commandCenter.previousTrackCommand.addTarget { [weak self] _ in
|
|
555
|
+
self?.config.onPreviousTrack?()
|
|
556
|
+
return .success
|
|
557
|
+
}
|
|
558
|
+
|
|
439
559
|
commandCenter.changePlaybackPositionCommand.isEnabled = true
|
|
440
560
|
commandCenter.changePlaybackPositionCommand.removeTarget(nil)
|
|
441
561
|
commandCenter.changePlaybackPositionCommand.addTarget { [weak self] event in
|
|
@@ -506,6 +626,8 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
506
626
|
commandCenter.pauseCommand.removeTarget(nil)
|
|
507
627
|
commandCenter.skipForwardCommand.removeTarget(nil)
|
|
508
628
|
commandCenter.skipBackwardCommand.removeTarget(nil)
|
|
629
|
+
commandCenter.nextTrackCommand.removeTarget(nil)
|
|
630
|
+
commandCenter.previousTrackCommand.removeTarget(nil)
|
|
509
631
|
commandCenter.changePlaybackPositionCommand.removeTarget(nil)
|
|
510
632
|
|
|
511
633
|
MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
|
|
@@ -13,6 +13,8 @@ export interface NitroNowPlayingTemplateConfig extends TemplateConfig {
|
|
|
13
13
|
onPause?: () => void;
|
|
14
14
|
onSkipForward?: () => void;
|
|
15
15
|
onSkipBackward?: () => void;
|
|
16
|
+
onNextTrack?: () => void;
|
|
17
|
+
onPreviousTrack?: () => void;
|
|
16
18
|
onComplete?: () => void;
|
|
17
19
|
onProgressUpdate?: (currentTime: number, duration: number) => void;
|
|
18
20
|
onPlaybackFinished?: () => void;
|
|
@@ -85,6 +85,10 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
85
85
|
jni::local_ref<JFunc_void::javaobject> onSkipForward = this->getFieldValue(fieldOnSkipForward);
|
|
86
86
|
static const auto fieldOnSkipBackward = clazz->getField<JFunc_void::javaobject>("onSkipBackward");
|
|
87
87
|
jni::local_ref<JFunc_void::javaobject> onSkipBackward = this->getFieldValue(fieldOnSkipBackward);
|
|
88
|
+
static const auto fieldOnNextTrack = clazz->getField<JFunc_void::javaobject>("onNextTrack");
|
|
89
|
+
jni::local_ref<JFunc_void::javaobject> onNextTrack = this->getFieldValue(fieldOnNextTrack);
|
|
90
|
+
static const auto fieldOnPreviousTrack = clazz->getField<JFunc_void::javaobject>("onPreviousTrack");
|
|
91
|
+
jni::local_ref<JFunc_void::javaobject> onPreviousTrack = this->getFieldValue(fieldOnPreviousTrack);
|
|
88
92
|
static const auto fieldOnComplete = clazz->getField<JFunc_void::javaobject>("onComplete");
|
|
89
93
|
jni::local_ref<JFunc_void::javaobject> onComplete = this->getFieldValue(fieldOnComplete);
|
|
90
94
|
static const auto fieldOnProgressUpdate = clazz->getField<JFunc_void_double_double::javaobject>("onProgressUpdate");
|
|
@@ -181,6 +185,24 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
181
185
|
return JNICallable<JFunc_void, void()>(std::move(onSkipBackwardRef));
|
|
182
186
|
}
|
|
183
187
|
}()) : std::nullopt,
|
|
188
|
+
onNextTrack != nullptr ? std::make_optional([&]() -> std::function<void()> {
|
|
189
|
+
if (onNextTrack->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
190
|
+
auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(onNextTrack);
|
|
191
|
+
return downcast->cthis()->getFunction();
|
|
192
|
+
} else {
|
|
193
|
+
auto onNextTrackRef = jni::make_global(onNextTrack);
|
|
194
|
+
return JNICallable<JFunc_void, void()>(std::move(onNextTrackRef));
|
|
195
|
+
}
|
|
196
|
+
}()) : std::nullopt,
|
|
197
|
+
onPreviousTrack != nullptr ? std::make_optional([&]() -> std::function<void()> {
|
|
198
|
+
if (onPreviousTrack->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
199
|
+
auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(onPreviousTrack);
|
|
200
|
+
return downcast->cthis()->getFunction();
|
|
201
|
+
} else {
|
|
202
|
+
auto onPreviousTrackRef = jni::make_global(onPreviousTrack);
|
|
203
|
+
return JNICallable<JFunc_void, void()>(std::move(onPreviousTrackRef));
|
|
204
|
+
}
|
|
205
|
+
}()) : std::nullopt,
|
|
184
206
|
onComplete != nullptr ? std::make_optional([&]() -> std::function<void()> {
|
|
185
207
|
if (onComplete->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
186
208
|
auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(onComplete);
|
|
@@ -217,7 +239,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
217
239
|
*/
|
|
218
240
|
[[maybe_unused]]
|
|
219
241
|
static jni::local_ref<JNowPlayingTemplateConfig::javaobject> fromCpp(const NowPlayingTemplateConfig& value) {
|
|
220
|
-
using JSignature = JNowPlayingTemplateConfig(jni::alias_ref<jni::JString>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JAutoText>, jni::alias_ref<JAutoText>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JVariant_GlyphImage_AssetImage>, jboolean, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void_double_double::javaobject>, jni::alias_ref<JFunc_void::javaobject>);
|
|
242
|
+
using JSignature = JNowPlayingTemplateConfig(jni::alias_ref<jni::JString>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void_std__optional_bool_::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JAutoText>, jni::alias_ref<JAutoText>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JVariant_GlyphImage_AssetImage>, jboolean, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void::javaobject>, jni::alias_ref<JFunc_void_double_double::javaobject>, jni::alias_ref<JFunc_void::javaobject>);
|
|
221
243
|
static const auto clazz = javaClassStatic();
|
|
222
244
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
223
245
|
return create(
|
|
@@ -239,6 +261,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
239
261
|
value.onPause.has_value() ? JFunc_void_cxx::fromCpp(value.onPause.value()) : nullptr,
|
|
240
262
|
value.onSkipForward.has_value() ? JFunc_void_cxx::fromCpp(value.onSkipForward.value()) : nullptr,
|
|
241
263
|
value.onSkipBackward.has_value() ? JFunc_void_cxx::fromCpp(value.onSkipBackward.value()) : nullptr,
|
|
264
|
+
value.onNextTrack.has_value() ? JFunc_void_cxx::fromCpp(value.onNextTrack.value()) : nullptr,
|
|
265
|
+
value.onPreviousTrack.has_value() ? JFunc_void_cxx::fromCpp(value.onPreviousTrack.value()) : nullptr,
|
|
242
266
|
value.onComplete.has_value() ? JFunc_void_cxx::fromCpp(value.onComplete.value()) : nullptr,
|
|
243
267
|
value.onProgressUpdate.has_value() ? JFunc_void_double_double_cxx::fromCpp(value.onProgressUpdate.value()) : nullptr,
|
|
244
268
|
value.onPlaybackFinished.has_value() ? JFunc_void_cxx::fromCpp(value.onPlaybackFinished.value()) : nullptr
|
|
@@ -70,6 +70,12 @@ data class NowPlayingTemplateConfig(
|
|
|
70
70
|
val onSkipBackward: Func_void?,
|
|
71
71
|
@DoNotStrip
|
|
72
72
|
@Keep
|
|
73
|
+
val onNextTrack: Func_void?,
|
|
74
|
+
@DoNotStrip
|
|
75
|
+
@Keep
|
|
76
|
+
val onPreviousTrack: Func_void?,
|
|
77
|
+
@DoNotStrip
|
|
78
|
+
@Keep
|
|
73
79
|
val onComplete: Func_void?,
|
|
74
80
|
@DoNotStrip
|
|
75
81
|
@Keep
|
|
@@ -81,8 +87,8 @@ data class NowPlayingTemplateConfig(
|
|
|
81
87
|
/**
|
|
82
88
|
* Create a new instance of NowPlayingTemplateConfig from Kotlin
|
|
83
89
|
*/
|
|
84
|
-
constructor(id: String, onWillAppear: ((animated: Boolean?) -> Unit)?, onWillDisappear: ((animated: Boolean?) -> Unit)?, onDidAppear: ((animated: Boolean?) -> Unit)?, onDidDisappear: ((animated: Boolean?) -> Unit)?, onPopped: (() -> Unit)?, autoDismissMs: Double?, title: AutoText, subtitle: AutoText?, courseId: String, lessonId: String, image: Variant_GlyphImage_AssetImage?, isPlaying: Boolean, onPlay: (() -> Unit)?, onPause: (() -> Unit)?, onSkipForward: (() -> Unit)?, onSkipBackward: (() -> Unit)?, onComplete: (() -> Unit)?, onProgressUpdate: ((currentTime: Double, duration: Double) -> Unit)?, onPlaybackFinished: (() -> Unit)?):
|
|
85
|
-
this(id, onWillAppear?.let { Func_void_std__optional_bool__java(it) }, onWillDisappear?.let { Func_void_std__optional_bool__java(it) }, onDidAppear?.let { Func_void_std__optional_bool__java(it) }, onDidDisappear?.let { Func_void_std__optional_bool__java(it) }, onPopped?.let { Func_void_java(it) }, autoDismissMs, title, subtitle, courseId, lessonId, image, isPlaying, onPlay?.let { Func_void_java(it) }, onPause?.let { Func_void_java(it) }, onSkipForward?.let { Func_void_java(it) }, onSkipBackward?.let { Func_void_java(it) }, onComplete?.let { Func_void_java(it) }, onProgressUpdate?.let { Func_void_double_double_java(it) }, onPlaybackFinished?.let { Func_void_java(it) })
|
|
90
|
+
constructor(id: String, onWillAppear: ((animated: Boolean?) -> Unit)?, onWillDisappear: ((animated: Boolean?) -> Unit)?, onDidAppear: ((animated: Boolean?) -> Unit)?, onDidDisappear: ((animated: Boolean?) -> Unit)?, onPopped: (() -> Unit)?, autoDismissMs: Double?, title: AutoText, subtitle: AutoText?, courseId: String, lessonId: String, image: Variant_GlyphImage_AssetImage?, isPlaying: Boolean, onPlay: (() -> Unit)?, onPause: (() -> Unit)?, onSkipForward: (() -> Unit)?, onSkipBackward: (() -> Unit)?, onNextTrack: (() -> Unit)?, onPreviousTrack: (() -> Unit)?, onComplete: (() -> Unit)?, onProgressUpdate: ((currentTime: Double, duration: Double) -> Unit)?, onPlaybackFinished: (() -> Unit)?):
|
|
91
|
+
this(id, onWillAppear?.let { Func_void_std__optional_bool__java(it) }, onWillDisappear?.let { Func_void_std__optional_bool__java(it) }, onDidAppear?.let { Func_void_std__optional_bool__java(it) }, onDidDisappear?.let { Func_void_std__optional_bool__java(it) }, onPopped?.let { Func_void_java(it) }, autoDismissMs, title, subtitle, courseId, lessonId, image, isPlaying, onPlay?.let { Func_void_java(it) }, onPause?.let { Func_void_java(it) }, onSkipForward?.let { Func_void_java(it) }, onSkipBackward?.let { Func_void_java(it) }, onNextTrack?.let { Func_void_java(it) }, onPreviousTrack?.let { Func_void_java(it) }, onComplete?.let { Func_void_java(it) }, onProgressUpdate?.let { Func_void_double_double_java(it) }, onPlaybackFinished?.let { Func_void_java(it) })
|
|
86
92
|
|
|
87
93
|
private companion object {
|
|
88
94
|
/**
|
|
@@ -92,8 +98,8 @@ data class NowPlayingTemplateConfig(
|
|
|
92
98
|
@Keep
|
|
93
99
|
@Suppress("unused")
|
|
94
100
|
@JvmStatic
|
|
95
|
-
private fun fromCpp(id: String, onWillAppear: Func_void_std__optional_bool_?, onWillDisappear: Func_void_std__optional_bool_?, onDidAppear: Func_void_std__optional_bool_?, onDidDisappear: Func_void_std__optional_bool_?, onPopped: Func_void?, autoDismissMs: Double?, title: AutoText, subtitle: AutoText?, courseId: String, lessonId: String, image: Variant_GlyphImage_AssetImage?, isPlaying: Boolean, onPlay: Func_void?, onPause: Func_void?, onSkipForward: Func_void?, onSkipBackward: Func_void?, onComplete: Func_void?, onProgressUpdate: Func_void_double_double?, onPlaybackFinished: Func_void?): NowPlayingTemplateConfig {
|
|
96
|
-
return NowPlayingTemplateConfig(id, onWillAppear, onWillDisappear, onDidAppear, onDidDisappear, onPopped, autoDismissMs, title, subtitle, courseId, lessonId, image, isPlaying, onPlay, onPause, onSkipForward, onSkipBackward, onComplete, onProgressUpdate, onPlaybackFinished)
|
|
101
|
+
private fun fromCpp(id: String, onWillAppear: Func_void_std__optional_bool_?, onWillDisappear: Func_void_std__optional_bool_?, onDidAppear: Func_void_std__optional_bool_?, onDidDisappear: Func_void_std__optional_bool_?, onPopped: Func_void?, autoDismissMs: Double?, title: AutoText, subtitle: AutoText?, courseId: String, lessonId: String, image: Variant_GlyphImage_AssetImage?, isPlaying: Boolean, onPlay: Func_void?, onPause: Func_void?, onSkipForward: Func_void?, onSkipBackward: Func_void?, onNextTrack: Func_void?, onPreviousTrack: Func_void?, onComplete: Func_void?, onProgressUpdate: Func_void_double_double?, onPlaybackFinished: Func_void?): NowPlayingTemplateConfig {
|
|
102
|
+
return NowPlayingTemplateConfig(id, onWillAppear, onWillDisappear, onDidAppear, onDidDisappear, onPopped, autoDismissMs, title, subtitle, courseId, lessonId, image, isPlaying, onPlay, onPause, onSkipForward, onSkipBackward, onNextTrack, onPreviousTrack, onComplete, onProgressUpdate, onPlaybackFinished)
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
}
|
|
@@ -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)?, onProgressUpdate: ((_ currentTime: Double, _ duration: Double) -> Void)?, onPlaybackFinished: (() -> 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)?, onNextTrack: (() -> Void)?, onPreviousTrack: (() -> 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
|
|
@@ -126,6 +126,24 @@ public extension NowPlayingTemplateConfig {
|
|
|
126
126
|
} else {
|
|
127
127
|
return .init()
|
|
128
128
|
}
|
|
129
|
+
}(), { () -> bridge.std__optional_std__function_void____ in
|
|
130
|
+
if let __unwrappedValue = onNextTrack {
|
|
131
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
132
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
133
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
134
|
+
}())
|
|
135
|
+
} else {
|
|
136
|
+
return .init()
|
|
137
|
+
}
|
|
138
|
+
}(), { () -> bridge.std__optional_std__function_void____ in
|
|
139
|
+
if let __unwrappedValue = onPreviousTrack {
|
|
140
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
141
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
142
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
143
|
+
}())
|
|
144
|
+
} else {
|
|
145
|
+
return .init()
|
|
146
|
+
}
|
|
129
147
|
}(), { () -> bridge.std__optional_std__function_void____ in
|
|
130
148
|
if let __unwrappedValue = onComplete {
|
|
131
149
|
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
@@ -600,6 +618,70 @@ public extension NowPlayingTemplateConfig {
|
|
|
600
618
|
}
|
|
601
619
|
}
|
|
602
620
|
|
|
621
|
+
var onNextTrack: (() -> Void)? {
|
|
622
|
+
@inline(__always)
|
|
623
|
+
get {
|
|
624
|
+
return { () -> (() -> Void)? in
|
|
625
|
+
if bridge.has_value_std__optional_std__function_void____(self.__onNextTrack) {
|
|
626
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(self.__onNextTrack)
|
|
627
|
+
return { () -> () -> Void in
|
|
628
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
629
|
+
return { () -> Void in
|
|
630
|
+
__wrappedFunction.call()
|
|
631
|
+
}
|
|
632
|
+
}()
|
|
633
|
+
} else {
|
|
634
|
+
return nil
|
|
635
|
+
}
|
|
636
|
+
}()
|
|
637
|
+
}
|
|
638
|
+
@inline(__always)
|
|
639
|
+
set {
|
|
640
|
+
self.__onNextTrack = { () -> bridge.std__optional_std__function_void____ in
|
|
641
|
+
if let __unwrappedValue = newValue {
|
|
642
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
643
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
644
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
645
|
+
}())
|
|
646
|
+
} else {
|
|
647
|
+
return .init()
|
|
648
|
+
}
|
|
649
|
+
}()
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
var onPreviousTrack: (() -> Void)? {
|
|
654
|
+
@inline(__always)
|
|
655
|
+
get {
|
|
656
|
+
return { () -> (() -> Void)? in
|
|
657
|
+
if bridge.has_value_std__optional_std__function_void____(self.__onPreviousTrack) {
|
|
658
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(self.__onPreviousTrack)
|
|
659
|
+
return { () -> () -> Void in
|
|
660
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
661
|
+
return { () -> Void in
|
|
662
|
+
__wrappedFunction.call()
|
|
663
|
+
}
|
|
664
|
+
}()
|
|
665
|
+
} else {
|
|
666
|
+
return nil
|
|
667
|
+
}
|
|
668
|
+
}()
|
|
669
|
+
}
|
|
670
|
+
@inline(__always)
|
|
671
|
+
set {
|
|
672
|
+
self.__onPreviousTrack = { () -> bridge.std__optional_std__function_void____ in
|
|
673
|
+
if let __unwrappedValue = newValue {
|
|
674
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
675
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
676
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
677
|
+
}())
|
|
678
|
+
} else {
|
|
679
|
+
return .init()
|
|
680
|
+
}
|
|
681
|
+
}()
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
603
685
|
var onComplete: (() -> Void)? {
|
|
604
686
|
@inline(__always)
|
|
605
687
|
get {
|
|
@@ -62,13 +62,15 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
62
62
|
std::optional<std::function<void()>> onPause SWIFT_PRIVATE;
|
|
63
63
|
std::optional<std::function<void()>> onSkipForward SWIFT_PRIVATE;
|
|
64
64
|
std::optional<std::function<void()>> onSkipBackward SWIFT_PRIVATE;
|
|
65
|
+
std::optional<std::function<void()>> onNextTrack SWIFT_PRIVATE;
|
|
66
|
+
std::optional<std::function<void()>> onPreviousTrack SWIFT_PRIVATE;
|
|
65
67
|
std::optional<std::function<void()>> onComplete SWIFT_PRIVATE;
|
|
66
68
|
std::optional<std::function<void(double /* currentTime */, double /* duration */)>> onProgressUpdate SWIFT_PRIVATE;
|
|
67
69
|
std::optional<std::function<void()>> onPlaybackFinished SWIFT_PRIVATE;
|
|
68
70
|
|
|
69
71
|
public:
|
|
70
72
|
NowPlayingTemplateConfig() = default;
|
|
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) {}
|
|
73
|
+
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()>> onNextTrack, std::optional<std::function<void()>> onPreviousTrack, 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), onNextTrack(onNextTrack), onPreviousTrack(onPreviousTrack), onComplete(onComplete), onProgressUpdate(onProgressUpdate), onPlaybackFinished(onPlaybackFinished) {}
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -98,6 +100,8 @@ namespace margelo::nitro {
|
|
|
98
100
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onPause")),
|
|
99
101
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onSkipForward")),
|
|
100
102
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onSkipBackward")),
|
|
103
|
+
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onNextTrack")),
|
|
104
|
+
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onPreviousTrack")),
|
|
101
105
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onComplete")),
|
|
102
106
|
JSIConverter<std::optional<std::function<void(double, double)>>>::fromJSI(runtime, obj.getProperty(runtime, "onProgressUpdate")),
|
|
103
107
|
JSIConverter<std::optional<std::function<void()>>>::fromJSI(runtime, obj.getProperty(runtime, "onPlaybackFinished"))
|
|
@@ -122,6 +126,8 @@ namespace margelo::nitro {
|
|
|
122
126
|
obj.setProperty(runtime, "onPause", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onPause));
|
|
123
127
|
obj.setProperty(runtime, "onSkipForward", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onSkipForward));
|
|
124
128
|
obj.setProperty(runtime, "onSkipBackward", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onSkipBackward));
|
|
129
|
+
obj.setProperty(runtime, "onNextTrack", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onNextTrack));
|
|
130
|
+
obj.setProperty(runtime, "onPreviousTrack", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onPreviousTrack));
|
|
125
131
|
obj.setProperty(runtime, "onComplete", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onComplete));
|
|
126
132
|
obj.setProperty(runtime, "onProgressUpdate", JSIConverter<std::optional<std::function<void(double, double)>>>::toJSI(runtime, arg.onProgressUpdate));
|
|
127
133
|
obj.setProperty(runtime, "onPlaybackFinished", JSIConverter<std::optional<std::function<void()>>>::toJSI(runtime, arg.onPlaybackFinished));
|
|
@@ -152,6 +158,8 @@ namespace margelo::nitro {
|
|
|
152
158
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onPause"))) return false;
|
|
153
159
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onSkipForward"))) return false;
|
|
154
160
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onSkipBackward"))) return false;
|
|
161
|
+
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onNextTrack"))) return false;
|
|
162
|
+
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onPreviousTrack"))) return false;
|
|
155
163
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onComplete"))) return false;
|
|
156
164
|
if (!JSIConverter<std::optional<std::function<void(double, double)>>>::canConvert(runtime, obj.getProperty(runtime, "onProgressUpdate"))) return false;
|
|
157
165
|
if (!JSIConverter<std::optional<std::function<void()>>>::canConvert(runtime, obj.getProperty(runtime, "onPlaybackFinished"))) return false;
|
package/package.json
CHANGED
|
@@ -24,6 +24,8 @@ export interface NitroNowPlayingTemplateConfig extends TemplateConfig {
|
|
|
24
24
|
onPause?: () => void;
|
|
25
25
|
onSkipForward?: () => void;
|
|
26
26
|
onSkipBackward?: () => void;
|
|
27
|
+
onNextTrack?: () => void;
|
|
28
|
+
onPreviousTrack?: () => void;
|
|
27
29
|
onComplete?: () => void;
|
|
28
30
|
onProgressUpdate?: (currentTime: number, duration: number) => void;
|
|
29
31
|
onPlaybackFinished?: () => void;
|