Skip to content

Commit

Permalink
add Stream Type #528
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Nov 5, 2023
1 parent 52da789 commit 5a3c14f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Sources/KSPlayer/AVPlayer/MediaPlayerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ public enum FFmpegFieldOrder: UInt8 {
case bt // < Bottom coded first, top displayed first
}

extension FFmpegFieldOrder: CustomStringConvertible {
public var description: String {
switch self {
case .unknown, .progressive:
return "progressive"
case .tt:
return "top first"
case .bb:
return "bottom first"
case .tb:
return "top coded first (swapped)"
case .bt:
return "bottom coded first (swapped)"
}
}
}

// swiftlint:enable identifier_name
public extension MediaPlayerTrack {
var codecType: FourCharCode {
Expand Down
7 changes: 4 additions & 3 deletions Sources/KSPlayer/SwiftUI/KSVideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ struct VideoSettingView: View {
Label("Audio track", systemImage: "waveform")
}
}

if let videoTracks = config.playerLayer?.player.tracks(mediaType: .video), !videoTracks.isEmpty {
let videoTracks = config.playerLayer?.player.tracks(mediaType: .video)
if let videoTracks, !videoTracks.isEmpty {
Picker(selection: Binding {
videoTracks.first { $0.isEnabled }?.trackID
} set: { value in
Expand Down Expand Up @@ -522,8 +522,9 @@ struct VideoSettingView: View {
Button("Search Sutitle") {
subtitleModel.searchSubtitle(query: subtitleTitle, languages: ["zh-cn"])
}
Text("Stream Type: \((videoTracks?.first { $0.isEnabled }?.fieldOrder ?? .progressive).description)")
if let fileSize = config.playerLayer?.player.fileSize, fileSize > 0 {
Text("File Size \(String(format: "%.1f", fileSize / 1_000_000))MB")
Text("File Size: \(String(format: "%.1f", fileSize / 1_000_000))MB")
}
}
.padding()
Expand Down

0 comments on commit 5a3c14f

Please sign in to comment.