Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Player Manager Refactor #1203

Draft
wants to merge 107 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
1f6701c
wip
LePips Aug 19, 2024
f15c590
wip
LePips Aug 20, 2024
d368b20
wip
LePips Aug 20, 2024
acb6eab
tvos
LePips Aug 20, 2024
4e01daf
wip
LePips Aug 20, 2024
c38b4ca
wip
LePips Aug 24, 2024
b3bbdab
wip
LePips Aug 27, 2024
52cb03e
wip
LePips Aug 29, 2024
ec98005
Merge branch 'main' into now-playable-app
LePips Sep 2, 2024
bbe1e1d
wip
LePips Sep 2, 2024
4010406
wip
LePips Sep 3, 2024
86840d9
wip
LePips Sep 3, 2024
a203594
wip
LePips Sep 5, 2024
d70aedf
wip
LePips Sep 5, 2024
cc5f88d
wip
LePips Sep 6, 2024
b422eb2
wip
LePips Sep 9, 2024
242a22c
wip
LePips Sep 9, 2024
d7893c0
wip
LePips Sep 9, 2024
0b1e2f1
Update SwiftfinDefaults.swift
LePips Sep 9, 2024
793e496
wip
LePips Sep 10, 2024
789bac5
wip
LePips Sep 10, 2024
70c4565
wip
LePips Sep 12, 2024
32bfba1
Update TopBarView.swift
LePips Sep 12, 2024
579fa7c
wip
LePips Sep 13, 2024
1a33462
wip
LePips Sep 19, 2024
1f2ee0d
wip
LePips Sep 21, 2024
ebf2bda
wip
LePips Sep 22, 2024
786e14d
cleanup
LePips Sep 23, 2024
39f37c2
wip
LePips Sep 27, 2024
7512069
wip
LePips Oct 1, 2024
ea116eb
wip
LePips Oct 4, 2024
64ab8b2
wip
LePips Oct 5, 2024
27b9b1e
Merge branch 'main' into now-playable-app
LePips Oct 6, 2024
5025692
wip
LePips Oct 6, 2024
6cd165e
wip
LePips Oct 7, 2024
c4498ce
wip
LePips Oct 11, 2024
48d6ff7
wip
LePips Oct 11, 2024
961673a
wip
LePips Oct 11, 2024
2fd0e82
wip
LePips Oct 12, 2024
1a784ba
wip
LePips Oct 12, 2024
c2792f3
wip
LePips Oct 12, 2024
611c5c0
wip
LePips Oct 13, 2024
67c60d8
wip
LePips Oct 13, 2024
a51aa2c
wip
LePips Oct 13, 2024
e8ab1b1
wip
LePips Oct 14, 2024
7f4b3f2
wip
LePips Oct 14, 2024
9ef91d5
wip
LePips Oct 14, 2024
9929241
wip
LePips Oct 14, 2024
93d2a98
Update MediaChaptersSupplement.swift
LePips Oct 15, 2024
41481e4
Merge branch 'main' into now-playable-app
LePips Oct 15, 2024
46bc4a7
wip
LePips Oct 15, 2024
acf4cca
wip
LePips Oct 15, 2024
f928fb8
wip
LePips Oct 17, 2024
b10d3d8
wip
LePips Oct 17, 2024
d9ba181
wip
LePips Oct 17, 2024
41a68bb
wip
LePips Oct 17, 2024
7ec1556
wip
LePips Oct 18, 2024
fdb8944
wip
LePips Oct 18, 2024
d7454d8
wip
LePips Oct 20, 2024
b4fd687
wip
LePips Oct 21, 2024
6f3d121
wip
LePips Oct 23, 2024
204f4c7
wip
LePips Oct 26, 2024
4eab0ee
wip
LePips Oct 26, 2024
b931d6a
wip
LePips Oct 26, 2024
dfc863b
wip
LePips Oct 27, 2024
c12679e
wip
LePips Oct 28, 2024
ab8dcb0
wip
LePips Oct 29, 2024
1a43693
wip
LePips Oct 29, 2024
b05a16f
wip
LePips Oct 30, 2024
19d5ceb
wip
LePips Oct 31, 2024
2ddcf2f
Update Overlay+Gesture.swift
LePips Nov 4, 2024
1002a3a
wip
LePips Nov 5, 2024
a8f6ab0
wip
LePips Nov 9, 2024
c3713a8
wip
LePips Nov 9, 2024
5b96210
Merge branch 'main' into now-playable-app
LePips Nov 27, 2024
7bdfc35
Create Package.resolved
LePips Nov 27, 2024
f34e87e
wip
LePips Dec 3, 2024
d4008b4
wip
LePips Dec 3, 2024
24e7c12
wip
LePips Dec 5, 2024
0ebb494
wip
LePips Dec 7, 2024
a68f52c
Merge branch 'main' into now-playable-app
LePips Dec 11, 2024
383fb18
wip
LePips Dec 12, 2024
f05c7a9
wip
LePips Dec 13, 2024
a47c8be
wip
LePips Dec 13, 2024
9fcd122
wip
LePips Dec 14, 2024
8cadb6e
wip
LePips Dec 14, 2024
efda9e7
Merge branch 'main' into now-playable-app
LePips Dec 20, 2024
32c7b3f
wip
LePips Dec 20, 2024
4bcf231
Update project.pbxproj
LePips Dec 20, 2024
08081c5
Merge branch 'main' into now-playable-app
LePips Dec 31, 2024
f38be99
wip
LePips Dec 31, 2024
6a04461
Update VideoPlayer+KeyCommands.swift
LePips Dec 31, 2024
c9b814c
wip
LePips Jan 1, 2025
9b45f5d
wip
LePips Jan 10, 2025
92cbcba
Merge branch 'main' into now-playable-app
LePips Jan 10, 2025
4457d25
wip
LePips Jan 10, 2025
2316071
wip
LePips Jan 10, 2025
991e7bf
wip
LePips Jan 10, 2025
00ead63
wip
LePips Jan 11, 2025
fa76fec
wip
LePips Jan 11, 2025
dda58f3
wip
LePips Jan 11, 2025
c20b1ad
wip
LePips Jan 11, 2025
2f87814
wip
LePips Jan 11, 2025
886a787
wip
LePips Jan 11, 2025
3592517
Merge branch 'main' into now-playable-app
LePips Jan 11, 2025
7487fb1
Update Overlay.swift
LePips Jan 17, 2025
ca9f346
wip
LePips Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions PreferencesView/Sources/PreferencesView/PreferenceKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ struct PreferredScreenEdgesDeferringSystemGesturesPreferenceKey: PreferenceKey {

static var defaultValue: UIRectEdge = [.left, .right]

static func reduce(value: inout UIRectEdge, nextValue: () -> UIRectEdge) {}
static func reduce(value: inout UIRectEdge, nextValue: () -> UIRectEdge) {
value = nextValue()
}
}

struct PrefersHomeIndicatorAutoHiddenPreferenceKey: PreferenceKey {

static var defaultValue: Bool = false

static func reduce(value: inout Bool, nextValue: () -> Bool) {
value = nextValue() || value
value = nextValue()
}
}

Expand Down
3 changes: 3 additions & 0 deletions Shared/Components/AlternateLayoutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import SwiftUI

// TODO: remove frame

/// A view that takes a view to affect layout while overlaying the content.
struct AlternateLayoutView<Content: View, Layout: View>: View {

Expand All @@ -27,6 +29,7 @@ struct AlternateLayoutView<Content: View, Layout: View>: View {

var body: some View {
layout()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.hidden()
.overlay(alignment: alignment) {
content()
Expand Down
2 changes: 1 addition & 1 deletion Shared/Components/ImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Nuke
import NukeUI
import SwiftUI

// TODO: currently SVGs are only supported for logos, which are only used in a few places.
// TODO: currently SVGs are only "officially" supported for logos, which are only used in a few places.
// make it so when displaying an SVG there is a unified `image` caller modifier
// TODO: `LazyImage` uses a transaction for view swapping, which will fade out old views
// and fade in new views, causing a black "flash" between the placeholder and final image.
Expand Down
36 changes: 36 additions & 0 deletions Shared/Components/OpacityLinearGradient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
//

import SwiftUI

struct OpacityLinearGradient: View {

typealias Stop = (location: CGFloat, opacity: CGFloat)

private let stops: [Stop]

init(@ArrayBuilder<Stop> stops: () -> [Stop]) {
self.stops = stops()
}

var body: some View {
Rectangle()
.mask {
LinearGradient(
stops: stops.map {
Gradient.Stop(
color: Color.black.opacity($0.opacity),
location: $0.location
)
},
startPoint: .top,
endPoint: .bottom
)
}
}
}
56 changes: 1 addition & 55 deletions Shared/Components/ProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

// TODO: remove and replace with below
// TODO: remove and replace with `PlaybackProgressViewStyle`
struct ProgressBar: View {

@State
Expand All @@ -31,57 +31,3 @@ struct ProgressBar: View {
.trackingSize($contentSize)
}
}

// TODO: fix capsule with low progress

extension ProgressViewStyle where Self == PlaybackProgressViewStyle {

static var playback: Self { .init(secondaryProgress: nil) }

static func playback(secondaryProgress: Double?) -> Self {
.init(secondaryProgress: secondaryProgress)
}
}

struct PlaybackProgressViewStyle: ProgressViewStyle {

@State
private var contentSize: CGSize = .zero

let secondaryProgress: Double?

func makeBody(configuration: Configuration) -> some View {
Capsule()
.foregroundStyle(.secondary)
.opacity(0.2)
.overlay(alignment: .leading) {
ZStack(alignment: .leading) {

if let secondaryProgress {
Capsule()
.mask(alignment: .leading) {
Rectangle()
}
.frame(width: contentSize.width * clamp(secondaryProgress, min: 0, max: 1))
.foregroundStyle(.tertiary)
}

Capsule()
.mask(alignment: .leading) {
Rectangle()
}
.frame(width: contentSize.width * (configuration.fractionCompleted ?? 0))
.foregroundStyle(.primary)
}
}
.trackingSize($contentSize)
}
}

// #Preview {
// ProgressView(value: 0.3)
// .progressViewStyle(.SwiftfinLinear(secondaryProgress: 0.3))
// .frame(height: 8)
// .padding(.horizontal, 10)
// .foregroundStyle(.primary, .secondary, .orange)
// }
1 change: 1 addition & 0 deletions Shared/Components/SystemImageContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI

// TODO: bottom view can probably just be cleaned up and change
// usages to use local background views
// TODO: use heirarchical styles instead of explicit color

struct RelativeSystemImageView: View {

Expand Down
2 changes: 1 addition & 1 deletion Shared/Components/TruncatedText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct TruncatedText: View {
}
}
}
.visible(isTruncated)
.isVisible(isTruncated)
}

if isTruncated {
Expand Down
1 change: 1 addition & 0 deletions Shared/Components/WrappedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SwiftUI
// but doesn't work with animations/transitions.
// Look at alternative with just ZStack and remove

// @available(*, deprecated, message: "Use ZStack instead")
struct WrappedView<Content: View>: View {

@ViewBuilder
Expand Down
4 changes: 2 additions & 2 deletions Shared/Coordinators/AppSettingsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ final class AppSettingsCoordinator: NavigationCoordinatable {

#if os(iOS)
@ViewBuilder
func makeAbout(viewModel: SettingsViewModel) -> some View {
AboutAppView(viewModel: viewModel)
func makeAbout() -> some View {
AboutAppView()
}

@ViewBuilder
Expand Down
4 changes: 2 additions & 2 deletions Shared/Coordinators/ItemCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ final class ItemCoordinator: NavigationCoordinatable {
#endif

#if os(tvOS)
func makeVideoPlayer(manager: VideoPlayerManager) -> NavigationViewCoordinator<VideoPlayerCoordinator> {
NavigationViewCoordinator(VideoPlayerCoordinator(manager: manager))
func makeVideoPlayer(manager: MediaPlayerManager) -> VideoPlayerCoordinator {
VideoPlayerCoordinator(manager: manager)
}
#endif

Expand Down
82 changes: 0 additions & 82 deletions Shared/Coordinators/LiveVideoPlayerCoordinator.swift

This file was deleted.

42 changes: 38 additions & 4 deletions Shared/Coordinators/MainCoordinator/iOSMainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ final class MainCoordinator: NavigationCoordinatable {
@Root
var serverCheck = makeServerCheck

#if DEBUG
@Route(.fullScreen)
var liveVideoPlayer = makeLiveVideoPlayer
var debugPlayground = makeDebugPlayground
#endif

@Route(.modal)
var settings = makeSettings
@Route(.fullScreen)
Expand Down Expand Up @@ -79,6 +82,20 @@ final class MainCoordinator: NavigationCoordinatable {
Notifications[.didSignOut].subscribe(self, selector: #selector(didSignOut))
Notifications[.processDeepLink].subscribe(self, selector: #selector(processDeepLink(_:)))
Notifications[.didChangeCurrentServerURL].subscribe(self, selector: #selector(didChangeCurrentServerURL(_:)))

#if DEBUG
NotificationCenter.default.addObserver(
self,
selector: #selector(didShake),
name: UIDevice.deviceDidShakeNotification,
object: nil
)
#endif
}

@objc
private func didShake() {
self.route(to: \.debugPlayground)
}

private func didFinishMigration() {}
Expand Down Expand Up @@ -148,11 +165,28 @@ final class MainCoordinator: NavigationCoordinatable {
}
}

func makeVideoPlayer(manager: VideoPlayerManager) -> VideoPlayerCoordinator {
func makeVideoPlayer(manager: MediaPlayerManager) -> VideoPlayerCoordinator {
VideoPlayerCoordinator(manager: manager)
}

func makeLiveVideoPlayer(manager: LiveVideoPlayerManager) -> LiveVideoPlayerCoordinator {
LiveVideoPlayerCoordinator(manager: manager)
#if DEBUG
@ViewBuilder
func makeDebugPlayground() -> some View {
DebugPlaygroundView()
}
#endif
}

// The notification we'll send when a shake gesture happens.
extension UIDevice {
static let deviceDidShakeNotification = Notification.Name(rawValue: "deviceDidShakeNotification")
}

// Override the default behavior of shake gestures to send our notification instead.
extension UIWindow {
override open func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
if motion == .motionShake {
NotificationCenter.default.post(name: UIDevice.deviceDidShakeNotification, object: nil)
}
}
}
46 changes: 0 additions & 46 deletions Shared/Coordinators/PlaybackSettingsCoordinator.swift

This file was deleted.

Loading