mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Shared seek model
This commit is contained in:
parent
6643208579
commit
02617a7c42
@ -3,6 +3,8 @@ import Foundation
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
final class SeekModel: ObservableObject {
|
final class SeekModel: ObservableObject {
|
||||||
|
static let shared = SeekModel()
|
||||||
|
|
||||||
@Published var currentTime = CMTime.zero
|
@Published var currentTime = CMTime.zero
|
||||||
@Published var duration = CMTime.zero
|
@Published var duration = CMTime.zero
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ struct ContentView: View {
|
|||||||
@EnvironmentObject<CommentsModel> private var comments
|
@EnvironmentObject<CommentsModel> private var comments
|
||||||
@EnvironmentObject<InstancesModel> private var instances
|
@EnvironmentObject<InstancesModel> private var instances
|
||||||
@EnvironmentObject<NavigationModel> private var navigation
|
@EnvironmentObject<NavigationModel> private var navigation
|
||||||
@EnvironmentObject<PlayerModel> private var player
|
|
||||||
@EnvironmentObject<PlayerControlsModel> private var playerControls
|
@EnvironmentObject<PlayerControlsModel> private var playerControls
|
||||||
@EnvironmentObject<PlaylistsModel> private var playlists
|
@EnvironmentObject<PlaylistsModel> private var playlists
|
||||||
@EnvironmentObject<RecentsModel> private var recents
|
@EnvironmentObject<RecentsModel> private var recents
|
||||||
@ -29,6 +28,8 @@ struct ContentView: View {
|
|||||||
|
|
||||||
@State private var playerInitialized = false
|
@State private var playerInitialized = false
|
||||||
|
|
||||||
|
private var player = PlayerModel.shared
|
||||||
|
|
||||||
let persistenceController = PersistenceController.shared
|
let persistenceController = PersistenceController.shared
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -7,7 +7,7 @@ struct Seek: View {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
@EnvironmentObject<PlayerControlsModel> private var controls
|
@EnvironmentObject<PlayerControlsModel> private var controls
|
||||||
@EnvironmentObject<SeekModel> private var model
|
@StateObject private var model = SeekModel.shared
|
||||||
|
|
||||||
private var updateThrottle = Throttle(interval: 2)
|
private var updateThrottle = Throttle(interval: 2)
|
||||||
|
|
||||||
|
@ -461,7 +461,6 @@ struct VideoPlayerView: View {
|
|||||||
struct VideoPlayerView_Previews: PreviewProvider {
|
struct VideoPlayerView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
VideoPlayerView()
|
VideoPlayerView()
|
||||||
.environmentObject(SeekModel())
|
|
||||||
.injectFixtureEnvironmentObjects()
|
.injectFixtureEnvironmentObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ struct YatteeApp: App {
|
|||||||
@StateObject private var playlists = PlaylistsModel()
|
@StateObject private var playlists = PlaylistsModel()
|
||||||
@StateObject private var recents = RecentsModel()
|
@StateObject private var recents = RecentsModel()
|
||||||
@StateObject private var search = SearchModel()
|
@StateObject private var search = SearchModel()
|
||||||
@StateObject private var seek = SeekModel()
|
|
||||||
@StateObject private var settings = SettingsModel()
|
@StateObject private var settings = SettingsModel()
|
||||||
@StateObject private var subscriptions = SubscriptionsModel()
|
@StateObject private var subscriptions = SubscriptionsModel()
|
||||||
@StateObject private var thumbnails = ThumbnailsModel()
|
@StateObject private var thumbnails = ThumbnailsModel()
|
||||||
@ -64,7 +63,6 @@ struct YatteeApp: App {
|
|||||||
.environmentObject(playerControls)
|
.environmentObject(playerControls)
|
||||||
.environmentObject(playlists)
|
.environmentObject(playlists)
|
||||||
.environmentObject(recents)
|
.environmentObject(recents)
|
||||||
.environmentObject(seek)
|
|
||||||
.environmentObject(settings)
|
.environmentObject(settings)
|
||||||
.environmentObject(subscriptions)
|
.environmentObject(subscriptions)
|
||||||
.environmentObject(thumbnails)
|
.environmentObject(thumbnails)
|
||||||
@ -204,7 +202,7 @@ struct YatteeApp: App {
|
|||||||
player.controls = playerControls
|
player.controls = playerControls
|
||||||
player.navigation = navigation
|
player.navigation = navigation
|
||||||
player.networkState = networkState
|
player.networkState = networkState
|
||||||
player.seek = seek
|
player.seek = .shared
|
||||||
|
|
||||||
PlayerTimeModel.shared.player = player
|
PlayerTimeModel.shared.player = player
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user