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