mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-23 23:36:54 +01:00
Update Seeking behaviour
This commit is contained in:
@@ -106,7 +106,7 @@ class MpvPlayerView: ExpoView {
|
|||||||
|
|
||||||
// Create and add SwiftUI hosting controller
|
// Create and add SwiftUI hosting controller
|
||||||
let hostController = UIHostingController(
|
let hostController = UIHostingController(
|
||||||
rootView: MpvMetalPlayerView(coordinator: coordinator)
|
rootView: MpvMetalPlayerView(coordinator: coordinator, existingController: controller)
|
||||||
)
|
)
|
||||||
self.hostingController = hostController
|
self.hostingController = hostController
|
||||||
|
|
||||||
@@ -163,7 +163,8 @@ class MpvPlayerView: ExpoView {
|
|||||||
|
|
||||||
func seekTo(_ time: Int32) {
|
func seekTo(_ time: Int32) {
|
||||||
let seconds = Double(time) / 1000.0
|
let seconds = Double(time) / 1000.0
|
||||||
playerController?.command("seek", args: ["\(seconds)"])
|
print("Seeking to absolute position: \(seconds) seconds")
|
||||||
|
playerController?.command("seek", args: ["\(seconds)", "absolute"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func setAudioTrack(_ trackIndex: Int) {
|
func setAudioTrack(_ trackIndex: Int) {
|
||||||
@@ -220,6 +221,7 @@ class MpvPlayerView: ExpoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case MpvProperty.pause:
|
case MpvProperty.pause:
|
||||||
|
print("MpvProperty.pause: \(value)")
|
||||||
if let isPaused = value as? Bool {
|
if let isPaused = value as? Bool {
|
||||||
let state = isPaused ? "Paused" : "Playing"
|
let state = isPaused ? "Paused" : "Playing"
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
@@ -290,14 +292,15 @@ class MpvPlayerView: ExpoView {
|
|||||||
// MARK: - SwiftUI Wrapper
|
// MARK: - SwiftUI Wrapper
|
||||||
struct MpvMetalPlayerView: UIViewControllerRepresentable {
|
struct MpvMetalPlayerView: UIViewControllerRepresentable {
|
||||||
@ObservedObject var coordinator: Coordinator
|
@ObservedObject var coordinator: Coordinator
|
||||||
|
let existingController: MpvMetalViewController
|
||||||
|
|
||||||
|
init(coordinator: Coordinator, existingController: MpvMetalViewController) {
|
||||||
|
self.coordinator = coordinator
|
||||||
|
self.existingController = existingController
|
||||||
|
}
|
||||||
|
|
||||||
func makeUIViewController(context: Context) -> UIViewController {
|
func makeUIViewController(context: Context) -> UIViewController {
|
||||||
let controller = MpvMetalViewController()
|
return existingController
|
||||||
controller.delegate = coordinator
|
|
||||||
controller.playUrl = coordinator.playUrl
|
|
||||||
|
|
||||||
coordinator.player = controller
|
|
||||||
return controller
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
|
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
|
||||||
@@ -454,7 +457,7 @@ final class MpvMetalViewController: UIViewController {
|
|||||||
|
|
||||||
// Configure mpv options
|
// Configure mpv options
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
mpv_request_log_messages(mpvHandle, "debug")
|
// mpv_request_log_messages(mpvHandle, "debug")
|
||||||
#else
|
#else
|
||||||
mpv_request_log_messages(mpvHandle, "no")
|
mpv_request_log_messages(mpvHandle, "no")
|
||||||
#endif
|
#endif
|
||||||
@@ -530,6 +533,7 @@ final class MpvMetalViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func pause() {
|
func pause() {
|
||||||
|
print("Pausing")
|
||||||
setFlag(MpvProperty.pause, true)
|
setFlag(MpvProperty.pause, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,6 +566,7 @@ final class MpvMetalViewController: UIViewController {
|
|||||||
guard let mpv = mpv else { return }
|
guard let mpv = mpv else { return }
|
||||||
|
|
||||||
var data: Int = value ? 1 : 0
|
var data: Int = value ? 1 : 0
|
||||||
|
print("Setting flag \(name) to \(value)")
|
||||||
mpv_set_property(mpv, name, MPV_FORMAT_FLAG, &data)
|
mpv_set_property(mpv, name, MPV_FORMAT_FLAG, &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,7 +689,8 @@ final class MpvMetalViewController: UIViewController {
|
|||||||
mpv_terminate_destroy(self.mpv)
|
mpv_terminate_destroy(self.mpv)
|
||||||
self.mpv = nil
|
self.mpv = nil
|
||||||
}
|
}
|
||||||
|
case MPV_EVENT_LOG_MESSAGE:
|
||||||
|
return
|
||||||
default:
|
default:
|
||||||
if let eventName = mpv_event_name(event.pointee.event_id) {
|
if let eventName = mpv_event_name(event.pointee.event_id) {
|
||||||
print("MPV event: \(String(cString: eventName))")
|
print("MPV event: \(String(cString: eventName))")
|
||||||
|
|||||||
Reference in New Issue
Block a user