Dreamio turn document

Native Player Liquid Glass UX

The native VLC player received a fuller control experience: Liquid Glass-backed panels on iOS 26, larger controls, clearer loading and failure states, scrubbing feedback, double-tap seeking, menu polish, iPad width adaptation, and accessibility improvements.

2026-05-26Beads issue dreamio-060Native player UI

Summary

Implemented the remaining player UX plan in Dreamio/NativePlayerViewController.swift, keeping the VLC backend contract intact while improving the control surface and user feedback around playback.

Changes Made

Context

The prior baseline was compact and functional but used a plain blur tray, small controls, a spinner-only loading state, and a text-only failure state. This pass keeps the same native playback architecture while making the player feel more intentional and touch-friendly.

Important Implementation Details

Relevant Diff Snippets

Dreamio/NativePlayerViewController.swift ยท player controls UX pass

Dreamio/NativePlayerViewController.swift
-60+341
10 unmodified lines
11
12
13
14
15
16
17
18
7 unmodified lines
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2 unmodified lines
50
51
52
53
54
55
56
57
58
59
60
27 unmodified lines
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
31 unmodified lines
136
137
138
139
140
141
142
143
144
67 unmodified lines
212
213
214
215
216
217
218
22 unmodified lines
241
242
243
244
245
246
4 unmodified lines
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
1 unmodified line
270
271
272
273
274
275
21 unmodified lines
297
298
299
300
301
302
5 unmodified lines
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
5 unmodified lines
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
30 unmodified lines
428
429
430
431
432
433
434
6 unmodified lines
441
442
443
444
445
446
1 unmodified line
448
449
450
451
452
453
454
23 unmodified lines
478
479
480
481
482
483
484
14 unmodified lines
499
500
501
502
503
504
9 unmodified lines
514
515
516
517
518
519
14 unmodified lines
534
535
536
537
538
539
27 unmodified lines
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
1 unmodified line
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
10 unmodified lines
private var attachedSubtitleURLs: Set<URL>
private var audioMenuSignature: String?
private var captionsMenuSignature: String?
var onDismiss: (() -> Void)?
private let loadingView: UIActivityIndicatorView = {
let view = UIActivityIndicatorView(style: .large)
view.translatesAutoresizingMaskIntoConstraints = false
7 unmodified lines
button.translatesAutoresizingMaskIntoConstraints = false
button.setImage(UIImage(systemName: "xmark"), for: .normal)
button.tintColor = .white
button.backgroundColor = UIColor.black.withAlphaComponent(0.45)
button.layer.cornerRadius = 18
button.accessibilityLabel = "Close"
return button
}()
private let controlsContainer: UIVisualEffectView = {
let view = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterialDark))
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.cornerRadius = 22
view.clipsToBounds = true
view.backgroundColor = UIColor.white.withAlphaComponent(0.08)
view.layer.borderColor = UIColor.white.withAlphaComponent(0.18).cgColor
view.layer.borderWidth = 1
return view
}()
private let tapSurfaceView: UIView = {
let view = UIView()
2 unmodified lines
return view
}()
private let playPauseButton = NativePlayerViewController.iconButton(systemName: "pause.fill", label: "Play or Pause")
private let jumpBackButton = NativePlayerViewController.iconButton(systemName: "gobackward.15", label: "Jump Back 15 Seconds")
private let jumpForwardButton = NativePlayerViewController.iconButton(systemName: "goforward.15", label: "Jump Forward 15 Seconds")
private let audioButton = NativePlayerViewController.iconButton(systemName: "waveform.circle", label: "Audio Tracks")
private let captionsButton = NativePlayerViewController.iconButton(systemName: "captions.bubble", label: "Captions")
private let elapsedLabel: UILabel = {
let label = UILabel()
27 unmodified lines
return slider
}()
private let failureLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .white
label.textAlignment = .center
label.numberOfLines = 0
label.font = .preferredFont(forTextStyle: .body)
label.isHidden = true
return label
}()
init(
request: NativePlaybackRequest,
backend: NativePlaybackBackend = VLCNativePlaybackBackend(),
31 unmodified lines
view.backgroundColor = .black
configureBackend()
configureLayout()
startStartupTimer()
backend.play(request: request)
addSubtitleCandidates(request.subtitleCandidates)
}
@discardableResult
67 unmodified lines
DispatchQueue.main.async {
self?.startupTimer?.invalidate()
self?.loadingView.stopAnimating()
self?.loadingView.isHidden = true
self?.startProgressUpdates()
self?.refreshControls()
self?.scheduleControlsHide()
22 unmodified lines
}
}
private func startStartupTimer() {
startupTimer?.invalidate()
startupTimer = Timer.scheduledTimer(withTimeInterval: 20, repeats: false) { [weak self] _ in
4 unmodified lines
private func configureLayout() {
view.addSubview(backend.view)
view.addSubview(tapSurfaceView)
view.addSubview(loadingView)
view.addSubview(failureLabel)
view.addSubview(controlsContainer)
view.addSubview(closeButton)
closeButton.addTarget(self, action: #selector(close), for: .touchUpInside)
playPauseButton.addTarget(self, action: #selector(togglePlayPause), for: .touchUpInside)
jumpBackButton.addTarget(self, action: #selector(jumpBack), for: .touchUpInside)
jumpForwardButton.addTarget(self, action: #selector(jumpForward), for: .touchUpInside)
audioButton.showsMenuAsPrimaryAction = true
captionsButton.showsMenuAsPrimaryAction = true
playPauseButton.layer.cornerRadius = 24
scrubber.addTarget(self, action: #selector(scrubbingStarted), for: .touchDown)
scrubber.addTarget(self, action: #selector(scrubberChanged), for: .valueChanged)
scrubber.addTarget(self, action: #selector(scrubbingEnded), for: [.touchUpInside, .touchUpOutside, .touchCancel])
1 unmodified line
let tap = UITapGestureRecognizer(target: self, action: #selector(toggleControlsVisibility))
tap.cancelsTouchesInView = false
tapSurfaceView.addGestureRecognizer(tap)
let timeAndScrubRow = UIStackView(arrangedSubviews: [elapsedLabel, scrubber, remainingLabel])
timeAndScrubRow.translatesAutoresizingMaskIntoConstraints = false
21 unmodified lines
stack.spacing = 6
controlsContainer.contentView.addSubview(stack)
NSLayoutConstraint.activate([
backend.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
backend.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
5 unmodified lines
tapSurfaceView.topAnchor.constraint(equalTo: view.topAnchor),
tapSurfaceView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
loadingView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
loadingView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
failureLabel.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 28),
failureLabel.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -28),
failureLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor),
closeButton.widthAnchor.constraint(equalToConstant: 36),
closeButton.heightAnchor.constraint(equalToConstant: 36),
closeButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 10),
closeButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -10),
controlsContainer.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
controlsContainer.widthAnchor.constraint(lessThanOrEqualTo: view.safeAreaLayoutGuide.widthAnchor, constant: -24),
controlsContainer.widthAnchor.constraint(lessThanOrEqualToConstant: 430),
controlsContainer.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -12),
stack.leadingAnchor.constraint(equalTo: controlsContainer.contentView.leadingAnchor, constant: 12),
5 unmodified lines
remainingLabel.widthAnchor.constraint(equalToConstant: 42),
scrubber.widthAnchor.constraint(greaterThanOrEqualToConstant: 160),
jumpBackButton.widthAnchor.constraint(equalToConstant: 36),
jumpBackButton.heightAnchor.constraint(equalToConstant: 36),
playPauseButton.widthAnchor.constraint(equalToConstant: 42),
playPauseButton.heightAnchor.constraint(equalToConstant: 42),
jumpForwardButton.widthAnchor.constraint(equalToConstant: 36),
jumpForwardButton.heightAnchor.constraint(equalToConstant: 36),
audioButton.widthAnchor.constraint(equalToConstant: 36),
audioButton.heightAnchor.constraint(equalToConstant: 36),
playbackCluster.centerXAnchor.constraint(equalTo: controlRow.centerXAnchor),
captionsButton.widthAnchor.constraint(equalToConstant: 36),
captionsButton.heightAnchor.constraint(equalToConstant: 36)
])
}
private func showFailure(_ error: Error) {
loadingView.stopAnimating()
loadingView.isHidden = true
failureLabel.text = "Native playback could not start.\n\(error.localizedDescription)"
failureLabel.isHidden = false
#if DEBUG
print("[DreamioNativePlayer] error=\(URLRedactor.redactedURLString(error.localizedDescription))")
#endif
}
@objc private func close() {
dismiss(animated: true)
}
@objc private func togglePlayPause() {
backend.togglePlayPause()
revealControls()
}
@objc private func jumpBack() {
backend.jump(by: -15)
revealControls()
}
@objc private func jumpForward() {
backend.jump(by: 15)
revealControls()
}
@objc private func scrubbingStarted() {
isScrubbing = true
controlsTimer?.invalidate()
}
@objc private func scrubberChanged() {
elapsedLabel.text = PlaybackTimeFormatter.label(for: TimeInterval(scrubber.value) * backend.duration)
}
@objc private func scrubbingEnded() {
backend.seek(to: scrubber.value)
isScrubbing = false
revealControls()
}
@objc private func toggleControlsVisibility() {
if controlsContainer.alpha < 1 {
revealControls()
30 unmodified lines
}
let delayActions = UIMenu(
title: "Delay",
options: .displayInline,
children: [
UIAction(title: "Decrease 0.5s") { [weak self] _ in
6 unmodified lines
self?.captionsMenuSignature = nil
self?.refreshControls()
},
UIAction(
title: "Current: \(String(format: "%.1fs", backend.subtitleDelay))",
attributes: .disabled
1 unmodified line
]
)
return UIMenu(title: "Captions", children: trackActions + [delayActions])
}
private func audioMenu() -> UIMenu {
23 unmodified lines
}
}
return UIMenu(title: "Audio", children: trackActions)
}
private func startProgressUpdates() {
14 unmodified lines
updateCaptionsMenuIfNeeded(subtitleTracks: subtitleTracks)
elapsedLabel.text = PlaybackTimeFormatter.label(for: backend.currentTime)
remainingLabel.text = "-\(PlaybackTimeFormatter.label(for: backend.remainingTime))"
if !isScrubbing {
scrubber.value = backend.position
}
9 unmodified lines
let hasSelectableTrack = AudioOptionMapper.options(from: audioTracks).count > 1
audioButton.isEnabled = hasSelectableTrack
audioButton.alpha = hasSelectableTrack ? 1 : 0.45
guard signature != audioMenuSignature else {
return
}
14 unmodified lines
)
let hasSelectableTrack = subtitleTracks.contains { $0.id >= 0 }
captionsButton.isEnabled = hasSelectableTrack
guard signature != captionsMenuSignature else {
return
}
27 unmodified lines
private func revealControls() {
controlsContainer.isUserInteractionEnabled = true
closeButton.isUserInteractionEnabled = true
UIView.animate(withDuration: 0.18) {
self.controlsContainer.alpha = 1
self.closeButton.alpha = 1
}
scheduleControlsHide()
}
private func hideControls() {
controlsContainer.isUserInteractionEnabled = false
closeButton.isUserInteractionEnabled = false
UIView.animate(withDuration: 0.24) {
self.controlsContainer.alpha = 0
self.closeButton.alpha = 0
}
1 unmodified line
private func scheduleControlsHide() {
controlsTimer?.invalidate()
guard backend.isPlaying else {
return
}
controlsTimer = Timer.scheduledTimer(withTimeInterval: 3, repeats: false) { [weak self] _ in
self?.hideControls()
}
}
private static func iconButton(systemName: String, label: String) -> UIButton {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setImage(UIImage(systemName: systemName), for: .normal)
button.tintColor = .white
button.backgroundColor = UIColor.white.withAlphaComponent(0.12)
button.layer.cornerRadius = 18
button.layer.borderColor = UIColor.white.withAlphaComponent(0.16).cgColor
button.layer.borderWidth = 1
button.accessibilityLabel = label
return button
}
private static func scrubberThumbImage(diameter: CGFloat) -> UIImage {
let format = UIGraphicsImageRendererFormat()
format.scale = UIScreen.main.scale
10 unmodified lines
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
7 unmodified lines
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2 unmodified lines
71
72
73
74
75
76
77
78
79
80
81
82
83
27 unmodified lines
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
31 unmodified lines
192
193
194
195
196
197
198
199
200
201
202
203
204
205
67 unmodified lines
273
274
275
276
277
278
279
22 unmodified lines
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
4 unmodified lines
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
1 unmodified line
353
354
355
356
357
358
359
360
361
362
363
364
365
366
21 unmodified lines
388
389
390
391
392
393
394
395
5 unmodified lines
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
5 unmodified lines
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
30 unmodified lines
575
576
577
578
579
580
581
6 unmodified lines
588
589
590
591
592
593
594
595
596
597
598
599
1 unmodified line
601
602
603
604
605
606
607
23 unmodified lines
631
632
633
634
635
636
637
14 unmodified lines
652
653
654
655
656
657
658
9 unmodified lines
668
669
670
671
672
673
674
14 unmodified lines
689
690
691
692
693
694
695
696
27 unmodified lines
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
1 unmodified line
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
10 unmodified lines
private var attachedSubtitleURLs: Set<URL>
private var audioMenuSignature: String?
private var captionsMenuSignature: String?
private var controlsMaximumWidthConstraint: NSLayoutConstraint?
private let bottomScrimLayer = CAGradientLayer()
var onDismiss: (() -> Void)?
private let loadingContainer: UIVisualEffectView = {
let view = NativePlayerViewController.glassPanel(cornerRadius: 24)
view.isHidden = false
return view
}()
private let loadingStack: UIStackView = {
let stack = UIStackView()
stack.translatesAutoresizingMaskIntoConstraints = false
stack.axis = .horizontal
stack.alignment = .center
stack.spacing = 12
return stack
}()
private let loadingTextLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "Opening streamโ€ฆ"
label.textColor = .white
label.font = .preferredFont(forTextStyle: .subheadline)
label.adjustsFontForContentSizeCategory = true
return label
}()
private let loadingView: UIActivityIndicatorView = {
let view = UIActivityIndicatorView(style: .large)
view.translatesAutoresizingMaskIntoConstraints = false
7 unmodified lines
button.translatesAutoresizingMaskIntoConstraints = false
button.setImage(UIImage(systemName: "xmark"), for: .normal)
button.tintColor = .white
button.backgroundColor = UIColor.white.withAlphaComponent(0.14)
button.layer.cornerRadius = 22
button.layer.borderColor = UIColor.white.withAlphaComponent(0.22).cgColor
button.layer.borderWidth = 1
button.accessibilityLabel = "Close"
button.accessibilityHint = "Closes native playback and returns to Stremio."
return button
}()
private let controlsContainer = NativePlayerViewController.glassPanel(cornerRadius: 26)
private let tapSurfaceView: UIView = {
let view = UIView()
2 unmodified lines
return view
}()
private let playPauseButton = NativePlayerViewController.iconButton(systemName: "pause.fill", label: "Play or Pause", pointSize: 24)
private let jumpBackButton = NativePlayerViewController.iconButton(systemName: "gobackward.15", label: "Jump Back 15 Seconds")
private let jumpForwardButton = NativePlayerViewController.iconButton(systemName: "goforward.15", label: "Jump Forward 15 Seconds")
private let audioButton = NativePlayerViewController.iconButton(systemName: "waveform.circle", label: "Audio Track")
private let captionsButton = NativePlayerViewController.iconButton(systemName: "captions.bubble", label: "Subtitles")
private let centerPlayPauseButton = NativePlayerViewController.iconButton(systemName: "play.fill", label: "Toggle Playback", pointSize: 34)
private let elapsedLabel: UILabel = {
let label = UILabel()
27 unmodified lines
return slider
}()
private let scrubTimeBubble: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .white
label.textAlignment = .center
label.font = .monospacedDigitSystemFont(ofSize: 13, weight: .bold)
label.backgroundColor = UIColor.black.withAlphaComponent(0.56)
label.layer.cornerRadius = 14
label.clipsToBounds = true
label.alpha = 0
return label
}()
private let failureContainer: UIVisualEffectView = {
let view = NativePlayerViewController.glassPanel(cornerRadius: 28)
view.isHidden = true
return view
}()
private let failureTitleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "Playback could not start"
label.textColor = .white
label.textAlignment = .center
label.font = .preferredFont(forTextStyle: .headline)
label.adjustsFontForContentSizeCategory = true
return label
}()
private let failureDetailLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = UIColor.white.withAlphaComponent(0.82)
label.textAlignment = .center
label.numberOfLines = 0
label.font = .preferredFont(forTextStyle: .subheadline)
label.adjustsFontForContentSizeCategory = true
return label
}()
private let retryButton: UIButton = NativePlayerViewController.textButton(title: "Retry")
private let failureCloseButton: UIButton = NativePlayerViewController.textButton(title: "Close")
init(
request: NativePlaybackRequest,
backend: NativePlaybackBackend = VLCNativePlaybackBackend(),
31 unmodified lines
view.backgroundColor = .black
configureBackend()
configureLayout()
configureAccessibility()
startPlayback()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
bottomScrimLayer.frame = view.bounds
updateLayoutForCurrentSize()
}
@discardableResult
67 unmodified lines
DispatchQueue.main.async {
self?.startupTimer?.invalidate()
self?.loadingView.stopAnimating()
self?.loadingContainer.isHidden = true
self?.startProgressUpdates()
self?.refreshControls()
self?.scheduleControlsHide()
22 unmodified lines
}
}
private func startPlayback() {
loadingContainer.isHidden = false
loadingView.startAnimating()
failureContainer.isHidden = true
startStartupTimer()
backend.play(request: request)
addSubtitleCandidates(request.subtitleCandidates)
revealControls()
}
private func startStartupTimer() {
startupTimer?.invalidate()
startupTimer = Timer.scheduledTimer(withTimeInterval: 20, repeats: false) { [weak self] _ in
4 unmodified lines
private func configureLayout() {
view.addSubview(backend.view)
configureBottomScrim()
view.addSubview(tapSurfaceView)
view.addSubview(loadingContainer)
view.addSubview(failureContainer)
view.addSubview(centerPlayPauseButton)
view.addSubview(controlsContainer)
view.addSubview(scrubTimeBubble)
view.addSubview(closeButton)
loadingStack.addArrangedSubview(loadingView)
loadingStack.addArrangedSubview(loadingTextLabel)
loadingContainer.contentView.addSubview(loadingStack)
configureFailureCard()
closeButton.addTarget(self, action: #selector(close), for: .touchUpInside)
playPauseButton.addTarget(self, action: #selector(togglePlayPause), for: .touchUpInside)
centerPlayPauseButton.addTarget(self, action: #selector(togglePlayPause), for: .touchUpInside)
jumpBackButton.addTarget(self, action: #selector(jumpBack), for: .touchUpInside)
jumpForwardButton.addTarget(self, action: #selector(jumpForward), for: .touchUpInside)
retryButton.addTarget(self, action: #selector(retryPlayback), for: .touchUpInside)
failureCloseButton.addTarget(self, action: #selector(close), for: .touchUpInside)
audioButton.showsMenuAsPrimaryAction = true
captionsButton.showsMenuAsPrimaryAction = true
playPauseButton.layer.cornerRadius = 28
centerPlayPauseButton.layer.cornerRadius = 34
centerPlayPauseButton.alpha = 0
scrubber.addTarget(self, action: #selector(scrubbingStarted), for: .touchDown)
scrubber.addTarget(self, action: #selector(scrubberChanged), for: .valueChanged)
scrubber.addTarget(self, action: #selector(scrubbingEnded), for: [.touchUpInside, .touchUpOutside, .touchCancel])
1 unmodified line
let tap = UITapGestureRecognizer(target: self, action: #selector(toggleControlsVisibility))
tap.cancelsTouchesInView = false
tapSurfaceView.addGestureRecognizer(tap)
let leftDoubleTap = UITapGestureRecognizer(target: self, action: #selector(handleLeftDoubleTap))
leftDoubleTap.numberOfTapsRequired = 2
let rightDoubleTap = UITapGestureRecognizer(target: self, action: #selector(handleRightDoubleTap))
rightDoubleTap.numberOfTapsRequired = 2
tap.require(toFail: leftDoubleTap)
tap.require(toFail: rightDoubleTap)
tapSurfaceView.addGestureRecognizer(leftDoubleTap)
tapSurfaceView.addGestureRecognizer(rightDoubleTap)
let timeAndScrubRow = UIStackView(arrangedSubviews: [elapsedLabel, scrubber, remainingLabel])
timeAndScrubRow.translatesAutoresizingMaskIntoConstraints = false
21 unmodified lines
stack.spacing = 6
controlsContainer.contentView.addSubview(stack)
controlsMaximumWidthConstraint = controlsContainer.widthAnchor.constraint(lessThanOrEqualToConstant: 430)
NSLayoutConstraint.activate([
backend.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
backend.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
5 unmodified lines
tapSurfaceView.topAnchor.constraint(equalTo: view.topAnchor),
tapSurfaceView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
loadingContainer.centerXAnchor.constraint(equalTo: view.centerXAnchor),
loadingContainer.centerYAnchor.constraint(equalTo: view.centerYAnchor),
loadingStack.leadingAnchor.constraint(equalTo: loadingContainer.contentView.leadingAnchor, constant: 18),
loadingStack.trailingAnchor.constraint(equalTo: loadingContainer.contentView.trailingAnchor, constant: -18),
loadingStack.topAnchor.constraint(equalTo: loadingContainer.contentView.topAnchor, constant: 14),
loadingStack.bottomAnchor.constraint(equalTo: loadingContainer.contentView.bottomAnchor, constant: -14),
failureContainer.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
failureContainer.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
failureContainer.widthAnchor.constraint(lessThanOrEqualTo: view.safeAreaLayoutGuide.widthAnchor, constant: -40),
failureContainer.widthAnchor.constraint(lessThanOrEqualToConstant: 420),
centerPlayPauseButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
centerPlayPauseButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),
centerPlayPauseButton.widthAnchor.constraint(equalToConstant: 68),
centerPlayPauseButton.heightAnchor.constraint(equalToConstant: 68),
closeButton.widthAnchor.constraint(equalToConstant: 44),
closeButton.heightAnchor.constraint(equalToConstant: 44),
closeButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 10),
closeButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -10),
controlsContainer.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor),
controlsContainer.widthAnchor.constraint(lessThanOrEqualTo: view.safeAreaLayoutGuide.widthAnchor, constant: -24),
controlsMaximumWidthConstraint!,
controlsContainer.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -12),
stack.leadingAnchor.constraint(equalTo: controlsContainer.contentView.leadingAnchor, constant: 12),
5 unmodified lines
remainingLabel.widthAnchor.constraint(equalToConstant: 42),
scrubber.widthAnchor.constraint(greaterThanOrEqualToConstant: 160),
scrubTimeBubble.centerXAnchor.constraint(equalTo: controlsContainer.centerXAnchor),
scrubTimeBubble.bottomAnchor.constraint(equalTo: controlsContainer.topAnchor, constant: -8),
scrubTimeBubble.widthAnchor.constraint(greaterThanOrEqualToConstant: 64),
scrubTimeBubble.heightAnchor.constraint(equalToConstant: 28),
jumpBackButton.widthAnchor.constraint(equalToConstant: 44),
jumpBackButton.heightAnchor.constraint(equalToConstant: 44),
playPauseButton.widthAnchor.constraint(equalToConstant: 56),
playPauseButton.heightAnchor.constraint(equalToConstant: 56),
jumpForwardButton.widthAnchor.constraint(equalToConstant: 44),
jumpForwardButton.heightAnchor.constraint(equalToConstant: 44),
audioButton.widthAnchor.constraint(equalToConstant: 44),
audioButton.heightAnchor.constraint(equalToConstant: 44),
playbackCluster.centerXAnchor.constraint(equalTo: controlRow.centerXAnchor),
captionsButton.widthAnchor.constraint(equalToConstant: 44),
captionsButton.heightAnchor.constraint(equalToConstant: 44)
])
}
private func showFailure(_ error: Error) {
controlsTimer?.invalidate()
loadingView.stopAnimating()
loadingContainer.isHidden = true
controlsContainer.alpha = 0
controlsContainer.isUserInteractionEnabled = false
failureDetailLabel.text = error.localizedDescription
failureContainer.isHidden = false
closeButton.alpha = 1
closeButton.isUserInteractionEnabled = true
#if DEBUG
print("[DreamioNativePlayer] error=\(URLRedactor.redactedURLString(error.localizedDescription))")
#endif
}
@objc private func retryPlayback() {
backend.stop()
progressTimer?.invalidate()
audioMenuSignature = nil
captionsMenuSignature = nil
startPlayback()
}
@objc private func close() {
dismiss(animated: true)
}
@objc private func togglePlayPause() {
backend.togglePlayPause()
flashCenterPlayPauseIcon()
revealControls()
}
@objc private func jumpBack() {
backend.jump(by: -15)
UIImpactFeedbackGenerator(style: .light).impactOccurred()
revealControls()
}
@objc private func jumpForward() {
backend.jump(by: 15)
UIImpactFeedbackGenerator(style: .light).impactOccurred()
revealControls()
}
@objc private func scrubbingStarted() {
isScrubbing = true
controlsTimer?.invalidate()
scrubber.setThumbImage(NativePlayerViewController.scrubberThumbImage(diameter: 20), for: .normal)
scrubber.setThumbImage(NativePlayerViewController.scrubberThumbImage(diameter: 22), for: .highlighted)
UISelectionFeedbackGenerator().selectionChanged()
updateScrubPreview()
UIView.animate(withDuration: 0.16) {
self.scrubTimeBubble.alpha = 1
}
}
@objc private func scrubberChanged() {
updateScrubPreview()
}
@objc private func scrubbingEnded() {
backend.seek(to: scrubber.value)
isScrubbing = false
scrubber.setThumbImage(NativePlayerViewController.scrubberThumbImage(diameter: 14), for: .normal)
scrubber.setThumbImage(NativePlayerViewController.scrubberThumbImage(diameter: 18), for: .highlighted)
UIImpactFeedbackGenerator(style: .soft).impactOccurred()
UIView.animate(withDuration: 0.18) {
self.scrubTimeBubble.alpha = 0
}
revealControls()
}
@objc private func handleLeftDoubleTap(_ recognizer: UITapGestureRecognizer) {
guard recognizer.location(in: tapSurfaceView).x < tapSurfaceView.bounds.midX else { return }
jumpBack()
}
@objc private func handleRightDoubleTap(_ recognizer: UITapGestureRecognizer) {
guard recognizer.location(in: tapSurfaceView).x >= tapSurfaceView.bounds.midX else { return }
jumpForward()
}
@objc private func toggleControlsVisibility() {
if controlsContainer.alpha < 1 {
revealControls()
30 unmodified lines
}
let delayActions = UIMenu(
title: "Subtitle Delay",
options: .displayInline,
children: [
UIAction(title: "Decrease 0.5s") { [weak self] _ in
6 unmodified lines
self?.captionsMenuSignature = nil
self?.refreshControls()
},
UIAction(title: "Reset Delay") { [weak self] _ in
guard let self else { return }
self.backend.adjustSubtitleDelay(by: -self.backend.subtitleDelay)
self.captionsMenuSignature = nil
self.refreshControls()
},
UIAction(
title: "Current: \(String(format: "%.1fs", backend.subtitleDelay))",
attributes: .disabled
1 unmodified line
]
)
return UIMenu(title: "Subtitles", children: trackActions + [delayActions])
}
private func audioMenu() -> UIMenu {
23 unmodified lines
}
}
return UIMenu(title: "Audio Track", children: trackActions)
}
private func startProgressUpdates() {
14 unmodified lines
updateCaptionsMenuIfNeeded(subtitleTracks: subtitleTracks)
elapsedLabel.text = PlaybackTimeFormatter.label(for: backend.currentTime)
remainingLabel.text = "-\(PlaybackTimeFormatter.label(for: backend.remainingTime))"
scrubber.accessibilityValue = "\(elapsedLabel.text ?? "0:00") elapsed, \(remainingLabel.text ?? "-0:00") remaining"
if !isScrubbing {
scrubber.value = backend.position
}
9 unmodified lines
let hasSelectableTrack = AudioOptionMapper.options(from: audioTracks).count > 1
audioButton.isEnabled = hasSelectableTrack
audioButton.alpha = hasSelectableTrack ? 1 : 0.45
audioButton.accessibilityHint = hasSelectableTrack ? "Opens available audio tracks." : "Only one audio track is available."
guard signature != audioMenuSignature else {
return
}
14 unmodified lines
)
let hasSelectableTrack = subtitleTracks.contains { $0.id >= 0 }
captionsButton.isEnabled = hasSelectableTrack
captionsButton.alpha = hasSelectableTrack ? 1 : 0.45
captionsButton.accessibilityHint = hasSelectableTrack ? "Opens subtitle tracks and delay controls." : "No subtitle tracks are available yet."
guard signature != captionsMenuSignature else {
return
}
27 unmodified lines
private func revealControls() {
controlsContainer.isUserInteractionEnabled = true
closeButton.isUserInteractionEnabled = true
let animations = {
self.controlsContainer.alpha = 1
self.closeButton.alpha = 1
self.controlsContainer.transform = .identity
}
if UIAccessibility.isReduceMotionEnabled {
animations()
} else {
controlsContainer.transform = CGAffineTransform(translationX: 0, y: 8).scaledBy(x: 0.98, y: 0.98)
UIView.animate(withDuration: 0.22, delay: 0, options: [.curveEaseOut], animations: animations)
}
scheduleControlsHide()
}
private func hideControls() {
guard !isScrubbing, failureContainer.isHidden, loadingContainer.isHidden else { return }
controlsContainer.isUserInteractionEnabled = false
closeButton.isUserInteractionEnabled = false
UIView.animate(withDuration: 0.28, delay: 0, options: [.curveEaseInOut]) {
self.controlsContainer.alpha = 0
self.closeButton.alpha = 0
}
1 unmodified line
private func scheduleControlsHide() {
controlsTimer?.invalidate()
guard backend.isPlaying, !isScrubbing, failureContainer.isHidden, loadingContainer.isHidden else {
return
}
controlsTimer = Timer.scheduledTimer(withTimeInterval: 4.5, repeats: false) { [weak self] _ in
self?.hideControls()
}
}
private func configureBottomScrim() {
bottomScrimLayer.colors = [
UIColor.clear.cgColor,
UIColor.black.withAlphaComponent(0.12).cgColor,
UIColor.black.withAlphaComponent(0.48).cgColor
]
bottomScrimLayer.locations = [0, 0.58, 1]
view.layer.insertSublayer(bottomScrimLayer, above: backend.view.layer)
}
private func configureFailureCard() {
let buttonRow = UIStackView(arrangedSubviews: [failureCloseButton, retryButton])
buttonRow.translatesAutoresizingMaskIntoConstraints = false
buttonRow.axis = .horizontal
buttonRow.distribution = .fillEqually
buttonRow.spacing = 10
let stack = UIStackView(arrangedSubviews: [failureTitleLabel, failureDetailLabel, buttonRow])
stack.translatesAutoresizingMaskIntoConstraints = false
stack.axis = .vertical
stack.alignment = .fill
stack.spacing = 14
failureContainer.contentView.addSubview(stack)
NSLayoutConstraint.activate([
stack.leadingAnchor.constraint(equalTo: failureContainer.contentView.leadingAnchor, constant: 20),
stack.trailingAnchor.constraint(equalTo: failureContainer.contentView.trailingAnchor, constant: -20),
stack.topAnchor.constraint(equalTo: failureContainer.contentView.topAnchor, constant: 20),
stack.bottomAnchor.constraint(equalTo: failureContainer.contentView.bottomAnchor, constant: -20),
retryButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 44),
failureCloseButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 44)
])
}
private func configureAccessibility() {
scrubber.accessibilityLabel = "Playback Position"
scrubber.accessibilityHint = "Adjusts the playback position."
playPauseButton.accessibilityHint = "Toggles playback."
jumpBackButton.accessibilityHint = "Rewinds 15 seconds when seeking is available."
jumpForwardButton.accessibilityHint = "Skips ahead 15 seconds when seeking is available."
view.accessibilityCustomActions = [
UIAccessibilityCustomAction(name: "Jump Back 15 Seconds", target: self, selector: #selector(accessibilityJumpBack)),
UIAccessibilityCustomAction(name: "Jump Forward 15 Seconds", target: self, selector: #selector(accessibilityJumpForward))
]
}
@objc private func accessibilityJumpBack() -> Bool {
jumpBack()
return true
}
@objc private func accessibilityJumpForward() -> Bool {
jumpForward()
return true
}
private func updateLayoutForCurrentSize() {
controlsMaximumWidthConstraint?.constant = traitCollection.horizontalSizeClass == .regular ? 560 : 430
}
private func updateScrubPreview() {
let target = TimeInterval(scrubber.value) * backend.duration
let label = PlaybackTimeFormatter.label(for: target)
elapsedLabel.text = label
scrubTimeBubble.text = " \(label) "
}
private func flashCenterPlayPauseIcon() {
centerPlayPauseButton.setImage(UIImage(systemName: backend.isPlaying ? "pause.fill" : "play.fill"), for: .normal)
guard !UIAccessibility.isReduceMotionEnabled else { return }
centerPlayPauseButton.transform = CGAffineTransform(scaleX: 0.86, y: 0.86)
UIView.animate(withDuration: 0.16, animations: {
self.centerPlayPauseButton.alpha = 1
self.centerPlayPauseButton.transform = .identity
}) { _ in
UIView.animate(withDuration: 0.22, delay: 0.28, options: [.curveEaseOut]) {
self.centerPlayPauseButton.alpha = 0
}
}
}
private static func glassPanel(cornerRadius: CGFloat) -> UIVisualEffectView {
let effect: UIVisualEffect
if #available(iOS 26.0, *) {
let glassEffect = UIGlassEffect()
glassEffect.tintColor = UIColor(red: 0.64, green: 0.48, blue: 1.0, alpha: 0.16)
glassEffect.isInteractive = true
effect = glassEffect
} else {
effect = UIBlurEffect(style: .systemUltraThinMaterialDark)
}
let view = UIVisualEffectView(effect: effect)
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.cornerRadius = cornerRadius
view.clipsToBounds = true
view.backgroundColor = UIColor.white.withAlphaComponent(0.09)
view.layer.borderColor = UIColor.white.withAlphaComponent(0.22).cgColor
view.layer.borderWidth = 1
return view
}
private static func iconButton(systemName: String, label: String, pointSize: CGFloat = 20) -> UIButton {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
let configuration = UIImage.SymbolConfiguration(pointSize: pointSize, weight: .semibold)
button.setImage(UIImage(systemName: systemName, withConfiguration: configuration), for: .normal)
button.tintColor = .white
button.backgroundColor = UIColor.white.withAlphaComponent(0.14)
button.layer.cornerRadius = 22
button.layer.borderColor = UIColor.white.withAlphaComponent(0.16).cgColor
button.layer.borderWidth = 1
button.accessibilityLabel = label
return button
}
private static func textButton(title: String) -> UIButton {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle(title, for: .normal)
button.setTitleColor(.white, for: .normal)
button.titleLabel?.font = .preferredFont(forTextStyle: .headline)
button.titleLabel?.adjustsFontForContentSizeCategory = true
button.backgroundColor = UIColor.white.withAlphaComponent(0.16)
button.layer.cornerRadius = 14
button.layer.borderColor = UIColor.white.withAlphaComponent(0.18).cgColor
button.layer.borderWidth = 1
return button
}
private static func scrubberThumbImage(diameter: CGFloat) -> UIImage {
let format = UIGraphicsImageRendererFormat()
format.scale = UIScreen.main.scale

Rendered with @pierre/diffs/ssr.

Expected Impact for End-Users

Users should see a more polished, readable, and forgiving native player with better touch ergonomics, clearer recovery from failures, more helpful loading feedback, and faster jump interactions.

Validation

Issues, Limitations, and Mitigations

Follow-up Work