mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
wip
This commit is contained in:
@@ -152,9 +152,16 @@ export default function page() {
|
||||
if (isSeeking.value === true) return;
|
||||
if (isPlaybackStopped === true) return;
|
||||
|
||||
const { currentTime, duration } = data.nativeEvent;
|
||||
const { currentTime, duration, isBuffering, isPlaying } =
|
||||
data.nativeEvent;
|
||||
|
||||
console.log("onProgress ~", {
|
||||
currentTime,
|
||||
duration,
|
||||
isBuffering,
|
||||
isPlaying,
|
||||
});
|
||||
|
||||
console.log("onProgress ~", currentTime);
|
||||
progress.value = currentTime;
|
||||
|
||||
// cacheProgress.value = secondsToTicks(data.playableDuration);
|
||||
@@ -297,7 +304,7 @@ export default function page() {
|
||||
/>
|
||||
</Pressable>
|
||||
|
||||
<VideoDebugInfo
|
||||
{/* <VideoDebugInfo
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
@@ -310,7 +317,7 @@ export default function page() {
|
||||
duration: 0,
|
||||
}}
|
||||
playerRef={videoRef}
|
||||
/>
|
||||
/> */}
|
||||
|
||||
<Controls
|
||||
item={playSettings.item}
|
||||
|
||||
@@ -431,36 +431,51 @@ extension VlcPlayerView: VLCMediaPlayerDelegate {
|
||||
"isBuffering": currentState == .buffering,
|
||||
]
|
||||
|
||||
switch currentState {
|
||||
case .opening:
|
||||
stateInfo["state"] = "Opening"
|
||||
case .buffering:
|
||||
stateInfo["state"] = "Buffering"
|
||||
stateInfo["isBuffering"] = true
|
||||
case .playing:
|
||||
if player.state == .playing {
|
||||
stateInfo["isPlaying"] = true
|
||||
stateInfo["isBuffering"] = false
|
||||
stateInfo["state"] = "Playing"
|
||||
case .paused:
|
||||
stateInfo["state"] = "Paused"
|
||||
case .stopped:
|
||||
stateInfo["state"] = "Stopped"
|
||||
case .ended:
|
||||
stateInfo["state"] = "Ended"
|
||||
case .error:
|
||||
stateInfo["state"] = "Error"
|
||||
default:
|
||||
stateInfo["state"] = "Unknown"
|
||||
}
|
||||
|
||||
if currentState != self.lastReportedState {
|
||||
self.lastReportedState = currentState
|
||||
self.onVideoStateChange?(stateInfo)
|
||||
if player.state == .buffering {
|
||||
stateInfo["isBuffering"] = true
|
||||
stateInfo["state"] = "Buffering"
|
||||
}
|
||||
|
||||
if player.state == .paused {
|
||||
stateInfo["isPlaying"] = false
|
||||
stateInfo["state"] = "Paused"
|
||||
}
|
||||
|
||||
// switch currentState {
|
||||
// case .opening:
|
||||
// stateInfo["state"] = "Opening"
|
||||
// case .buffering:
|
||||
// stateInfo["state"] = "Buffering"
|
||||
// stateInfo["isBuffering"] = true
|
||||
// case .playing:
|
||||
// stateInfo["state"] = "Playing"
|
||||
// case .paused:
|
||||
// stateInfo["state"] = "Paused"
|
||||
// case .stopped:
|
||||
// stateInfo["state"] = "Stopped"
|
||||
// case .ended:
|
||||
// stateInfo["state"] = "Ended"
|
||||
// case .error:
|
||||
// stateInfo["state"] = "Error"
|
||||
// default:
|
||||
// stateInfo["state"] = "Unknown"
|
||||
// }
|
||||
|
||||
self.lastReportedState = currentState
|
||||
self.onVideoStateChange?(stateInfo)
|
||||
}
|
||||
}
|
||||
|
||||
func mediaPlayerTimeChanged(_ aNotification: Notification) {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.updateVideoProgress()
|
||||
self?.updatePlayerState()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,11 +487,20 @@ extension VlcPlayerView: VLCMediaPlayerDelegate {
|
||||
let durationMs = player.media?.length.intValue ?? 0
|
||||
|
||||
if currentTimeMs >= 0 && currentTimeMs < durationMs {
|
||||
let isPlaying = player.isPlaying
|
||||
let isBuffering = player.state == .buffering
|
||||
|
||||
self.onVideoProgress?([
|
||||
"target": self.reactTag ?? NSNull(),
|
||||
"currentTime": currentTimeMs,
|
||||
"duration": durationMs,
|
||||
"isPlaying": isPlaying,
|
||||
"isBuffering": isBuffering,
|
||||
])
|
||||
|
||||
// Debug log
|
||||
print(
|
||||
"VLC Player State: \(player.state.description), isPlaying: \(isPlaying), isBuffering: \(isBuffering)"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ export type ProgressUpdatePayload = {
|
||||
nativeEvent: {
|
||||
currentTime: number;
|
||||
duration: number;
|
||||
isPlaying: boolean;
|
||||
isBuffering: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user