Skip to content

Commit

Permalink
fix #690
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Dec 13, 2023
1 parent 3c892b7 commit d3f89fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
10 changes: 3 additions & 7 deletions Sources/KSPlayer/AVPlayer/KSAVPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class AVMediaPlayerTrack: MediaPlayerTrack {
let rotation: Int16 = 0
let bitRate: Int64
let name: String
let language: String?
let languageCode: String?
let mediaType: AVFoundation.AVMediaType
let isImageSubtitle = false
var dovi: DOVIDecoderConfigurationRecord?
Expand All @@ -535,17 +535,13 @@ class AVMediaPlayerTrack: MediaPlayerTrack {
self.track = track
trackID = track.assetTrack?.trackID ?? 0
mediaType = track.assetTrack?.mediaType ?? .video
#if os(xrOS)
name = track.assetTrack?.languageCode ?? ""
language = track.assetTrack?.extendedLanguageTag
languageCode = track.assetTrack?.languageCode
nominalFrameRate = track.assetTrack?.nominalFrameRate ?? 24.0
bitRate = Int64(track.assetTrack?.estimatedDataRate ?? 0)
#if os(xrOS)
isPlayable = false
#else
name = track.assetTrack?.languageCode ?? ""
language = track.assetTrack?.extendedLanguageTag
nominalFrameRate = track.assetTrack?.nominalFrameRate ?? 24.0
bitRate = Int64(track.assetTrack?.estimatedDataRate ?? 0)
isPlayable = track.assetTrack?.isPlayable ?? false
#endif
// swiftlint:disable force_cast
Expand Down
8 changes: 7 additions & 1 deletion Sources/KSPlayer/AVPlayer/MediaPlayerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public protocol MediaPlayerDelegate: AnyObject {
public protocol MediaPlayerTrack: AnyObject, CustomStringConvertible {
var trackID: Int32 { get }
var name: String { get }
var language: String? { get }
var languageCode: String? { get }
var mediaType: AVFoundation.AVMediaType { get }
var nominalFrameRate: Float { get }
var bitRate: Int64 { get }
Expand Down Expand Up @@ -180,6 +180,12 @@ extension FFmpegFieldOrder: CustomStringConvertible {

// swiftlint:enable identifier_name
public extension MediaPlayerTrack {
var language: String? {
languageCode.flatMap {
Locale.current.localizedString(forLanguageCode: $0)
}
}

var codecType: FourCharCode {
mediaSubType.rawValue
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/KSPlayer/MEPlayer/FFmpegAssetTrack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class FFmpegAssetTrack: MediaPlayerTrack {
public private(set) var trackID: Int32 = 0
public let codecName: String
public var name: String = ""
public private(set) var language: String?
public private(set) var languageCode: String?
public private(set) var nominalFrameRate: Float = 0
public private(set) var bitRate: Int64 = 0
public let mediaType: AVFoundation.AVMediaType
Expand Down Expand Up @@ -97,9 +97,9 @@ public class FFmpegAssetTrack: MediaPlayerTrack {
}

if let value = metadata["language"], value != "und" {
language = Locale.current.localizedString(forLanguageCode: value)
languageCode = value
} else {
language = nil
languageCode = nil
}
if let value = metadata["title"] {
name = value
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/Video/IOSVideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class IOSVideoPlayerView: VideoPlayerView {
fullScreenDelegate?.player(isMaskShow: isMaskShow, isFullScreen: landscapeButton.isSelected)
}
}

#if !os(xrOS)
private var brightness: CGFloat = UIScreen.main.brightness {
didSet {
Expand Down

0 comments on commit d3f89fb

Please sign in to comment.