Skip to content

Commit

Permalink
fix #692
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Dec 19, 2023
1 parent e37c425 commit b2c203d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ open class KSOptions {
desire -= AVAudioSession.sharedInstance().outputLatency
#endif
let diff = nextVideoTime - desire
// print("[video] video diff \(diff) audio \(main.positionTime) interval \(CACurrentMediaTime() - main.lastMediaTime) render interval \(CACurrentMediaTime() - lastMediaTime)")
// print("[video] video diff \(diff) main \(main.time.seconds) interval \(CACurrentMediaTime() - main.lastMediaTime) render interval \(CACurrentMediaTime() - lastMediaTime)")
// 最大刷新率上限
if diff >= 1 / 120 {
videoClockDelayCount = 0
Expand Down
5 changes: 5 additions & 0 deletions Sources/KSPlayer/MEPlayer/MEPlayerItemTrack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,16 @@ class SyncPlayerItemTrack<Frame: MEFrame>: PlayerItemTrackProtocol, CustomString
}
lastPacketBytes += packet.size
let decoder = decoderMap.value(for: packet.assetTrack.trackID, default: makeDecode(assetTrack: packet.assetTrack))
// var startTime = CACurrentMediaTime()
decoder.decodeFrame(from: packet) { [weak self] result in
guard let self else {
return
}
do {
// if packet.assetTrack.mediaType == .video {
// print("[video] decode time: \(CACurrentMediaTime()-startTime)")
// startTime = CACurrentMediaTime()
// }
let frame = try result.get()
if self.state == .flush || self.state == .closed {
return
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/MEPlayer/Resample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class VideoSwresample: FrameChange {
}

func transfer(format: AVPixelFormat, width: Int32, height: Int32, data: [UnsafeMutablePointer<UInt8>?], linesize: [Int32]) -> CVPixelBuffer? {
setup(format: format, width: width, height: height, linesize: linesize[0])
setup(format: format, width: width, height: height, linesize: linesize[1] == 0 ? linesize[0] : linesize[1])
guard let pool else {
return nil
}
Expand Down
37 changes: 21 additions & 16 deletions Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,17 @@ struct VideoControllerView: View {
Spacer()
HStack {
Spacer()
Button {
config.skip(interval: -15)
} label: {
Image(systemName: "gobackward.15")
.font(.largeTitle)
if config.playerLayer?.player.seekable ?? false {
Button {
config.skip(interval: -15)
} label: {
Image(systemName: "gobackward.15")
.font(.largeTitle)
}
#if !os(tvOS)
.keyboardShortcut(.leftArrow, modifiers: .none)
#endif
}
#if !os(tvOS)
.keyboardShortcut(.leftArrow, modifiers: .none)
#endif
Spacer()
Button {
if config.state.isPlaying {
Expand All @@ -314,15 +316,17 @@ struct VideoControllerView: View {
.keyboardShortcut(.space, modifiers: .none)
#endif
Spacer()
Button {
config.skip(interval: 15)
} label: {
Image(systemName: "goforward.15")
.font(.largeTitle)
if config.playerLayer?.player.seekable ?? false {
Button {
config.skip(interval: 15)
} label: {
Image(systemName: "goforward.15")
.font(.largeTitle)
}
#if !os(tvOS)
.keyboardShortcut(.rightArrow, modifiers: .none)
#endif
}
#if !os(tvOS)
.keyboardShortcut(.rightArrow, modifiers: .none)
#endif
Spacer()
}
Spacer()
Expand Down Expand Up @@ -468,6 +472,7 @@ public struct MenuView<Label, SelectionValue, Content>: View where Label: View,
}
.pickerStyle(.inline)
} label: {
// menu 里面的label无法调整大小
label()
}
.menuIndicator(.hidden)
Expand Down

0 comments on commit b2c203d

Please sign in to comment.