@neoskola/auto-play 0.3.7 → 0.3.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.
|
@@ -37,14 +37,16 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
37
37
|
let titleText = Parser.parseText(text: config.title) ?? "Now Playing"
|
|
38
38
|
let subtitleText = config.subtitle.flatMap { Parser.parseText(text: $0) } ?? ""
|
|
39
39
|
|
|
40
|
-
// Section 1: Bilgi — ders ve kurs adi
|
|
40
|
+
// Section 1: Bilgi — ders ve kurs adi + progress bar accessory
|
|
41
41
|
let infoItem = CPListItem(
|
|
42
42
|
text: titleText,
|
|
43
43
|
detailText: subtitleText,
|
|
44
|
-
image: UIImage(systemName: "music.note")
|
|
44
|
+
image: UIImage(systemName: "music.note")?
|
|
45
|
+
.withTintColor(.systemPurple, renderingMode: .alwaysOriginal),
|
|
45
46
|
accessoryImage: nil,
|
|
46
47
|
accessoryType: .none
|
|
47
48
|
)
|
|
49
|
+
infoItem.isEnabled = false
|
|
48
50
|
let infoSection = CPListSection(
|
|
49
51
|
items: [infoItem],
|
|
50
52
|
header: "Şimdi Oynatılıyor",
|
|
@@ -55,35 +57,40 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
55
57
|
let timeItem = CPListItem(
|
|
56
58
|
text: "Yükleniyor...",
|
|
57
59
|
detailText: nil,
|
|
58
|
-
image: UIImage(systemName: "clock")
|
|
60
|
+
image: UIImage(systemName: "clock")?
|
|
61
|
+
.withTintColor(.systemGray, renderingMode: .alwaysOriginal),
|
|
59
62
|
accessoryImage: nil,
|
|
60
63
|
accessoryType: .none
|
|
61
64
|
)
|
|
65
|
+
timeItem.isEnabled = false
|
|
62
66
|
let timeSection = CPListSection(
|
|
63
67
|
items: [timeItem],
|
|
64
68
|
header: nil,
|
|
65
69
|
sectionIndexTitle: nil
|
|
66
70
|
)
|
|
67
71
|
|
|
68
|
-
// Section 3: Kontroller —
|
|
72
|
+
// Section 3: Kontroller — renkli ikonlar
|
|
69
73
|
let prevItem = CPListItem(
|
|
70
74
|
text: "Önceki Bölüm",
|
|
71
75
|
detailText: nil,
|
|
72
|
-
image: UIImage(systemName: "backward.end.fill")
|
|
76
|
+
image: UIImage(systemName: "backward.end.fill")?
|
|
77
|
+
.withTintColor(.systemBlue, renderingMode: .alwaysOriginal),
|
|
73
78
|
accessoryImage: nil,
|
|
74
79
|
accessoryType: .none
|
|
75
80
|
)
|
|
76
81
|
let playPauseItem = CPListItem(
|
|
77
82
|
text: "Oynat",
|
|
78
83
|
detailText: nil,
|
|
79
|
-
image: UIImage(systemName: "play.circle.fill")
|
|
84
|
+
image: UIImage(systemName: "play.circle.fill")?
|
|
85
|
+
.withTintColor(.systemGreen, renderingMode: .alwaysOriginal),
|
|
80
86
|
accessoryImage: nil,
|
|
81
87
|
accessoryType: .none
|
|
82
88
|
)
|
|
83
89
|
let nextItem = CPListItem(
|
|
84
90
|
text: "Sonraki Bölüm",
|
|
85
91
|
detailText: nil,
|
|
86
|
-
image: UIImage(systemName: "forward.end.fill")
|
|
92
|
+
image: UIImage(systemName: "forward.end.fill")?
|
|
93
|
+
.withTintColor(.systemBlue, renderingMode: .alwaysOriginal),
|
|
87
94
|
accessoryImage: nil,
|
|
88
95
|
accessoryType: .none
|
|
89
96
|
)
|
|
@@ -94,7 +101,7 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
94
101
|
)
|
|
95
102
|
|
|
96
103
|
template = CPListTemplate(
|
|
97
|
-
title:
|
|
104
|
+
title: titleText,
|
|
98
105
|
sections: [infoSection, timeSection, controlSection],
|
|
99
106
|
assistantCellConfiguration: nil,
|
|
100
107
|
id: config.id
|
|
@@ -150,60 +157,79 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
150
157
|
let titleText = Parser.parseText(text: config.title) ?? "Now Playing"
|
|
151
158
|
let subtitleText = config.subtitle.flatMap { Parser.parseText(text: $0) } ?? ""
|
|
152
159
|
|
|
153
|
-
//
|
|
160
|
+
// Progress hesapla
|
|
161
|
+
let progress = currentDuration > 0 ? currentElapsedTime / currentDuration : 0
|
|
162
|
+
|
|
163
|
+
// Section 1: Bilgi + progress bar accessory
|
|
154
164
|
let infoItem = CPListItem(
|
|
155
165
|
text: titleText,
|
|
156
166
|
detailText: subtitleText,
|
|
157
|
-
image: loadedImage ?? UIImage(systemName: "music.note")
|
|
158
|
-
|
|
167
|
+
image: loadedImage ?? UIImage(systemName: "music.note")?
|
|
168
|
+
.withTintColor(.systemPurple, renderingMode: .alwaysOriginal),
|
|
169
|
+
accessoryImage: drawProgressBarImage(progress: progress),
|
|
159
170
|
accessoryType: .none
|
|
160
171
|
)
|
|
172
|
+
infoItem.isEnabled = false
|
|
161
173
|
let infoSection = CPListSection(
|
|
162
174
|
items: [infoItem],
|
|
163
175
|
header: "Şimdi Oynatılıyor",
|
|
164
176
|
sectionIndexTitle: nil
|
|
165
177
|
)
|
|
166
178
|
|
|
167
|
-
// Section 2: Sure
|
|
179
|
+
// Section 2: Sure + yuzde detay
|
|
168
180
|
let elapsed = formatTime(currentElapsedTime)
|
|
169
181
|
let total = currentDuration > 0 ? formatTime(currentDuration) : "--:--"
|
|
170
182
|
let timeText: String
|
|
171
|
-
let timeIcon:
|
|
183
|
+
let timeIcon: UIImage?
|
|
172
184
|
if config.isPlaying {
|
|
173
185
|
timeText = "\(elapsed) / \(total)"
|
|
174
|
-
timeIcon = "waveform"
|
|
186
|
+
timeIcon = UIImage(systemName: "waveform")?
|
|
187
|
+
.withTintColor(.systemGreen, renderingMode: .alwaysOriginal)
|
|
175
188
|
} else {
|
|
176
189
|
timeText = "Duraklatıldı \(elapsed) / \(total)"
|
|
177
|
-
timeIcon = "pause.circle"
|
|
190
|
+
timeIcon = UIImage(systemName: "pause.circle")?
|
|
191
|
+
.withTintColor(.systemGray, renderingMode: .alwaysOriginal)
|
|
178
192
|
}
|
|
193
|
+
|
|
194
|
+
let progressPercent = currentDuration > 0
|
|
195
|
+
? Int((currentElapsedTime / currentDuration) * 100)
|
|
196
|
+
: 0
|
|
197
|
+
let timeDetailText: String? = currentDuration > 0 ? "%\(progressPercent) tamamlandı" : nil
|
|
198
|
+
|
|
179
199
|
let timeItem = CPListItem(
|
|
180
200
|
text: timeText,
|
|
181
|
-
detailText:
|
|
182
|
-
image:
|
|
201
|
+
detailText: timeDetailText,
|
|
202
|
+
image: timeIcon,
|
|
183
203
|
accessoryImage: nil,
|
|
184
204
|
accessoryType: .none
|
|
185
205
|
)
|
|
206
|
+
timeItem.isEnabled = false
|
|
186
207
|
let timeSection = CPListSection(
|
|
187
208
|
items: [timeItem],
|
|
188
209
|
header: nil,
|
|
189
210
|
sectionIndexTitle: nil
|
|
190
211
|
)
|
|
191
212
|
|
|
192
|
-
// Section 3: Kontroller
|
|
213
|
+
// Section 3: Kontroller — renkli ikonlar
|
|
193
214
|
let prevItem = CPListItem(
|
|
194
215
|
text: "Önceki Bölüm",
|
|
195
216
|
detailText: nil,
|
|
196
|
-
image: UIImage(systemName: "backward.end.fill")
|
|
217
|
+
image: UIImage(systemName: "backward.end.fill")?
|
|
218
|
+
.withTintColor(.systemBlue, renderingMode: .alwaysOriginal),
|
|
197
219
|
accessoryImage: nil,
|
|
198
220
|
accessoryType: .none
|
|
199
221
|
)
|
|
200
222
|
|
|
201
223
|
let playPauseText = config.isPlaying ? "Duraklat" : "Oynat"
|
|
202
|
-
let playPauseIcon = config.isPlaying
|
|
224
|
+
let playPauseIcon: UIImage? = config.isPlaying
|
|
225
|
+
? UIImage(systemName: "pause.circle.fill")?
|
|
226
|
+
.withTintColor(.systemOrange, renderingMode: .alwaysOriginal)
|
|
227
|
+
: UIImage(systemName: "play.circle.fill")?
|
|
228
|
+
.withTintColor(.systemGreen, renderingMode: .alwaysOriginal)
|
|
203
229
|
let playPauseItem = CPListItem(
|
|
204
230
|
text: playPauseText,
|
|
205
231
|
detailText: nil,
|
|
206
|
-
image:
|
|
232
|
+
image: playPauseIcon,
|
|
207
233
|
accessoryImage: nil,
|
|
208
234
|
accessoryType: .none
|
|
209
235
|
)
|
|
@@ -211,7 +237,8 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
211
237
|
let nextItem = CPListItem(
|
|
212
238
|
text: "Sonraki Bölüm",
|
|
213
239
|
detailText: nil,
|
|
214
|
-
image: UIImage(systemName: "forward.end.fill")
|
|
240
|
+
image: UIImage(systemName: "forward.end.fill")?
|
|
241
|
+
.withTintColor(.systemBlue, renderingMode: .alwaysOriginal),
|
|
215
242
|
accessoryImage: nil,
|
|
216
243
|
accessoryType: .none
|
|
217
244
|
)
|
|
@@ -234,6 +261,35 @@ class NowPlayingTemplate: AutoPlayTemplate {
|
|
|
234
261
|
return String(format: "%d:%02d", mins, secs)
|
|
235
262
|
}
|
|
236
263
|
|
|
264
|
+
private func drawProgressBarImage(progress: Double) -> UIImage? {
|
|
265
|
+
let size = CPListItem.maximumImageSize
|
|
266
|
+
let renderer = UIGraphicsImageRenderer(size: size)
|
|
267
|
+
return renderer.image { _ in
|
|
268
|
+
let barHeight: CGFloat = 6
|
|
269
|
+
let barY = (size.height - barHeight) / 2
|
|
270
|
+
let cornerRadius = barHeight / 2
|
|
271
|
+
|
|
272
|
+
// Arka plan (gri track)
|
|
273
|
+
let trackPath = UIBezierPath(
|
|
274
|
+
roundedRect: CGRect(x: 2, y: barY, width: size.width - 4, height: barHeight),
|
|
275
|
+
cornerRadius: cornerRadius
|
|
276
|
+
)
|
|
277
|
+
UIColor.systemGray4.setFill()
|
|
278
|
+
trackPath.fill()
|
|
279
|
+
|
|
280
|
+
// Ilerleme (yesil fill)
|
|
281
|
+
let progressWidth = max(0, (size.width - 4) * CGFloat(min(progress, 1.0)))
|
|
282
|
+
if progressWidth > 0 {
|
|
283
|
+
let progressPath = UIBezierPath(
|
|
284
|
+
roundedRect: CGRect(x: 2, y: barY, width: progressWidth, height: barHeight),
|
|
285
|
+
cornerRadius: cornerRadius
|
|
286
|
+
)
|
|
287
|
+
UIColor.systemGreen.setFill()
|
|
288
|
+
progressPath.fill()
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
237
293
|
// MARK: - Native Audio Playback
|
|
238
294
|
|
|
239
295
|
@MainActor
|