From ed884c23f5a489d7a872d40e39bab38e0ac0e9c7 Mon Sep 17 00:00:00 2001 From: kintan Date: Sun, 17 Mar 2024 22:11:12 +0800 Subject: [PATCH] fix build --- Sources/KSPlayer/AVPlayer/KSVideoPlayer.swift | 2 +- .../MEPlayer/ThumbnailController.swift | 2 +- .../KSPlayer/SwiftUI/KSVideoPlayerView.swift | 26 +++++++++--------- .../SwiftUI/KSVideoPlayerViewBuilder.swift | 27 +++++++++---------- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Sources/KSPlayer/AVPlayer/KSVideoPlayer.swift b/Sources/KSPlayer/AVPlayer/KSVideoPlayer.swift index 5019f27d3..88fd926bf 100644 --- a/Sources/KSPlayer/AVPlayer/KSVideoPlayer.swift +++ b/Sources/KSPlayer/AVPlayer/KSVideoPlayer.swift @@ -93,7 +93,7 @@ extension KSVideoPlayer: UIViewRepresentable { playerLayer?.player.isMuted = isMuted } } - + @Published public var playbackVolume: Float = 1.0 { didSet { diff --git a/Sources/KSPlayer/MEPlayer/ThumbnailController.swift b/Sources/KSPlayer/MEPlayer/ThumbnailController.swift index 8eaec2f6c..c543f88ba 100644 --- a/Sources/KSPlayer/MEPlayer/ThumbnailController.swift +++ b/Sources/KSPlayer/MEPlayer/ThumbnailController.swift @@ -106,7 +106,7 @@ public class ThumbnailController { } let ret = avcodec_receive_frame(codecContext, frame) if ret < 0 { - if (ret == -(EAGAIN)) { + if ret == -EAGAIN { continue } else { break diff --git a/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift b/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift index 5d66e71b1..d5458c008 100644 --- a/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift +++ b/Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift @@ -249,7 +249,7 @@ public struct KSVideoPlayerView: View { .opacity(playerCoordinator.isMaskShow ? 1 : 0) .padding() } - + private func ornamentView(playerWidth: Double) -> some View { VStack(alignment: .leading) { KSVideoPlayerViewBuilder.titleView(title: title, config: playerCoordinator) @@ -259,10 +259,12 @@ public struct KSVideoPlayerView: View { .buttonStyle(.plain) .padding(.vertical, 24) .padding(.horizontal, 36) - .glassBackgroundEffect() + #if os(xrOS) + .glassBackgroundEffect() + #endif } - - private func ornamentControlsView(playerWidth: Double) -> some View { + + private func ornamentControlsView(playerWidth _: Double) -> some View { HStack { KSVideoPlayerViewBuilder.playbackControlView(config: playerCoordinator, spacing: 16) Spacer() @@ -430,13 +432,13 @@ struct VideoControllerView: View { private var muteButton: some View { #if os(xrOS) HStack { - Slider(value: $config.playbackVolume, in: 0...1) - .onChange(of: config.playbackVolume, { _, newValue in - config.isMuted = newValue == 0 - }) - .frame(width: volumeSliderSize ?? 100) - .tint(.white.opacity(0.8)) - .padding(.leading, 16) + Slider(value: $config.playbackVolume, in: 0 ... 1) + .onChange(of: config.playbackVolume) { _, newValue in + config.isMuted = newValue == 0 + } + .frame(width: volumeSliderSize ?? 100) + .tint(.white.opacity(0.8)) + .padding(.leading, 16) KSVideoPlayerViewBuilder.muteButton(config: config) } .padding(16) @@ -548,7 +550,7 @@ struct VideoTimeShowView: View { } .frame(maxHeight: 20) #if os(xrOS) - .tint(.white.opacity(0.8)) + .tint(.white.opacity(0.8)) #endif Text((model.totalTime).toString(for: .minOrHour)).font(timeFont ?? .caption2.monospacedDigit()) } diff --git a/Sources/KSPlayer/SwiftUI/KSVideoPlayerViewBuilder.swift b/Sources/KSPlayer/SwiftUI/KSVideoPlayerViewBuilder.swift index c50b527ce..1985e609a 100644 --- a/Sources/KSPlayer/SwiftUI/KSVideoPlayerViewBuilder.swift +++ b/Sources/KSPlayer/SwiftUI/KSVideoPlayerViewBuilder.swift @@ -7,8 +7,8 @@ import SwiftUI +@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) enum KSVideoPlayerViewBuilder { - @MainActor static func playbackControlView(config: KSVideoPlayer.Coordinator, spacing: CGFloat? = nil) -> some View { HStack(spacing: spacing) { @@ -28,7 +28,7 @@ enum KSVideoPlayerViewBuilder { #endif } } - + @MainActor static func contentModeButton(config: KSVideoPlayer.Coordinator) -> some View { Button { @@ -37,7 +37,7 @@ enum KSVideoPlayerViewBuilder { Image(systemName: config.isScaleAspectFill ? "rectangle.arrowtriangle.2.inward" : "rectangle.arrowtriangle.2.outward") } } - + @MainActor static func subtitleButton(config: KSVideoPlayer.Coordinator) -> some View { MenuView(selection: Binding { @@ -58,7 +58,7 @@ enum KSVideoPlayerViewBuilder { Image(systemName: "text.bubble.fill") } } - + @MainActor static func playbackRateButton(playbackRate: Binding) -> some View { MenuView(selection: playbackRate) { @@ -71,7 +71,7 @@ enum KSVideoPlayerViewBuilder { Image(systemName: "gauge.with.dots.needle.67percent") } } - + @MainActor static func titleView(title: String, config: KSVideoPlayer.Coordinator) -> some View { HStack { @@ -81,7 +81,7 @@ enum KSVideoPlayerViewBuilder { .opacity(config.state == .buffering ? 1 : 0) } } - + @MainActor static func muteButton(config: KSVideoPlayer.Coordinator) -> some View { Button { @@ -91,7 +91,7 @@ enum KSVideoPlayerViewBuilder { } .shadow(color: .black, radius: 1) } - + static func infoButton(showVideoSetting: Binding) -> some View { Button { showVideoSetting.wrappedValue.toggle() @@ -105,8 +105,8 @@ enum KSVideoPlayerViewBuilder { } } +@available(iOS 16.0, macOS 13.0, tvOS 16.0, *) private extension KSVideoPlayerViewBuilder { - static var playSystemName: String { #if os(xrOS) "play.fill" @@ -122,8 +122,7 @@ private extension KSVideoPlayerViewBuilder { "pause.circle.fill" #endif } - - + static var speakerSystemName: String { #if os(xrOS) "speaker.fill" @@ -139,7 +138,7 @@ private extension KSVideoPlayerViewBuilder { "speaker.slash.circle.fill" #endif } - + @MainActor @ViewBuilder static func backwardButton(config: KSVideoPlayer.Coordinator) -> some View { @@ -155,7 +154,7 @@ private extension KSVideoPlayerViewBuilder { #endif } } - + @MainActor @ViewBuilder static func forwardButton(config: KSVideoPlayer.Coordinator) -> some View { @@ -171,7 +170,7 @@ private extension KSVideoPlayerViewBuilder { #endif } } - + @MainActor static func playButton(config: KSVideoPlayer.Coordinator) -> some View { Button { @@ -185,7 +184,7 @@ private extension KSVideoPlayerViewBuilder { .font(.largeTitle) } #if os(xrOS) - .contentTransition(.symbolEffect(.replace)) + .contentTransition(.symbolEffect(.replace)) #endif #if !os(tvOS) .keyboardShortcut(.space, modifiers: .none)