2022-06-17 15:57:01 +05:30
|
|
|
import Defaults
|
2022-02-17 01:53:11 +05:30
|
|
|
import Foundation
|
2022-06-08 02:57:48 +05:30
|
|
|
import SDWebImageSwiftUI
|
2022-02-17 01:53:11 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct PlayerControls: View {
|
2022-02-22 02:27:12 +05:30
|
|
|
static let animation = Animation.easeInOut(duration: 0.2)
|
2022-02-17 01:53:11 +05:30
|
|
|
|
|
|
|
private var player: PlayerModel!
|
2022-06-08 02:57:48 +05:30
|
|
|
private var thumbnails: ThumbnailsModel!
|
2022-02-17 03:21:37 +05:30
|
|
|
|
2022-02-17 01:53:11 +05:30
|
|
|
@EnvironmentObject<PlayerControlsModel> private var model
|
|
|
|
|
2022-02-28 02:01:17 +05:30
|
|
|
#if os(iOS)
|
|
|
|
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
2022-03-28 00:52:13 +05:30
|
|
|
#elseif os(tvOS)
|
|
|
|
enum Field: Hashable {
|
|
|
|
case play
|
|
|
|
case backward
|
|
|
|
case forward
|
|
|
|
}
|
|
|
|
|
|
|
|
@FocusState private var focusedField: Field?
|
2022-02-28 02:01:17 +05:30
|
|
|
#endif
|
2022-02-17 01:53:11 +05:30
|
|
|
|
2022-08-07 16:45:27 +05:30
|
|
|
#if !os(macOS)
|
|
|
|
@Default(.closePlayerOnItemClose) private var closePlayerOnItemClose
|
|
|
|
#endif
|
|
|
|
|
2022-06-08 02:57:48 +05:30
|
|
|
init(player: PlayerModel, thumbnails: ThumbnailsModel) {
|
2022-02-17 01:53:11 +05:30
|
|
|
self.player = player
|
2022-06-08 02:57:48 +05:30
|
|
|
self.thumbnails = thumbnails
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
2022-07-10 23:21:46 +05:30
|
|
|
ZStack(alignment: .topLeading) {
|
2022-06-18 18:09:49 +05:30
|
|
|
VStack {
|
|
|
|
ZStack(alignment: .center) {
|
|
|
|
OpeningStream()
|
|
|
|
NetworkState()
|
2022-02-17 01:53:11 +05:30
|
|
|
|
2022-08-08 23:01:13 +05:30
|
|
|
if model.presentingControls && !model.presentingOverlays {
|
2022-06-18 18:09:49 +05:30
|
|
|
VStack(spacing: 4) {
|
|
|
|
buttonsBar
|
|
|
|
|
2022-07-10 23:21:46 +05:30
|
|
|
HStack {
|
2022-08-09 22:58:16 +05:30
|
|
|
if !player.currentVideo.isNil, fullScreenLayout {
|
2022-07-10 23:21:46 +05:30
|
|
|
Button {
|
|
|
|
withAnimation(Self.animation) {
|
|
|
|
model.presentingDetailsOverlay = true
|
|
|
|
}
|
|
|
|
} label: {
|
|
|
|
ControlsBar(fullScreen: $model.presentingDetailsOverlay, presentingControls: false, detailsTogglePlayer: false, detailsToggleFullScreen: false)
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
|
|
|
.frame(maxWidth: 300, alignment: .leading)
|
|
|
|
}
|
|
|
|
.buttonStyle(.plain)
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
2022-07-10 23:21:46 +05:30
|
|
|
Spacer()
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
2022-05-28 04:29:35 +05:30
|
|
|
|
2022-05-28 04:53:50 +05:30
|
|
|
Spacer()
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
Group {
|
|
|
|
ZStack(alignment: .bottom) {
|
|
|
|
floatingControls
|
|
|
|
.padding(.top, 20)
|
|
|
|
.padding(4)
|
|
|
|
.modifier(ControlBackgroundModifier())
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
|
|
|
|
|
|
|
timeline
|
|
|
|
.padding(4)
|
|
|
|
.offset(y: -25)
|
|
|
|
.zIndex(1)
|
|
|
|
}
|
|
|
|
.frame(maxWidth: 500)
|
|
|
|
.padding(.bottom, 2)
|
|
|
|
}
|
2022-05-28 04:53:50 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
.padding(.top, 2)
|
|
|
|
.padding(.horizontal, 2)
|
2022-08-08 23:01:13 +05:30
|
|
|
.transition(.opacity)
|
2022-05-28 04:29:35 +05:30
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-08-08 23:01:13 +05:30
|
|
|
.frame(maxHeight: .infinity)
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
#if os(tvOS)
|
|
|
|
.onChange(of: model.presentingControls) { _ in
|
|
|
|
if model.presentingControls {
|
|
|
|
focusedField = .play
|
|
|
|
}
|
2022-03-28 00:52:13 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
.onChange(of: focusedField) { _ in
|
|
|
|
model.resetTimer()
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
.background(PlayerGestures())
|
|
|
|
.background(controlsBackground)
|
|
|
|
#endif
|
|
|
|
|
2022-08-08 23:01:13 +05:30
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
ControlsOverlay()
|
|
|
|
.frame(height: overlayHeight)
|
|
|
|
.padding()
|
|
|
|
.modifier(ControlBackgroundModifier())
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
|
|
|
.transition(.opacity)
|
|
|
|
}
|
|
|
|
|
|
|
|
if model.presentingDetailsOverlay {
|
|
|
|
VideoDetailsOverlay()
|
|
|
|
.frame(maxWidth: detailsWidth, maxHeight: detailsHeight)
|
|
|
|
.modifier(ControlBackgroundModifier())
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
|
|
|
.transition(.opacity)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !model.presentingControls,
|
|
|
|
!model.presentingControls,
|
|
|
|
let segment = player.lastSkipped
|
|
|
|
{
|
|
|
|
Button {
|
|
|
|
player.restoreLastSkippedSegment()
|
|
|
|
} label: {
|
|
|
|
HStack(spacing: 10) {
|
2022-06-18 18:09:49 +05:30
|
|
|
Image(systemName: "arrow.counterclockwise")
|
|
|
|
|
|
|
|
Text("Skipped \(segment.durationText) seconds of \(SponsorBlockAPI.categoryDescription(segment.category)?.lowercased() ?? "segment")")
|
|
|
|
.frame(alignment: .bottomLeading)
|
|
|
|
}
|
2022-08-08 23:01:13 +05:30
|
|
|
.padding(.vertical, 4)
|
|
|
|
.padding(.horizontal, 5)
|
|
|
|
.font(.system(size: 10))
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.modifier(ControlBackgroundModifier())
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 2))
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
2022-08-08 23:01:13 +05:30
|
|
|
.buttonStyle(.plain)
|
|
|
|
.transition(.opacity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.onChange(of: player.controls.presentingOverlays) { newValue in
|
|
|
|
if newValue {
|
|
|
|
player.backend.stopControlsUpdates()
|
|
|
|
} else {
|
|
|
|
player.backend.startControlsUpdates()
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
2022-03-28 00:52:13 +05:30
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
2022-07-05 22:50:25 +05:30
|
|
|
var overlayHeight: Double {
|
|
|
|
guard let player = player, player.playerSize.height.isFinite else { return 0 }
|
2022-07-10 23:21:46 +05:30
|
|
|
return [0, [player.playerSize.height - 40, 140].min()!].max()!
|
|
|
|
}
|
|
|
|
|
|
|
|
var detailsWidth: Double {
|
|
|
|
guard let player = player, player.playerSize.width.isFinite else { return 200 }
|
|
|
|
return [player.playerSize.width, 600].min()!
|
2022-07-05 22:50:25 +05:30
|
|
|
}
|
|
|
|
|
2022-07-11 22:13:23 +05:30
|
|
|
var detailsHeight: Double {
|
|
|
|
guard let player = player, player.playerSize.height.isFinite else { return 200 }
|
|
|
|
return [player.playerSize.height, 500].min()!
|
|
|
|
}
|
|
|
|
|
2022-06-08 02:57:48 +05:30
|
|
|
@ViewBuilder var controlsBackground: some View {
|
|
|
|
if player.musicMode,
|
|
|
|
let item = self.player.currentItem,
|
2022-06-18 18:09:49 +05:30
|
|
|
let video = item.video,
|
|
|
|
let url = thumbnails.best(video)
|
2022-06-08 02:57:48 +05:30
|
|
|
{
|
|
|
|
WebImage(url: url)
|
|
|
|
.resizable()
|
|
|
|
.placeholder {
|
|
|
|
Rectangle().fill(Color("PlaceholderColor"))
|
|
|
|
}
|
|
|
|
.retryOnAppear(true)
|
|
|
|
.indicator(.activity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-17 01:53:11 +05:30
|
|
|
var timeline: some View {
|
2022-06-18 18:09:49 +05:30
|
|
|
TimelineView(context: .player).foregroundColor(.primary)
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
private var hidePlayerButton: some View {
|
2022-05-28 04:29:35 +05:30
|
|
|
button("Hide", systemImage: "chevron.down") {
|
2022-02-17 01:53:11 +05:30
|
|
|
player.hide()
|
|
|
|
}
|
2022-05-28 04:29:35 +05:30
|
|
|
|
2022-03-28 00:52:13 +05:30
|
|
|
#if !os(tvOS)
|
2022-02-17 04:31:48 +05:30
|
|
|
.keyboardShortcut(.cancelAction)
|
2022-03-28 00:52:13 +05:30
|
|
|
#endif
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
private var playbackStatus: String {
|
|
|
|
if player.live {
|
|
|
|
return "LIVE"
|
|
|
|
}
|
|
|
|
|
|
|
|
guard !player.isLoadingVideo else {
|
|
|
|
return "loading..."
|
|
|
|
}
|
|
|
|
|
|
|
|
let videoLengthAtRate = (player.currentVideo?.length ?? 0) / Double(player.currentRate)
|
|
|
|
let remainingSeconds = videoLengthAtRate - (player.time?.seconds ?? 0)
|
|
|
|
|
|
|
|
if remainingSeconds < 60 {
|
|
|
|
return "less than a minute"
|
|
|
|
}
|
|
|
|
|
|
|
|
let timeFinishAt = Date().addingTimeInterval(remainingSeconds)
|
|
|
|
|
|
|
|
return "ends at \(formattedTimeFinishAt(timeFinishAt))"
|
|
|
|
}
|
|
|
|
|
|
|
|
private func formattedTimeFinishAt(_ date: Date) -> String {
|
|
|
|
let dateFormatter = DateFormatter()
|
|
|
|
|
|
|
|
dateFormatter.dateStyle = .none
|
|
|
|
dateFormatter.timeStyle = .short
|
|
|
|
|
|
|
|
return dateFormatter.string(from: date)
|
|
|
|
}
|
|
|
|
|
|
|
|
var buttonsBar: some View {
|
2022-06-18 18:09:49 +05:30
|
|
|
HStack(spacing: 20) {
|
2022-03-28 00:52:13 +05:30
|
|
|
#if !os(tvOS)
|
|
|
|
fullscreenButton
|
2022-04-17 02:20:37 +05:30
|
|
|
|
2022-06-25 05:09:29 +05:30
|
|
|
#if os(iOS)
|
|
|
|
pipButton
|
2022-07-11 04:56:35 +05:30
|
|
|
lockOrientationButton
|
2022-06-25 05:09:29 +05:30
|
|
|
#endif
|
2022-05-28 04:29:35 +05:30
|
|
|
|
2022-06-25 05:09:29 +05:30
|
|
|
Spacer()
|
2022-06-08 02:57:48 +05:30
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
button("settings", systemImage: "gearshape", active: model.presentingControlsOverlay) {
|
|
|
|
withAnimation(Self.animation) {
|
|
|
|
model.presentingControlsOverlay.toggle()
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 03:35:16 +05:30
|
|
|
|
|
|
|
closeVideoButton
|
2022-03-28 00:52:13 +05:30
|
|
|
#endif
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var fullscreenButton: some View {
|
|
|
|
button(
|
|
|
|
"Fullscreen",
|
|
|
|
systemImage: fullScreenLayout ? "arrow.down.right.and.arrow.up.left" : "arrow.up.left.and.arrow.down.right"
|
|
|
|
) {
|
2022-04-03 17:53:42 +05:30
|
|
|
player.toggleFullscreen(fullScreenLayout)
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-03-28 00:52:13 +05:30
|
|
|
#if !os(tvOS)
|
2022-02-17 01:53:11 +05:30
|
|
|
.keyboardShortcut(fullScreenLayout ? .cancelAction : .defaultAction)
|
2022-03-28 00:52:13 +05:30
|
|
|
#endif
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
2022-05-28 04:29:35 +05:30
|
|
|
private var closeVideoButton: some View {
|
|
|
|
button("Close", systemImage: "xmark") {
|
2022-08-07 16:45:27 +05:30
|
|
|
player.closeCurrentItem()
|
2022-05-28 04:29:35 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 03:35:16 +05:30
|
|
|
private var musicModeButton: some View {
|
2022-06-18 18:09:49 +05:30
|
|
|
button("Music Mode", systemImage: "music.note", background: false, active: player.musicMode, action: player.toggleMusicMode)
|
2022-06-08 03:35:16 +05:30
|
|
|
.disabled(player.activeBackend == .appleAVPlayer)
|
|
|
|
}
|
|
|
|
|
2022-05-21 02:53:14 +05:30
|
|
|
private var pipButton: some View {
|
|
|
|
button("PiP", systemImage: "pip") {
|
2022-05-29 20:08:37 +05:30
|
|
|
model.startPiP()
|
2022-05-21 02:53:14 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-11 04:56:35 +05:30
|
|
|
#if os(iOS)
|
|
|
|
private var lockOrientationButton: some View {
|
|
|
|
button("Lock Rotation", systemImage: player.lockedOrientation.isNil ? "lock.rotation.open" : "lock.rotation", active: !player.lockedOrientation.isNil) {
|
|
|
|
if player.lockedOrientation.isNil {
|
|
|
|
let orientationMask = OrientationTracker.shared.currentInterfaceOrientationMask
|
|
|
|
player.lockedOrientation = orientationMask
|
|
|
|
Orientation.lockOrientation(orientationMask)
|
|
|
|
} else {
|
|
|
|
player.lockedOrientation = nil
|
|
|
|
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: OrientationTracker.shared.currentInterfaceOrientation)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
var floatingControls: some View {
|
2022-02-17 01:53:11 +05:30
|
|
|
HStack {
|
2022-06-18 18:09:49 +05:30
|
|
|
HStack(spacing: 20) {
|
|
|
|
togglePlayButton
|
|
|
|
seekBackwardButton
|
|
|
|
seekForwardButton
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
2022-02-17 01:53:11 +05:30
|
|
|
|
|
|
|
Spacer()
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
HStack(spacing: 20) {
|
2022-07-11 03:54:56 +05:30
|
|
|
playbackModeButton
|
2022-06-18 18:09:49 +05:30
|
|
|
restartVideoButton
|
2022-05-29 21:20:54 +05:30
|
|
|
advanceToNextItemButton
|
2022-06-26 18:25:23 +05:30
|
|
|
#if !os(tvOS)
|
|
|
|
musicModeButton
|
|
|
|
#endif
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
|
|
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-05-28 04:29:35 +05:30
|
|
|
.font(.system(size: 20))
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-05-29 21:20:54 +05:30
|
|
|
|
2022-07-11 03:54:56 +05:30
|
|
|
var playbackModeButton: some View {
|
|
|
|
button("Playback Mode", systemImage: player.playbackMode.systemImage, background: false) {
|
|
|
|
player.playbackMode = player.playbackMode.next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
var seekBackwardButton: some View {
|
|
|
|
button("Seek Backward", systemImage: "gobackward.10", size: 25, cornerRadius: 5, background: false) {
|
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(-10))
|
|
|
|
}
|
2022-07-22 04:14:21 +05:30
|
|
|
.disabled(player.liveStreamInAVPlayer)
|
2022-06-18 18:09:49 +05:30
|
|
|
#if os(tvOS)
|
2022-07-22 04:14:21 +05:30
|
|
|
.focused($focusedField, equals: .backward)
|
2022-06-18 18:09:49 +05:30
|
|
|
#else
|
2022-07-22 04:14:21 +05:30
|
|
|
.keyboardShortcut("k", modifiers: [])
|
|
|
|
.keyboardShortcut(KeyEquivalent.leftArrow, modifiers: [])
|
2022-06-18 18:09:49 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
var seekForwardButton: some View {
|
|
|
|
button("Seek Forward", systemImage: "goforward.10", size: 25, cornerRadius: 5, background: false) {
|
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(10))
|
|
|
|
}
|
2022-07-22 04:14:21 +05:30
|
|
|
.disabled(player.liveStreamInAVPlayer)
|
2022-06-18 18:09:49 +05:30
|
|
|
#if os(tvOS)
|
2022-07-22 04:14:21 +05:30
|
|
|
.focused($focusedField, equals: .forward)
|
2022-06-18 18:09:49 +05:30
|
|
|
#else
|
2022-07-22 04:14:21 +05:30
|
|
|
.keyboardShortcut("l", modifiers: [])
|
|
|
|
.keyboardShortcut(KeyEquivalent.rightArrow, modifiers: [])
|
2022-06-18 18:09:49 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-05-29 21:20:54 +05:30
|
|
|
private var restartVideoButton: some View {
|
2022-06-18 18:09:49 +05:30
|
|
|
button("Restart video", systemImage: "backward.end.fill", size: 25, cornerRadius: 5, background: false) {
|
2022-05-29 21:20:54 +05:30
|
|
|
player.backend.seek(to: 0.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
private var togglePlayButton: some View {
|
|
|
|
button(
|
|
|
|
model.isPlaying ? "Pause" : "Play",
|
|
|
|
systemImage: model.isPlaying ? "pause.fill" : "play.fill",
|
|
|
|
size: 25, cornerRadius: 5, background: false
|
|
|
|
) {
|
|
|
|
player.backend.togglePlay()
|
2022-05-29 21:20:54 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
#if os(tvOS)
|
|
|
|
.focused($focusedField, equals: .play)
|
|
|
|
#else
|
|
|
|
.keyboardShortcut("p")
|
|
|
|
.keyboardShortcut(.space)
|
|
|
|
#endif
|
|
|
|
.disabled(model.isLoadingVideo)
|
2022-05-29 21:20:54 +05:30
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
private var advanceToNextItemButton: some View {
|
|
|
|
button("Next", systemImage: "forward.fill", size: 25, cornerRadius: 5, background: false) {
|
|
|
|
player.advanceToNextItem()
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-07-11 03:54:56 +05:30
|
|
|
.disabled(!player.isAdvanceToNextItemAvailable)
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func button(
|
|
|
|
_ label: String,
|
2022-06-15 04:11:49 +05:30
|
|
|
systemImage: String? = nil,
|
2022-06-18 18:09:49 +05:30
|
|
|
size: Double = 25,
|
2022-06-15 04:11:49 +05:30
|
|
|
width: Double? = nil,
|
|
|
|
height: Double? = nil,
|
2022-02-17 01:53:11 +05:30
|
|
|
cornerRadius: Double = 3,
|
2022-06-18 18:09:49 +05:30
|
|
|
background: Bool = true,
|
2022-06-08 02:57:48 +05:30
|
|
|
active: Bool = false,
|
2022-02-17 01:53:11 +05:30
|
|
|
action: @escaping () -> Void = {}
|
|
|
|
) -> some View {
|
|
|
|
Button {
|
|
|
|
action()
|
|
|
|
model.resetTimer()
|
|
|
|
} label: {
|
2022-06-15 04:11:49 +05:30
|
|
|
Group {
|
|
|
|
if let image = systemImage {
|
|
|
|
Label(label, systemImage: image)
|
|
|
|
.labelStyle(.iconOnly)
|
|
|
|
} else {
|
|
|
|
Label(label, systemImage: "")
|
|
|
|
.labelStyle(.titleOnly)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
.contentShape(Rectangle())
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
2022-06-18 18:09:49 +05:30
|
|
|
.font(.system(size: 13))
|
2022-02-28 02:01:17 +05:30
|
|
|
.buttonStyle(.plain)
|
2022-06-18 18:09:49 +05:30
|
|
|
.foregroundColor(active ? Color("AppRedColor") : .primary)
|
2022-06-15 04:11:49 +05:30
|
|
|
.frame(width: width ?? size, height: height ?? size)
|
2022-06-18 18:09:49 +05:30
|
|
|
.modifier(ControlBackgroundModifier(enabled: background))
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: cornerRadius))
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
var fullScreenLayout: Bool {
|
2022-03-28 00:52:13 +05:30
|
|
|
#if os(iOS)
|
2022-06-18 18:09:49 +05:30
|
|
|
player.playingFullScreen || verticalSizeClass == .compact
|
2022-02-28 02:01:17 +05:30
|
|
|
#else
|
2022-06-18 18:09:49 +05:30
|
|
|
player.playingFullScreen
|
2022-02-28 02:01:17 +05:30
|
|
|
#endif
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PlayerControls_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2022-06-18 18:09:49 +05:30
|
|
|
ZStack {
|
2022-05-28 04:53:50 +05:30
|
|
|
Color.gray
|
2022-05-28 04:29:35 +05:30
|
|
|
|
2022-06-08 02:57:48 +05:30
|
|
|
PlayerControls(player: PlayerModel(), thumbnails: ThumbnailsModel())
|
2022-05-28 04:29:35 +05:30
|
|
|
.injectFixtureEnvironmentObjects()
|
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
}
|