@neoskola/auto-play 0.2.6 → 0.2.8
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.
|
@@ -38,11 +38,13 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
var topTemplateId: String? {
|
|
41
|
-
|
|
41
|
+
let id = interfaceController.topTemplate?.id
|
|
42
|
+
return (id?.isEmpty == true) ? nil : id
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
var rootTemplateId: String? {
|
|
45
|
-
|
|
46
|
+
let id = interfaceController.rootTemplate.id
|
|
47
|
+
return id.isEmpty ? nil : id
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
func pushTemplate(
|
|
@@ -179,6 +181,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
179
181
|
animated: Bool
|
|
180
182
|
) {
|
|
181
183
|
let templateId = aTemplate.id
|
|
184
|
+
guard !templateId.isEmpty else { return }
|
|
182
185
|
|
|
183
186
|
TemplateStore.getTemplate(templateId: templateId)?.onWillAppear(
|
|
184
187
|
animated: animated
|
|
@@ -190,6 +193,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
190
193
|
animated: Bool
|
|
191
194
|
) {
|
|
192
195
|
let templateId = aTemplate.id
|
|
196
|
+
guard !templateId.isEmpty else { return }
|
|
193
197
|
|
|
194
198
|
if rootTemplateId == templateId {
|
|
195
199
|
// this makes sure we purge outdated CPSearchTemplate since that one can be popped on with a CarPlay native button we can not intercept
|
|
@@ -206,6 +210,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
206
210
|
animated: Bool
|
|
207
211
|
) {
|
|
208
212
|
let templateId = aTemplate.id
|
|
213
|
+
guard !templateId.isEmpty else { return }
|
|
209
214
|
|
|
210
215
|
TemplateStore.getTemplate(templateId: templateId)?.onWillDisappear(
|
|
211
216
|
animated: animated
|
|
@@ -217,6 +222,7 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
|
|
|
217
222
|
animated: Bool
|
|
218
223
|
) {
|
|
219
224
|
let templateId = aTemplate.id
|
|
225
|
+
guard !templateId.isEmpty else { return }
|
|
220
226
|
|
|
221
227
|
TemplateStore.getTemplate(templateId: templateId)?.onDidDisappear(
|
|
222
228
|
animated: animated
|
|
@@ -20,11 +20,17 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
20
20
|
template = CPNowPlayingTemplate.shared
|
|
21
21
|
initTemplate(template: template, id: config.id)
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if
|
|
27
|
-
|
|
23
|
+
// Constructor runs on the JS thread. Dispatch all CarPlay UI setup to main thread.
|
|
24
|
+
// CPNowPlayingTemplate.shared is Apple's singleton — must be modified on main thread.
|
|
25
|
+
// This also ensures MPNowPlayingInfoCenter and MPRemoteCommandCenter are configured
|
|
26
|
+
// even if push() is never called (CarPlay shows "Now Playing" bar automatically).
|
|
27
|
+
DispatchQueue.main.async { [weak self] in
|
|
28
|
+
guard let self = self else { return }
|
|
29
|
+
self.setupNowPlayingButtons()
|
|
30
|
+
self.updateNowPlayingInfo()
|
|
31
|
+
if let image = config.image {
|
|
32
|
+
self.loadImageAsync(image: image)
|
|
33
|
+
}
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -123,6 +129,10 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
123
129
|
func invalidate() {
|
|
124
130
|
setupNowPlayingButtons()
|
|
125
131
|
updateNowPlayingInfo()
|
|
132
|
+
|
|
133
|
+
if loadedImage == nil, let image = config.image {
|
|
134
|
+
loadImageAsync(image: image)
|
|
135
|
+
}
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
func onWillAppear(animated: Bool) {
|