Skip to content

Commit

Permalink
fix 图片字幕一直存在的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Apr 22, 2024
1 parent 866cc06 commit b96f145
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ open class KSOptions {
formatContextOptions["reconnect"] = 1
formatContextOptions["reconnect_streamed"] = 1
// 这个是用来开启http的链接复用(keep-alive)。vlc默认是打开的,所以这边也默认打开。
//开启这个,百度网盘的视频链接无法播放
//formatContextOptions["multiple_requests"] = 1
// 开启这个,百度网盘的视频链接无法播放
// formatContextOptions["multiple_requests"] = 1
// 下面是用来处理秒开的参数,有需要的自己打开。默认不开,不然在播放某些特殊的ts直播流会频繁卡顿。
// formatContextOptions["auto_convert"] = 0
// formatContextOptions["fps_probe_size"] = 3
Expand Down
6 changes: 5 additions & 1 deletion Sources/KSPlayer/MEPlayer/SubtitleDecode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ class SubtitleDecode: DecodeProtocol {
duration = packet.assetTrack.timebase.cmtime(for: packet.duration).seconds
}
if let preSubtitleFrame, preSubtitleFrame.part.end == preSubtitleFrame.part.start {
preSubtitleFrame.part.end = start
if start == preSubtitleFrame.part.end {
return
} else {
preSubtitleFrame.part.end = start
}
}
preSubtitleFrame = nil
let parts = text(subtitle: subtitle)
Expand Down
6 changes: 4 additions & 2 deletions Sources/KSPlayer/Subtitle/KSParseProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,11 @@ public class VTTParse: KSParseProtocol {
timeStrs = scanner.scanUpToCharacters(from: .newlines)
_ = scanner.scanCharacters(from: .newlines)
} while !(timeStrs?.contains("-->") ?? false) && !scanner.isAtEnd
guard let timeStrs else { return nil }
guard let timeStrs else {
return nil
}
let timeArray: [String] = timeStrs.components(separatedBy: "-->")
if timeArray.count == 2{
if timeArray.count == 2 {
let startString = timeArray[0]
let endString = timeArray[1]
_ = scanner.scanCharacters(from: .newlines)
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct KSVideoPlayerView: View {
HStack {
Spacer()
VideoSubtitleView(model: playerCoordinator.subtitleModel)
.allowsHitTesting(false)//禁止字幕视图交互,以免抢占视图的点击事件或其它手势事件
.allowsHitTesting(false) // 禁止字幕视图交互,以免抢占视图的点击事件或其它手势事件
Spacer()
}
.padding()
Expand Down

0 comments on commit b96f145

Please sign in to comment.