diff --git a/Demo/Podfile b/Demo/Podfile index 3fbcbef63..1f42930c8 100644 --- a/Demo/Podfile +++ b/Demo/Podfile @@ -3,6 +3,7 @@ workspace 'Demo.xcworkspace' install! 'cocoapods', :generate_multiple_pod_projects => true def common pod 'KSPlayer', :path => '../', :testspecs => ['Tests'] + pod 'DisplayCriteria', :path => '../' pod 'Libass', :path => '../FFmpegKit' pod 'OpenSSL', :path => '../FFmpegKit' pod 'FFmpegKit', :path => '../FFmpegKit' diff --git a/Demo/SwiftUI/Player.xcodeproj/project.pbxproj b/Demo/SwiftUI/Player.xcodeproj/project.pbxproj index 7d795a520..62343c207 100644 --- a/Demo/SwiftUI/Player.xcodeproj/project.pbxproj +++ b/Demo/SwiftUI/Player.xcodeproj/project.pbxproj @@ -23,8 +23,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - AC3CAD6228BB88A200AA1C2C /* AVDisplayCriteriaKS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVDisplayCriteriaKS.h; sourceTree = ""; }; - AC3CAD6328BB893500AA1C2C /* Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = ""; }; AC43F6402A5172830026ECF2 /* FavoriteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteView.swift; sourceTree = ""; }; AC43F6432A51916F0026ECF2 /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = ""; }; AC43F6652A519D400026ECF2 /* Persistence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = ""; }; @@ -70,8 +68,6 @@ AC77DFAF26402327001351AE /* Shared */ = { isa = PBXGroup; children = ( - AC3CAD6228BB88A200AA1C2C /* AVDisplayCriteriaKS.h */, - AC3CAD6328BB893500AA1C2C /* Bridging-Header.h */, ACEA9FEA298BFC8800FBA74B /* MovieModel.swift */, AC44E0F929290CBB00617BD3 /* HomeView.swift */, AC44E0FA29290CBC00617BD3 /* ContentView.swift */, @@ -368,7 +364,6 @@ SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_OBJC_BRIDGING_HEADER = "Shared/Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3,6,7"; }; @@ -411,7 +406,6 @@ SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_OBJC_BRIDGING_HEADER = "Shared/Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3,6,7"; VALIDATE_PRODUCT = YES; diff --git a/Demo/SwiftUI/Shared/Bridging-Header.h b/Demo/SwiftUI/Shared/Bridging-Header.h deleted file mode 100644 index 37d9cbb24..000000000 --- a/Demo/SwiftUI/Shared/Bridging-Header.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// Bridging-Header.h -// tvOS -// -// Created by kintan on 2022/8/28. -// - -#ifndef Bridging_Header_h -#define Bridging_Header_h -#import "AVDisplayCriteriaKS.h" - -#endif /* Bridging_Header_h */ diff --git a/Demo/SwiftUI/Shared/MovieModel.swift b/Demo/SwiftUI/Shared/MovieModel.swift index d339613d8..87dcc2c13 100644 --- a/Demo/SwiftUI/Shared/MovieModel.swift +++ b/Demo/SwiftUI/Shared/MovieModel.swift @@ -28,24 +28,6 @@ class MEOptions: KSOptions { super.process(assetTrack: assetTrack) } - override func updateVideo(refreshRate: Float, isDovi: Bool, formatDescription: CMFormatDescription?) { - #if os(tvOS) || os(xrOS) - guard let displayManager = UIApplication.shared.windows.first?.avDisplayManager, - displayManager.isDisplayCriteriaMatchingEnabled - else { - return - } - if let formatDescription { - if KSOptions.displayCriteriaFormatDescriptionEnabled, #available(tvOS 17.0, *) { - displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription) - } else { - let dynamicRange = isDovi ? .dolbyVision : formatDescription.dynamicRange - displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: dynamicRange.rawValue) - } - } - #endif - } - override func isUseDisplayLayer() -> Bool { MEOptions.isUseDisplayLayer && display == .plane } diff --git a/Demo/demo-tvOS/demo-tvOS.xcodeproj/project.pbxproj b/Demo/demo-tvOS/demo-tvOS.xcodeproj/project.pbxproj index b9a577c5f..462ee9d82 100644 --- a/Demo/demo-tvOS/demo-tvOS.xcodeproj/project.pbxproj +++ b/Demo/demo-tvOS/demo-tvOS.xcodeproj/project.pbxproj @@ -20,8 +20,6 @@ /* Begin PBXFileReference section */ 055202483CC6922E098C6565 /* Pods-demo-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo-tvOS.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-demo-tvOS/Pods-demo-tvOS.debug.xcconfig"; sourceTree = ""; }; - 06D08BDA294DDA7400D919DB /* AVDisplayCriteriaKS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AVDisplayCriteriaKS.h; sourceTree = ""; }; - 06D08BDB294DDA9900D919DB /* Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = ""; }; AC08611420B69A1C00D801FC /* demo-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "demo-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; AC08611E20B69A1C00D801FC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; AC08612020B69A1C00D801FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -78,8 +76,6 @@ AC08611E20B69A1C00D801FC /* Assets.xcassets */, AC80333124BA1B54002B3D40 /* Main.storyboard */, AC08612020B69A1C00D801FC /* Info.plist */, - 06D08BDA294DDA7400D919DB /* AVDisplayCriteriaKS.h */, - 06D08BDB294DDA9900D919DB /* Bridging-Header.h */, ); path = "demo-tvOS"; sourceTree = ""; @@ -362,7 +358,6 @@ PRODUCT_BUNDLE_IDENTIFIER = kintan.player.demo.tvos; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OBJC_BRIDGING_HEADER = "demo-tvOS/Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; @@ -388,7 +383,6 @@ OTHER_CODE_SIGN_FLAGS = "--deep"; PRODUCT_BUNDLE_IDENTIFIER = kintan.player.demo.tvos; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "demo-tvOS/Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; }; diff --git a/Demo/demo-tvOS/demo-tvOS/AVDisplayCriteriaKS.h b/Demo/demo-tvOS/demo-tvOS/AVDisplayCriteriaKS.h deleted file mode 100644 index 634cc5727..000000000 --- a/Demo/demo-tvOS/demo-tvOS/AVDisplayCriteriaKS.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// AVDisplayCriteriaKS.h -// KSPlayer -// -// Created by kintan on 2022/8/28. -// - -#ifndef AVDisplayCriteriaKS_h -#define AVDisplayCriteriaKS_h -#if __has_include() -#import -#import - -@interface AVDisplayCriteria () -@property(readonly) int videoDynamicRange; -@property(readonly, nonatomic) float refreshRate; -- (id)initWithRefreshRate:(float)arg1 videoDynamicRange:(int)arg2; -@end -#endif -#endif /* AVDisplayCriteriaKS_h */ - diff --git a/Demo/demo-tvOS/demo-tvOS/Bridging-Header.h b/Demo/demo-tvOS/demo-tvOS/Bridging-Header.h deleted file mode 100644 index 37d9cbb24..000000000 --- a/Demo/demo-tvOS/demo-tvOS/Bridging-Header.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// Bridging-Header.h -// tvOS -// -// Created by kintan on 2022/8/28. -// - -#ifndef Bridging_Header_h -#define Bridging_Header_h -#import "AVDisplayCriteriaKS.h" - -#endif /* Bridging_Header_h */ diff --git a/DisplayCriteria.podspec b/DisplayCriteria.podspec new file mode 100644 index 000000000..cdcca16e9 --- /dev/null +++ b/DisplayCriteria.podspec @@ -0,0 +1,22 @@ +Pod::Spec.new do |s| + s.name = 'DisplayCriteria' + s.version = '1.1.0' + s.summary = 'Video Player Using Swift, based on AVPlayer,FFmpeg' + + s.description = <<-DESC + Video Player Using Swift, based on ffmpeg, support for the horizontal screen, vertical screen, the upper and lower slide to adjust the volume, the screen brightness, or so slide to adjust the playback progress. + DESC + + s.homepage = 'https://github.com/kingslay/KSPlayer' + s.authors = { 'kintan' => 'kingslay@icloud.com' } + s.license = 'MIT' + s.source = { :git => 'https://github.com/kingslay/KSPlayer.git', :tag => s.version.to_s } + + s.ios.deployment_target = '13.0' + s.osx.deployment_target = '10.15' + # s.watchos.deployment_target = '2.0' + s.tvos.deployment_target = '13.0' + s.static_framework = true + s.source_files = 'Sources/DisplayCriteria/**/*' + s.frameworks = 'AVFoundation' +end diff --git a/FFmpegKit b/FFmpegKit index 66b2705c2..a50d4c5cf 160000 --- a/FFmpegKit +++ b/FFmpegKit @@ -1 +1 @@ -Subproject commit 66b2705c2809a24769c77cc593b6beb2568fdfbc +Subproject commit a50d4c5cf7f105ada6006a8070f636195dc6df19 diff --git a/KSPlayer.podspec b/KSPlayer.podspec index c6bf49bdd..61f7842e5 100644 --- a/KSPlayer.podspec +++ b/KSPlayer.podspec @@ -35,6 +35,7 @@ Pod::Spec.new do |s| ss.ios.frameworks = 'UIKit' ss.tvos.frameworks = 'UIKit' ss.osx.frameworks = 'AppKit' + ss.dependency 'DisplayCriteria' end #ffmpeg播放内核 s.subspec 'MEPlayer' do |ss| diff --git a/Package.swift b/Package.swift index 3d2b9b3df..6705d5ccb 100644 --- a/Package.swift +++ b/Package.swift @@ -22,9 +22,13 @@ let package = Package( .product(name: "FFmpegKit", package: "FFmpegKit"), // .product(name: "Libass", package: "FFmpegKit"), // .product(name: "Libmpv", package: "FFmpegKit"), + "DisplayCriteria", ], resources: [.process("Metal/Shaders.metal")] ), + .target( + name: "DisplayCriteria" + ), .testTarget( name: "KSPlayerTests", dependencies: ["KSPlayer"], diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift index f62abcbd1..9d53e5d69 100644 --- a/Package@swift-5.9.swift +++ b/Package@swift-5.9.swift @@ -23,9 +23,13 @@ let package = Package( .product(name: "FFmpegKit", package: "FFmpegKit"), // .product(name: "Libass", package: "FFmpegKit"), // .product(name: "Libmpv", package: "FFmpegKit"), + "DisplayCriteria", ], resources: [.process("Metal/Shaders.metal")] ), + .target( + name: "DisplayCriteria" + ), .testTarget( name: "KSPlayerTests", dependencies: ["KSPlayer"], diff --git a/README.md b/README.md index 7e22c4469..f9fd9cb1a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Make sure to use the latest version **cocoapods 1.10.1+**, which can be installe target 'ProjectName' do use_frameworks! pod 'KSPlayer',:git => 'https://github.com/kingslay/KSPlayer.git', :branch => 'develop' + pod 'DisplayCriteria',:git => 'https://github.com/kingslay/KSPlayer.git', :branch => 'develop' pod 'FFmpegKit',:git => 'https://github.com/kingslay/FFmpegKit.git', :branch => 'main' pod 'OpenSSL',:git => 'https://github.com/kingslay/FFmpegKit.git', :branch => 'main' pod 'Libass',:git => 'https://github.com/kingslay/FFmpegKit.git', :branch => 'main' diff --git a/Sources/DisplayCriteria/DisplayCriteria.m b/Sources/DisplayCriteria/DisplayCriteria.m new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/Sources/DisplayCriteria/DisplayCriteria.m @@ -0,0 +1 @@ + diff --git a/Demo/SwiftUI/Shared/AVDisplayCriteriaKS.h b/Sources/DisplayCriteria/include/AVDisplayCriteriaKS.h similarity index 99% rename from Demo/SwiftUI/Shared/AVDisplayCriteriaKS.h rename to Sources/DisplayCriteria/include/AVDisplayCriteriaKS.h index e5e2722e0..5d93cc425 100644 --- a/Demo/SwiftUI/Shared/AVDisplayCriteriaKS.h +++ b/Sources/DisplayCriteria/include/AVDisplayCriteriaKS.h @@ -16,4 +16,3 @@ @end #endif #endif /* AVDisplayCriteriaKS_h */ - diff --git a/Sources/KSPlayer/AVPlayer/KSOptions.swift b/Sources/KSPlayer/AVPlayer/KSOptions.swift index 5fa88d133..dbe190aa0 100644 --- a/Sources/KSPlayer/AVPlayer/KSOptions.swift +++ b/Sources/KSPlayer/AVPlayer/KSOptions.swift @@ -6,7 +6,11 @@ // import AVFoundation +#if os(tvOS) || os(xrOS) +import DisplayCriteria +#endif import OSLog + #if canImport(UIKit) import UIKit #endif @@ -315,7 +319,7 @@ open class KSOptions { } } - open func updateVideo(refreshRate: Float, isDovi _: Bool, formatDescription: CMFormatDescription?) { + open func updateVideo(refreshRate: Float, isDovi: Bool, formatDescription: CMFormatDescription?) { #if os(tvOS) || os(xrOS) guard let displayManager = UIApplication.shared.windows.first?.avDisplayManager, displayManager.isDisplayCriteriaMatchingEnabled @@ -327,8 +331,8 @@ open class KSOptions { if KSOptions.displayCriteriaFormatDescriptionEnabled, #available(tvOS 17.0, *) { displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription) } else { -// let dynamicRange = isDovi ? .dolbyVision : formatDescription.dynamicRange -// displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: dynamicRange.rawValue) + let dynamicRange = isDovi ? .dolbyVision : formatDescription.dynamicRange + displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: dynamicRange.rawValue) } } #endif