mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
Fixed skip intro skipping more than the video length
This commit is contained in:
@@ -208,9 +208,12 @@ export const Controls: React.FC<Props> = ({
|
||||
? maxValue - currentProgress
|
||||
: ticksToSeconds(maxValue - currentProgress);
|
||||
|
||||
// console.log("Remaning time is: ", remaining);
|
||||
|
||||
setCurrentTime(current);
|
||||
setRemainingTime(remaining);
|
||||
|
||||
// Currently doesm't work in VLC because of some corrupted timestamps, will need to find a workaround.
|
||||
if (currentProgress === maxValue) {
|
||||
setShowControls(true);
|
||||
// Automatically play the next item if it exists
|
||||
@@ -227,6 +230,7 @@ export const Controls: React.FC<Props> = ({
|
||||
isSeeking: isSeeking.value,
|
||||
}),
|
||||
(result) => {
|
||||
// console.log("Progress changed", result);
|
||||
if (result.isSeeking === false) {
|
||||
runOnJS(updateTimes)(result.progress, result.max);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ export const useCreditSkipper = (
|
||||
|
||||
const skipCredit = useCallback(() => {
|
||||
if (!creditTimestamps) return;
|
||||
console.log(`Skipping credits to ${creditTimestamps.Credits.End}`);
|
||||
try {
|
||||
wrappedSeek(creditTimestamps.Credits.End);
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -78,14 +78,22 @@ class VlcPlayerView: ExpoView {
|
||||
player.pause()
|
||||
}
|
||||
|
||||
player.time = VLCTime(int: time)
|
||||
if let duration = player.media?.length.intValue {
|
||||
print("Seeking to time: \(time) Video Duration \(duration)")
|
||||
|
||||
// Wait for a short moment to ensure the seek has been processed
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
if wasPlaying {
|
||||
player.play()
|
||||
// If the specified time is greater than the duration, seek to the end
|
||||
let seekTime = time > duration ? duration - 1000 : time
|
||||
player.time = VLCTime(int: seekTime)
|
||||
|
||||
// Wait for a short moment to ensure the seek has been processed
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
if wasPlaying {
|
||||
player.play()
|
||||
}
|
||||
self.updatePlayerState()
|
||||
}
|
||||
self.updatePlayerState()
|
||||
} else {
|
||||
print("Error: Unable to retrieve video duration")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +102,7 @@ class VlcPlayerView: ExpoView {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
let mediaOptions = source["mediaOptions"] as? [String: Any]
|
||||
let mediaOptions = source["mediaOptions"] as? [String: Any] ?? [:]
|
||||
let initOptions = source["initOptions"] as? [Any] ?? []
|
||||
let uri = source["uri"] as? String
|
||||
let autoplay = source["autoplay"] as? Bool ?? false
|
||||
@@ -133,18 +141,8 @@ class VlcPlayerView: ExpoView {
|
||||
}
|
||||
}
|
||||
|
||||
// Apply subtitle options
|
||||
let subtitleOptions = self.getSubtitleOptions()
|
||||
media.addOptions(subtitleOptions)
|
||||
print("Debug: Applied subtitle options: \(subtitleOptions)")
|
||||
|
||||
// // Apply any additional media options
|
||||
// if let mediaOptions = mediaOptions {
|
||||
// media.addOptions(mediaOptions)
|
||||
// print("Debug: Applied additional media options: \(mediaOptions)")
|
||||
// } else {
|
||||
// print("Debug: No additional media options provided")
|
||||
// }
|
||||
print("Debug: Media options: \(mediaOptions)")
|
||||
media.addOptions(mediaOptions)
|
||||
|
||||
// Apply subtitle options
|
||||
let subtitleTrackIndex = source["subtitleTrackIndex"] as? Int ?? -1
|
||||
@@ -610,9 +608,12 @@ extension VlcPlayerView: VLCMediaPlayerDelegate {
|
||||
guard let player = self.mediaPlayer else { return }
|
||||
|
||||
let currentTimeMs = player.time.intValue
|
||||
let remainingTimeMs = player.remainingTime
|
||||
let durationMs = player.media?.length.intValue ?? 0
|
||||
|
||||
// print("currentTimeMs: \(currentTimeMs) RemainingTimeMs: \(remainingTimeMs)")
|
||||
if currentTimeMs >= 0 && currentTimeMs < durationMs {
|
||||
|
||||
self.onVideoProgress?([
|
||||
"currentTime": currentTimeMs,
|
||||
"duration": durationMs,
|
||||
|
||||
Reference in New Issue
Block a user