mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-13 04:51:21 +00:00
Play video on a separate window on macOS
This commit is contained in:
parent
eeff60bf98
commit
621f0d0864
2 changed files with 17 additions and 0 deletions
|
@ -3,6 +3,7 @@ import DesignSystem
|
|||
import Env
|
||||
import Observation
|
||||
import SwiftUI
|
||||
import Models
|
||||
|
||||
@MainActor
|
||||
@Observable public class MediaUIAttachmentVideoViewModel {
|
||||
|
@ -74,6 +75,7 @@ import SwiftUI
|
|||
|
||||
@MainActor
|
||||
public struct MediaUIAttachmentVideoView: View {
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Environment(\.isMediaCompact) private var isCompact
|
||||
@Environment(UserPreferences.self) private var preferences
|
||||
|
@ -101,7 +103,13 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
viewModel.play()
|
||||
return
|
||||
}
|
||||
#if targetEnvironment(macCatalyst)
|
||||
viewModel.pause()
|
||||
let attachement = MediaAttachment.videoWith(url: viewModel.url)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement], selectedAttachment: attachement))
|
||||
#else
|
||||
isFullScreen = true
|
||||
#endif
|
||||
}
|
||||
.fullScreenCover(isPresented: $isFullScreen) {
|
||||
NavigationStack {
|
||||
|
|
|
@ -53,6 +53,15 @@ public struct MediaAttachment: Codable, Identifiable, Hashable, Equatable {
|
|||
description: "demo alt text here",
|
||||
meta: nil)
|
||||
}
|
||||
|
||||
public static func videoWith(url: URL) -> MediaAttachment {
|
||||
.init(id: UUID().uuidString,
|
||||
type: "video",
|
||||
url: url,
|
||||
previewUrl: url,
|
||||
description: nil,
|
||||
meta: nil)
|
||||
}
|
||||
}
|
||||
|
||||
extension MediaAttachment: Sendable {}
|
||||
|
|
Loading…
Reference in a new issue