mirror of
https://github.com/yattee/yattee.git
synced 2025-01-05 04:17:02 +00:00
Close current video (fixes #15)
This commit is contained in:
parent
dd995105b5
commit
19b146c6ad
@ -233,7 +233,7 @@ final class PlayerModel: ObservableObject {
|
|||||||
loadCompositionAsset(stream.videoAsset, stream: stream, type: .video, of: video, preservingTime: preservingTime)
|
loadCompositionAsset(stream.videoAsset, stream: stream, type: .video, of: video, preservingTime: preservingTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadCompositionAsset(
|
private func loadCompositionAsset(
|
||||||
_ asset: AVURLAsset,
|
_ asset: AVURLAsset,
|
||||||
stream: Stream,
|
stream: Stream,
|
||||||
type: AVMediaType,
|
type: AVMediaType,
|
||||||
@ -517,4 +517,10 @@ final class PlayerModel: ObservableObject {
|
|||||||
|
|
||||||
return "\(formatter.string(from: NSNumber(value: rate))!)×"
|
return "\(formatter.string(from: NSNumber(value: rate))!)×"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func closeCurrentItem() {
|
||||||
|
addCurrentItemToHistory()
|
||||||
|
currentItem = nil
|
||||||
|
player.replaceCurrentItem(with: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,17 @@ struct VideoDetails: View {
|
|||||||
.onAppear {
|
.onAppear {
|
||||||
currentPage = .details
|
currentPage = .details
|
||||||
}
|
}
|
||||||
|
.contextMenu {
|
||||||
|
Button {
|
||||||
|
player.closeCurrentItem()
|
||||||
|
if !sidebarQueue {
|
||||||
|
currentPage = .queue
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("Close Video", systemImage: "xmark.circle")
|
||||||
|
}
|
||||||
|
.disabled(player.currentItem.isNil)
|
||||||
|
}
|
||||||
|
|
||||||
.font(.title2.bold())
|
.font(.title2.bold())
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,6 +33,13 @@ struct NowPlayingView: View {
|
|||||||
} label: {
|
} label: {
|
||||||
VideoBanner(video: item.video)
|
VideoBanner(video: item.video)
|
||||||
}
|
}
|
||||||
|
.contextMenu {
|
||||||
|
Button("Close Video") {
|
||||||
|
player.closeCurrentItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
Button("Cancel", role: .cancel) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onPlayPauseCommand(perform: player.togglePlay)
|
.onPlayPauseCommand(perform: player.togglePlay)
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ import SwiftUI
|
|||||||
|
|
||||||
struct TVNavigationView: View {
|
struct TVNavigationView: View {
|
||||||
@EnvironmentObject<AccountsModel> private var accounts
|
@EnvironmentObject<AccountsModel> private var accounts
|
||||||
@EnvironmentObject<PlayerModel> private var player
|
|
||||||
@EnvironmentObject<NavigationModel> private var navigation
|
@EnvironmentObject<NavigationModel> private var navigation
|
||||||
|
@EnvironmentObject<PlayerModel> private var player
|
||||||
@EnvironmentObject<RecentsModel> private var recents
|
@EnvironmentObject<RecentsModel> private var recents
|
||||||
@EnvironmentObject<SearchModel> private var search
|
@EnvironmentObject<SearchModel> private var search
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user