From a5f9877474e282ee4c3435f6bc3e00ab149c2c16 Mon Sep 17 00:00:00 2001 From: Seiike <122684677+Seeike@users.noreply.github.com> Date: Sat, 22 Mar 2025 12:29:58 +0100 Subject: [PATCH 1/4] progression timer wont show hours unless media is longer than an hour --- .../CustomPlayer/Components/MusicProgressSlider.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sora/Utils/MediaPlayer/CustomPlayer/Components/MusicProgressSlider.swift b/Sora/Utils/MediaPlayer/CustomPlayer/Components/MusicProgressSlider.swift index 57fb3e5..e8a3ca8 100644 --- a/Sora/Utils/MediaPlayer/CustomPlayer/Components/MusicProgressSlider.swift +++ b/Sora/Utils/MediaPlayer/CustomPlayer/Components/MusicProgressSlider.swift @@ -42,10 +42,13 @@ struct MusicProgressSlider: View { } HStack { - Text(value.asTimeString(style: .positional, showHours: true)) + // Determine if we should show hours based on the total duration. + let shouldShowHours = inRange.upperBound >= 3600 + Text(value.asTimeString(style: .positional, showHours: shouldShowHours)) Spacer(minLength: 0) - Text("-" + (inRange.upperBound - value).asTimeString(style: .positional, showHours: true)) + Text("-" + (inRange.upperBound - value).asTimeString(style: .positional, showHours: shouldShowHours)) } + .font(.system(size: 12)) .foregroundColor(isActive ? fillColor : emptyColor) } From 0a526b2fe9ce10909037cdb62e661ca0dc3cb94d Mon Sep 17 00:00:00 2001 From: Seiike <122684677+Seeike@users.noreply.github.com> Date: Sat, 22 Mar 2025 13:12:05 +0100 Subject: [PATCH 2/4] adjusted the positions of the buttons for symmetry --- .../CustomPlayer/CustomPlayer.swift | 57 ++++++++----------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift b/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift index c18dff6..cb8cfdb 100644 --- a/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift +++ b/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift @@ -144,9 +144,9 @@ class CustomMediaPlayerViewController: UIViewController { addInvisibleControlOverlays() setupSubtitleLabel() setupDismissButton() + setupQualityButton() setupMenuButton() setupSpeedButton() - setupQualityButton() setupSkip85Button() setupWatchNextButton() addTimeObserver() @@ -527,20 +527,20 @@ class CustomMediaPlayerViewController: UIViewController { menuButton = UIButton(type: .system) menuButton.setImage(UIImage(systemName: "text.bubble"), for: .normal) menuButton.tintColor = .white - + if let subtitlesURL = subtitlesURL, !subtitlesURL.isEmpty { menuButton.showsMenuAsPrimaryAction = true menuButton.menu = buildOptionsMenu() } else { menuButton.isHidden = true } - + controlsContainerView.addSubview(menuButton) menuButton.translatesAutoresizingMaskIntoConstraints = false - guard let sliderView = sliderHostingController?.view else { return } + NSLayoutConstraint.activate([ - menuButton.bottomAnchor.constraint(equalTo: sliderView.topAnchor), - menuButton.trailingAnchor.constraint(equalTo: sliderView.trailingAnchor), + menuButton.topAnchor.constraint(equalTo: controlsContainerView.topAnchor, constant: 20), + menuButton.trailingAnchor.constraint(equalTo: qualityButton.leadingAnchor, constant: -20), menuButton.widthAnchor.constraint(equalToConstant: 40), menuButton.heightAnchor.constraint(equalToConstant: 40) ]) @@ -550,30 +550,20 @@ class CustomMediaPlayerViewController: UIViewController { speedButton = UIButton(type: .system) speedButton.setImage(UIImage(systemName: "speedometer"), for: .normal) speedButton.tintColor = .white - + speedButton.showsMenuAsPrimaryAction = true - speedButton.menu = speedChangerMenu() - + speedButton.menu = speedChangerMenu() // If you want the speed menu + controlsContainerView.addSubview(speedButton) speedButton.translatesAutoresizingMaskIntoConstraints = false - - guard let sliderView = sliderHostingController?.view else { return } - - if menuButton.isHidden { - NSLayoutConstraint.activate([ - speedButton.bottomAnchor.constraint(equalTo: controlsContainerView.bottomAnchor, constant: -50), - speedButton.trailingAnchor.constraint(equalTo: sliderView.trailingAnchor), - speedButton.widthAnchor.constraint(equalToConstant: 40), - speedButton.heightAnchor.constraint(equalToConstant: 40) - ]) - } else { - NSLayoutConstraint.activate([ - speedButton.bottomAnchor.constraint(equalTo: controlsContainerView.bottomAnchor, constant: -50), - speedButton.trailingAnchor.constraint(equalTo: menuButton.leadingAnchor), - speedButton.widthAnchor.constraint(equalToConstant: 40), - speedButton.heightAnchor.constraint(equalToConstant: 40) - ]) - } + + // Pin it at the top, to the left of the subtitles (menu) button. + NSLayoutConstraint.activate([ + speedButton.topAnchor.constraint(equalTo: controlsContainerView.topAnchor, constant: 20), + speedButton.trailingAnchor.constraint(equalTo: menuButton.leadingAnchor, constant: -20), + speedButton.widthAnchor.constraint(equalToConstant: 40), + speedButton.heightAnchor.constraint(equalToConstant: 40) + ]) } func setupWatchNextButton() { @@ -599,8 +589,8 @@ class CustomMediaPlayerViewController: UIViewController { ] watchNextButtonControlsConstraints = [ - watchNextButton.trailingAnchor.constraint(equalTo: qualityButton.leadingAnchor), - watchNextButton.bottomAnchor.constraint(equalTo: skip85Button.bottomAnchor), + watchNextButton.trailingAnchor.constraint(equalTo: sliderHostingController!.view.trailingAnchor), + watchNextButton.bottomAnchor.constraint(equalTo: sliderHostingController!.view.topAnchor, constant: -5), watchNextButton.heightAnchor.constraint(equalToConstant: 50), watchNextButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 120) ] @@ -637,17 +627,18 @@ class CustomMediaPlayerViewController: UIViewController { qualityButton.showsMenuAsPrimaryAction = true qualityButton.menu = qualitySelectionMenu() qualityButton.isHidden = true - + controlsContainerView.addSubview(qualityButton) qualityButton.translatesAutoresizingMaskIntoConstraints = false - + NSLayoutConstraint.activate([ - qualityButton.bottomAnchor.constraint(equalTo: controlsContainerView.bottomAnchor, constant: -50), - qualityButton.trailingAnchor.constraint(equalTo: speedButton.leadingAnchor), + qualityButton.topAnchor.constraint(equalTo: controlsContainerView.topAnchor, constant: 20), + qualityButton.trailingAnchor.constraint(equalTo: controlsContainerView.trailingAnchor, constant: -20), qualityButton.widthAnchor.constraint(equalToConstant: 40), qualityButton.heightAnchor.constraint(equalToConstant: 40) ]) } + func updateSubtitleLabelAppearance() { subtitleLabel.font = UIFont.systemFont(ofSize: CGFloat(subtitleFontSize)) From 607e8a9677e66239f6b2afe5908aeb7b3d13b15d Mon Sep 17 00:00:00 2001 From: Seiike <122684677+Seeike@users.noreply.github.com> Date: Sat, 22 Mar 2025 13:24:12 +0100 Subject: [PATCH 3/4] =?UTF-8?q?problem=20solved=20=F0=9F=8E=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift b/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift index cb8cfdb..1acb788 100644 --- a/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift +++ b/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift @@ -145,8 +145,8 @@ class CustomMediaPlayerViewController: UIViewController { setupSubtitleLabel() setupDismissButton() setupQualityButton() - setupMenuButton() setupSpeedButton() + setupMenuButton() setupSkip85Button() setupWatchNextButton() addTimeObserver() @@ -540,7 +540,7 @@ class CustomMediaPlayerViewController: UIViewController { NSLayoutConstraint.activate([ menuButton.topAnchor.constraint(equalTo: controlsContainerView.topAnchor, constant: 20), - menuButton.trailingAnchor.constraint(equalTo: qualityButton.leadingAnchor, constant: -20), + menuButton.trailingAnchor.constraint(equalTo: speedButton.leadingAnchor, constant: -20), menuButton.widthAnchor.constraint(equalToConstant: 40), menuButton.heightAnchor.constraint(equalToConstant: 40) ]) @@ -550,17 +550,16 @@ class CustomMediaPlayerViewController: UIViewController { speedButton = UIButton(type: .system) speedButton.setImage(UIImage(systemName: "speedometer"), for: .normal) speedButton.tintColor = .white - speedButton.showsMenuAsPrimaryAction = true - speedButton.menu = speedChangerMenu() // If you want the speed menu + speedButton.menu = speedChangerMenu() controlsContainerView.addSubview(speedButton) speedButton.translatesAutoresizingMaskIntoConstraints = false - // Pin it at the top, to the left of the subtitles (menu) button. NSLayoutConstraint.activate([ + // Middle speedButton.topAnchor.constraint(equalTo: controlsContainerView.topAnchor, constant: 20), - speedButton.trailingAnchor.constraint(equalTo: menuButton.leadingAnchor, constant: -20), + speedButton.trailingAnchor.constraint(equalTo: qualityButton.leadingAnchor, constant: -20), speedButton.widthAnchor.constraint(equalToConstant: 40), speedButton.heightAnchor.constraint(equalToConstant: 40) ]) From 6d08ce08cadaaee29347701e78c4f5e9d06a7de6 Mon Sep 17 00:00:00 2001 From: Seiike <122684677+Seeike@users.noreply.github.com> Date: Sat, 22 Mar 2025 13:32:53 +0100 Subject: [PATCH 4/4] info about double tapping the screen in settings --- .../SettingsView/SettingsSubViews/SettingsViewPlayer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift index 4f855ee..2792468 100644 --- a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift +++ b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewPlayer.swift @@ -58,7 +58,7 @@ struct SettingsViewPlayer: View { } } } - Section(header: Text("Skip Settings")) { + Section(header: Text("Skip Settings"), footer : Text("Double tapping the screen on it's sides will skip with the short tap setting.")) { HStack { Text("Tap Skip:") Spacer()