fix: local playback

This commit is contained in:
Fredrik Burmester
2024-10-13 16:07:03 +02:00
parent 43d64bc3d0
commit eefd1d9d13
4 changed files with 149 additions and 97 deletions

View File

@@ -110,9 +110,20 @@ class VlcPlayerView: ExpoView {
let media: VLCMedia
if isNetwork {
print("Loading network file: \(uri)")
media = VLCMedia(url: URL(string: uri)!)
} else {
media = VLCMedia(path: uri)
print("Loading local file: \(uri)")
if uri.starts(with: "file://") {
if let url = URL(string: uri) {
media = VLCMedia(url: url)
} else {
print("Error: Invalid local file URL")
return
}
} else {
media = VLCMedia(path: uri)
}
}
media.delegate = self
@@ -454,9 +465,6 @@ extension VlcPlayerView: VLCMediaPlayerDelegate {
stateInfo["state"] = "Buffering"
}
print("VLC Player State Changed: \(currentState.description)")
print("VLC Player State Changed: \(player.isPlaying)")
// switch currentState {
// case .opening:
// stateInfo["state"] = "Opening"
@@ -477,6 +485,8 @@ extension VlcPlayerView: VLCMediaPlayerDelegate {
// stateInfo["state"] = "Unknown"
// }
print("State changed: \(stateInfo)")
self.lastReportedState = currentState
self.onVideoStateChange?(stateInfo)
}