播放页面,控制横屏,还需要进一步处理

This commit is contained in:
bluesea 2024-04-26 12:41:47 +08:00
parent 71d0ca1a10
commit 61ef45d508
11 changed files with 225 additions and 89 deletions

View File

@ -1070,7 +1070,7 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
@ -1122,7 +1122,7 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (

View File

@ -545,8 +545,8 @@
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "280"
endingLineNumber = "280"
startingLineNumber = "373"
endingLineNumber = "373"
landmarkName = "notification_didActiveNotification(notification:)"
landmarkType = "7">
</BreakpointContent>
@ -641,8 +641,8 @@
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/ZZHCustomSlider.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "265"
endingLineNumber = "265"
startingLineNumber = "266"
endingLineNumber = "266"
landmarkName = "touchesCancelled(_:with:)"
landmarkType = "7">
</BreakpointContent>
@ -650,49 +650,49 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "33963580-0C7F-4FE4-AE70-F6DF35741254"
uuid = "CD9BB14F-8F94-4719-990D-C68773DB9C48"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/Project/Util/PlayByTransferConvertor.swift"
filePath = "SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "260"
endingLineNumber = "260"
landmarkName = "getImgWithScale(image:scale:)"
startingLineNumber = "160"
endingLineNumber = "160"
landmarkName = "viewDidLoad()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "9F19BD4E-941C-4D52-B3EF-40E453A907BA"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/CCKit/Base/BaseVirtualController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "90"
endingLineNumber = "90"
landmarkName = "setNavgationBarColor(color:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "67370F57-E845-49B3-A0B1-BBC5E230A1D7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/CCKit/Base/BaseVirtualController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "69"
endingLineNumber = "69"
landmarkName = "setNavgationBarImg(string:)"
landmarkType = "7">
<Locations>
<Location
uuid = "33963580-0C7F-4FE4-AE70-F6DF35741254 - 93a5385675665f6e"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.PlayByTransferConvertor.getImgWithScale(image: __C.UIImage, scale: CoreGraphics.CGFloat) -&gt; (__C.UIImage, __C.CGSize)"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/PlayByTransferConvertor.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "256"
endingLineNumber = "256"
offsetFromSymbolStart = "1056">
</Location>
<Location
uuid = "33963580-0C7F-4FE4-AE70-F6DF35741254 - e6cd3874189e0e8a"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.PlayByTransferConvertor.joinImages_backup(leftImage: __C.CIImage, rightImage: __C.CIImage) -&gt; __C.CIImage"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/PlayByTransferConvertor.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "256"
endingLineNumber = "256"
offsetFromSymbolStart = "572">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>

View File

@ -26,6 +26,7 @@ import FirebaseRemoteConfig
class AppDelegate: UIResponder, UIApplicationDelegate {
var remoteConfig:FirebaseRemoteConfig.RemoteConfig?
var allowRotation = false
var window: UIWindow?
// var root:RootManager?
var newWindow:UIWindow?
@ -87,6 +88,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if self.allowRotation {
return UIInterfaceOrientationMask.all
}
return UIInterfaceOrientationMask.portrait
}
// func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// print("configurationForConnecting....")
// let scene = UIWindowScene(session: connectingSceneSession, connectionOptions: options)

View File

@ -78,8 +78,13 @@ class BaseController: BaseVirtualController {
}
override func viewDidLoad() {
super.viewDidLoad()
KAppDelegate?.allowRotation = false
self.setNeedsUpdateOfSupportedInterfaceOrientations()
self.setNavgationBarColorImg(color: .black)
// self.setNavgationBarColorImg(color: tabBarTintSelectColor)
self.setNavgationBarLine(color: BackGroundColor)

View File

@ -112,9 +112,13 @@ class BaseVirtualController: UIViewController {
public func setNavgationBarColorImg(color:UIColor){
if(navtionBar == nil){
navtionBar = UIImageView.init()
navtionBar?.frame = CGRect.init(x: 0, y: 0, width: SCREEN_Width, height: SafeAreaTop_Height)
// navtionBar?.frame = CGRect.init(x: 0, y: 0, width: SCREEN_Width, height: SafeAreaTop_Height)
navtionBar?.isUserInteractionEnabled = true
view.addSubview(navtionBar!)
navtionBar?.snp.makeConstraints { make in
make.left.top.right.equalToSuperview()
make.height.equalTo(SafeAreaTop_Height)
}
}
if(navtionImgView == nil){
navtionImgView = UIImageView.init()

View File

@ -23,5 +23,7 @@ class RootNavigationController: UINavigationController {
// Do any additional setup after loading the view.
}
// appli
}

View File

@ -2,8 +2,23 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb349630657543828</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>349630657543828</string>
<key>FacebookAutoLogAppEventsEnabled</key>
<true/>
<key>FacebookClientToken</key>
<string>14b6cc1b437b5a201663ebd7e1a9b2bb</string>
<key>FacebookDisplayName</key>
<string>VPCamera</string>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>NSAppTransportSecurity</key>
@ -43,20 +58,5 @@
</dict>
<key>UIBackgroundModes</key>
<array/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb349630657543828</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>349630657543828</string>
<key>FacebookClientToken</key>
<string>14b6cc1b437b5a201663ebd7e1a9b2bb</string>
<key>FacebookDisplayName</key>
<string>VPCamera</string>
</dict>
</plist>

View File

@ -104,6 +104,7 @@ class CCSpatialVideoDisplayController: BaseController {
var customPlayer:ZZHCustomPlayer = {
let cp = ZZHCustomPlayer(frame: .zero)
return cp
}()
@ -222,8 +223,86 @@ class CCSpatialVideoDisplayController: BaseController {
self.customPlayer.setUPPlayer()
// AirPlay
self.checkAirPlayStatus()
KAppDelegate?.allowRotation = true
listingScreenOrientatinChange()
// self.setNeedsUpdateOfSupportedInterfaceOrientations()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.customPlayer.play(false)
KAppDelegate?.allowRotation = false
self.setNeedsUpdateOfSupportedInterfaceOrientations()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
KAppDelegate?.allowRotation = true
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
if externalVC != nil {
externalVC?.playerLayer?.player = nil
}
customPlayer.play(false)
releaseVideoComposition()
let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_VideoDisplayController)
Analytics.logEvent("preview_pv", parameters: ["refer_page":"视频预览页面","duration":sec])
print(".........ccs viewdid disappear....")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
//
func listingScreenOrientatinChange() {
UIDevice.current.beginGeneratingDeviceOrientationNotifications()
//
NotificationCenter.default.addObserver(self, selector: #selector(screenOrientationRotate), name: UIDevice.orientationDidChangeNotification, object: nil)
}
@objc func screenOrientationRotate() {
let orientation = UIDevice.current.orientation
switch orientation {
case .portrait , .portraitUpsideDown:
print("Portrait")
self.customPlayer.snp.updateConstraints { make in
make.height.equalTo(460)
}
navtionBar?.snp.updateConstraints { make in
make.top.equalToSuperview().offset(0)
}
self.view.layoutIfNeeded()
self.customPlayer.layoutViewWhenScreenLandscape(value: false)
self.navtionBar?.isHidden = false
self.customPlayer.isLandscape = false
break
case .landscapeLeft , .landscapeRight:
print("Landscape ...")
self.customPlayer.isLandscape = true
self.customPlayer.snp.updateConstraints { make in
make.height.equalTo(KScreenWidth)
}
navtionBar?.snp.updateConstraints { make in
make.top.equalToSuperview().offset(-KStatusBarHeight * 0.5)
}
self.view.layoutIfNeeded()
self.customPlayer.layoutViewWhenScreenLandscape(value: true)
self.navtionBar?.isHidden = true
break
default:
print("Other")
}
}
func configureUI(){
self.view.backgroundColor = UIColor(hexString: "#060507")
@ -237,7 +316,19 @@ class CCSpatialVideoDisplayController: BaseController {
self.view.bringSubviewToFront(self.navtionBar!)
navtionBar?.addSubview(transformButton)
transformButton.snp.makeConstraints { make in
make.width.equalTo(56)
make.height.equalTo(36)
make.right.equalToSuperview().offset(-14)
make.centerY.equalToSuperview().offset(StatuBar_Height*0.5)
}
navtionBar?.addSubview(mTopCenterTypeButton)
mTopCenterTypeButton.snp.makeConstraints { make in
make.height.equalTo(36)
make.width.equalTo(SCREEN_Width * 0.4 + 20)
make.centerX.equalToSuperview()
make.centerY.equalToSuperview().offset(StatuBar_Height*0.5)
}
self.view.addSubview(tipsButton)
self.view.addSubview(self.customPlayer)
@ -246,7 +337,9 @@ class CCSpatialVideoDisplayController: BaseController {
make.height.equalTo(460)
}
self.customPlayer.sourceVideoURL = sourceVideoURL
self.customPlayer.maskViewTapCallback = {[weak self] in
self?.navtionBar?.isHidden = !(self?.navtionBar?.isHidden ?? true)
}
self.view.addSubview(self.maskLabel)
self.maskLabel.snp.makeConstraints { make in
make.left.equalTo(customPlayer.snp.left)
@ -294,27 +387,7 @@ class CCSpatialVideoDisplayController: BaseController {
print("notificatin_newErrorLogEntryNotification....")
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
if externalVC != nil {
externalVC?.playerLayer?.player = nil
}
customPlayer.play(false)
releaseVideoComposition()
let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_VideoDisplayController)
Analytics.logEvent("preview_pv", parameters: ["refer_page":"视频预览页面","duration":sec])
print(".........ccs viewdid disappear....")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
//MARK: -
@objc private func airPlayStatusDidChange(_ notification: Notification) {
@ -472,6 +545,8 @@ class CCSpatialVideoDisplayController: BaseController {
print("patialvideodisplaycontroler deinit......")
releaseVideoComposition()
NotificationCenter.default.removeObserver(self)
//
UIDevice.current.endGeneratingDeviceOrientationNotifications()
}
func releaseVideoComposition() {

View File

@ -9,10 +9,14 @@ import Foundation
import UIKit
import AVKit
typealias CustomMaskViewTapCallback = ()->Void
class ZZHCustomPlayer: UIView {
//maskview ,
var maskViewTapCallback:CustomMaskViewTapCallback?
//
var isLandscape:Bool = false
//
var sourceVideoURL:URL?
var assetTrack:AVAssetTrack?
@ -63,7 +67,7 @@ class ZZHCustomPlayer: UIView {
}
}
let playerPauseBgColor:UIColor = UIColor(r: 20, g: 20, b: 20, a: 0.2)//
let playerHeight = 230 //
lazy var maskPlayerView:UIView? = {//
let bgView = UIView()
@ -127,7 +131,7 @@ class ZZHCustomPlayer: UIView {
NotificationCenter.default.addObserver(self, selector: #selector(notification_PlayerEndTime(notification:)), name: AVPlayerItem.didPlayToEndTimeNotification, object: nil)
let playerWidth = KScreenWidth
let playerHeight = 230
playerLayerBgView = UIView()
self.addSubview(playerLayerBgView!)
playerLayerBgView!.snp.makeConstraints { make in
@ -147,11 +151,17 @@ class ZZHCustomPlayer: UIView {
playerLayerBgView?.backgroundColor = UIColor.red
//
let mpBgView = UIView(frame: avPlayerLayer!.frame)
let mpBgView = UIView(frame: .zero)
playerLayerBgView?.addSubview(mpBgView)
mpBgView.snp.makeConstraints { make in
make.left.top.bottom.right.equalToSuperview()
}
self.maskPlayerView?.frame = mpBgView.bounds
mpBgView.addSubview(maskPlayerView!)
maskPlayerView?.snp.makeConstraints { make in
make.left.top.bottom.right.equalToSuperview()
}
let tgr = UITapGestureRecognizer(target: self, action: #selector(tapPlayerMaskView(sender: )))
mpBgView.addGestureRecognizer(tgr)
@ -168,8 +178,8 @@ class ZZHCustomPlayer: UIView {
timeSlider!.snp.makeConstraints { make in
make.left.equalToSuperview().offset(24)
// make.right.equalToSuperview().offset(-24)
make.bottom.equalToSuperview().offset(0)
make.height.equalTo(114)
make.bottom.equalToSuperview().offset(-30)
make.height.equalTo(84)
}
edBtn = UIButton()
@ -186,6 +196,28 @@ class ZZHCustomPlayer: UIView {
self.backgroundColor = .orange
}
//timeSlideredBtn,layer
func layoutViewWhenScreenLandscape(value:Bool) {
if value {
timeSlider?.isHidden = true
edBtn?.isHidden = true
playerLayerBgView?.snp.updateConstraints { make in
make.height.equalTo(KScreenWidth)
}
self.layoutIfNeeded()
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: KScreenHeight, height: KScreenWidth)
}
else {
timeSlider?.isHidden = false
edBtn?.isHidden = false
playerLayerBgView?.snp.updateConstraints { make in
make.height.equalTo(KScreenWidth)
}
self.layoutIfNeeded()
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(KScreenWidth), height: playerHeight)
}
}
//
@objc func showEDView(sender:UIButton){
CustomParamBoardView.showBoard(scaleCallback: {[weak self] scale in
@ -322,6 +354,14 @@ class ZZHCustomPlayer: UIView {
//player maskview
@objc func tapPlayerMaskView(sender:UITapGestureRecognizer) {
updatePlayMaskView(!(maskPlayerView!.isHidden))
if isLandscape {
if let mcallback = maskViewTapCallback {
mcallback()
}
self.timeSlider?.isHidden = !self.timeSlider!.isHidden
self.edBtn?.isHidden = !self.edBtn!.isHidden
}
}
// playermaskview

View File

@ -9,6 +9,7 @@ import Foundation
import UIKit
typealias CustomSliderProcessChangeValueCallback = (_ currentValue:Float,_ isMoving:Bool)->Void
class ZZHCustomSlider: UIView {
var sHeight:CGFloat?
var sLabel:UILabel?
var eLabel:UILabel?
@ -25,7 +26,7 @@ class ZZHCustomSlider: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .black
self.backgroundColor = .clear
self.addSubview(bgView)
bgView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
@ -370,7 +371,7 @@ class CustomParamBoardView: UIView {
make.bottom.equalToSuperview().offset(bgViewHeight)
make.centerX.equalToSuperview()
}
self.superBgView.backgroundColor = .black
self.superBgView.backgroundColor = .clear
// let blackBgView = UIView()
// self.addSubview(blackBgView)