Code style change

This commit is contained in:
Arkadiusz Fal 2022-08-13 16:46:45 +02:00
parent 661de78ab3
commit c51b9dd8e8
8 changed files with 35 additions and 40 deletions

View File

@ -455,7 +455,8 @@ final class AVPlayerBackend: PlayerBackend {
switch playerItem.status { switch playerItem.status {
case .readyToPlay: case .readyToPlay:
if self.model.activeBackend == .appleAVPlayer, if self.model.activeBackend == .appleAVPlayer,
self.isAutoplaying(playerItem) { self.isAutoplaying(playerItem)
{
self.model.updateAspectRatio() self.model.updateAspectRatio()
self.model.play() self.model.play()
} }

View File

@ -9,9 +9,7 @@ extension PlayerModel {
} }
func play(_ videos: [Video]) { func play(_ videos: [Video]) {
videos.forEach { video in videos.forEach { enqueueVideo($0, loadDetails: false) }
enqueueVideo(video, loadDetails: false)
}
#if os(iOS) #if os(iOS)
onPresentPlayer = { [weak self] in self?.advanceToNextItem() } onPresentPlayer = { [weak self] in self?.advanceToNextItem() }

View File

@ -67,8 +67,8 @@ struct OpenURLHandler {
default: default:
navigation.presentAlert(title: "Error", message: "This URL could not be opened") navigation.presentAlert(title: "Error", message: "This URL could not be opened")
#if os(macOS) #if os(macOS)
guard !Windows.main.isOpen else { return } guard !Windows.main.isOpen else { return }
navigation.presentingAlertInVideoPlayer = true navigation.presentingAlertInVideoPlayer = true
#endif #endif
} }
} }

View File

@ -30,9 +30,7 @@ struct PlayerBackendView: View {
} }
.overlay(GeometryReader { proxy in .overlay(GeometryReader { proxy in
Color.clear Color.clear
.onAppear { .onAppear { player.playerSize = proxy.size }
player.playerSize = proxy.size
}
.onChange(of: proxy.size) { _ in player.playerSize = proxy.size } .onChange(of: proxy.size) { _ in player.playerSize = proxy.size }
.onChange(of: player.controls.presentingOverlays) { _ in player.playerSize = proxy.size } .onChange(of: player.controls.presentingOverlays) { _ in player.playerSize = proxy.size }
.onChange(of: player.aspectRatio) { _ in player.playerSize = proxy.size } .onChange(of: player.aspectRatio) { _ in player.playerSize = proxy.size }

View File

@ -210,33 +210,33 @@ struct VideoPlayerView: View {
) )
.overlay(playerPlaceholder) .overlay(playerPlaceholder)
#endif #endif
.frame(maxWidth: fullScreenLayout ? .infinity : nil, maxHeight: fullScreenLayout ? .infinity : nil) .frame(maxWidth: fullScreenLayout ? .infinity : nil, maxHeight: fullScreenLayout ? .infinity : nil)
.onHover { hovering in .onHover { hovering in
hoveringPlayer = hovering hoveringPlayer = hovering
hovering ? playerControls.show() : playerControls.hide() hovering ? playerControls.show() : playerControls.hide()
} }
#if os(iOS) #if os(iOS)
.gesture(playerControls.presentingOverlays ? nil : playerDragGesture) .gesture(playerControls.presentingOverlays ? nil : playerDragGesture)
.onChange(of: dragGestureState) { _ in .onChange(of: dragGestureState) { _ in
if !dragGestureState { if !dragGestureState {
onPlayerDragGestureEnded() onPlayerDragGestureEnded()
}
}
#elseif os(macOS)
.onAppear(perform: {
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
hoverThrottle.execute {
if !player.currentItem.isNil, hoveringPlayer {
playerControls.resetTimer()
}
} }
return $0
} }
}) #elseif os(macOS)
.onAppear(perform: {
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
hoverThrottle.execute {
if !player.currentItem.isNil, hoveringPlayer {
playerControls.resetTimer()
}
}
return $0
}
})
#endif #endif
.background(Color.black) .background(Color.black)
#if !os(tvOS) #if !os(tvOS)
if !fullScreenLayout { if !fullScreenLayout {

View File

@ -37,10 +37,8 @@ struct VideoCell: View {
} }
var body: some View { var body: some View {
Group { Button(action: playAction) {
Button(action: playAction) { content
content
}
} }
.opacity(contentOpacity) .opacity(contentOpacity)
.buttonStyle(.plain) .buttonStyle(.plain)

View File

@ -7,12 +7,12 @@ struct ContentItemView: View {
var body: some View { var body: some View {
Group { Group {
switch item.contentType { switch item.contentType {
case .video:
VideoCell(video: item.video)
case .playlist: case .playlist:
ChannelPlaylistCell(playlist: item.playlist) ChannelPlaylistCell(playlist: item.playlist)
case .channel: case .channel:
ChannelCell(channel: item.channel) ChannelCell(channel: item.channel)
case .video:
VideoCell(video: item.video)
default: default:
PlaceholderCell() PlaceholderCell()
} }

View File

@ -10,8 +10,8 @@ struct SafeArea {
static var scene: UIWindowScene? { static var scene: UIWindowScene? {
UIApplication.shared.connectedScenes UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive } .filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene } .compactMap { $0 as? UIWindowScene }
.first .first
} }
} }