mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +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 Env
|
||||||
import Observation
|
import Observation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Models
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@Observable public class MediaUIAttachmentVideoViewModel {
|
@Observable public class MediaUIAttachmentVideoViewModel {
|
||||||
|
@ -74,6 +75,7 @@ import SwiftUI
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
public struct MediaUIAttachmentVideoView: View {
|
public struct MediaUIAttachmentVideoView: View {
|
||||||
|
@Environment(\.openWindow) private var openWindow
|
||||||
@Environment(\.scenePhase) private var scenePhase
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
@Environment(\.isMediaCompact) private var isCompact
|
@Environment(\.isMediaCompact) private var isCompact
|
||||||
@Environment(UserPreferences.self) private var preferences
|
@Environment(UserPreferences.self) private var preferences
|
||||||
|
@ -101,7 +103,13 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
viewModel.play()
|
viewModel.play()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
#if targetEnvironment(macCatalyst)
|
||||||
|
viewModel.pause()
|
||||||
|
let attachement = MediaAttachment.videoWith(url: viewModel.url)
|
||||||
|
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement], selectedAttachment: attachement))
|
||||||
|
#else
|
||||||
isFullScreen = true
|
isFullScreen = true
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
.fullScreenCover(isPresented: $isFullScreen) {
|
.fullScreenCover(isPresented: $isFullScreen) {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
|
|
|
@ -53,6 +53,15 @@ public struct MediaAttachment: Codable, Identifiable, Hashable, Equatable {
|
||||||
description: "demo alt text here",
|
description: "demo alt text here",
|
||||||
meta: nil)
|
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 {}
|
extension MediaAttachment: Sendable {}
|
||||||
|
|
Loading…
Reference in a new issue