空间视频预览页面解决循环引用问题
This commit is contained in:
parent
ac90cf0524
commit
bfbf17b997
@ -930,7 +930,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.1;
|
||||
MARKETING_VERSION = 1.2;
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nsk.tdvideo;
|
||||
@ -981,7 +981,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.1;
|
||||
MARKETING_VERSION = 1.2;
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nsk.tdvideo;
|
||||
|
||||
Binary file not shown.
@ -190,8 +190,8 @@
|
||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "442"
|
||||
endingLineNumber = "442"
|
||||
startingLineNumber = "454"
|
||||
endingLineNumber = "454"
|
||||
landmarkName = "setttinisScreenMirroring(isScreenMirroring:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
|
||||
@ -36,14 +36,14 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
didSet{
|
||||
//跟新selectedIndex、typeData的值
|
||||
if(isAirPlayActive){
|
||||
self.selectedIndex = .hsbs//在串流模式下,默认选项为hsbs
|
||||
self.typeData = [(icon:"type_check",title:"3D HSBS",isHiden:false),
|
||||
selectedIndex = .hsbs//在串流模式下,默认选项为hsbs
|
||||
typeData = [(icon:"type_check",title:"3D HSBS",isHiden:false),
|
||||
(icon:"type_check",title:"3D FSBS",isHiden:false),
|
||||
]
|
||||
}
|
||||
else{
|
||||
self.selectedIndex = .parallelEyes//在非串流模式下,默认选项为monocular2D
|
||||
self.typeData = [(icon:"type_check",title:"平行眼",isHiden:false),
|
||||
selectedIndex = .parallelEyes//在非串流模式下,默认选项为monocular2D
|
||||
typeData = [(icon:"type_check",title:"平行眼",isHiden:false),
|
||||
(icon:"type_check",title:"单眼2D",isHiden:false),
|
||||
|
||||
(icon:"type_check",title:"红蓝立体",isHiden:false),
|
||||
@ -172,9 +172,9 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
|
||||
//init (test随机生成点位置,注意:arrow点是基于屏幕的位置)
|
||||
let pointOnScreen = navtionImgView!.convert(CGPointMake(navtionImgView!.centerX, navtionImgView!.bottom), to: KWindow)
|
||||
let popMenu = CCSpatialDisplayTypeView(menuWidth: SCREEN_Width * 0.4, arrow: pointOnScreen, datas: typeData,configures: parameters){
|
||||
let popMenu = CCSpatialDisplayTypeView(menuWidth: SCREEN_Width * 0.4, arrow: pointOnScreen, datas: typeData,configures: parameters){[weak self] in
|
||||
//dissmiss回调
|
||||
self.mTopCenterTypeButton.setImage(UIImage.init(named: "type_button_arrow_down"), for: .normal)
|
||||
self?.mTopCenterTypeButton.setImage(UIImage.init(named: "type_button_arrow_down"), for: .normal)
|
||||
}
|
||||
return popMenu
|
||||
}()
|
||||
@ -200,8 +200,6 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
button.titleLabel?.font = KFont_Regular(14)
|
||||
button.titleLabel?.adjustsFontSizeToFitWidth = true
|
||||
button.updateBtnEdgeInsets(style: .Left, space: 8)
|
||||
// button.layer.cornerRadius = 18
|
||||
// button.layer.masksToBounds = true
|
||||
button.centerY = progressView.top - 70
|
||||
button.centerX = self.view.centerX
|
||||
|
||||
@ -211,20 +209,14 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
|
||||
//监听播放完毕
|
||||
@objc func notification_PlayerEndTime(notification:Notification){
|
||||
print("PlayerEndTime....")
|
||||
// print("PlayerEndTime....")
|
||||
}
|
||||
|
||||
//监听拖动播放的进度事件
|
||||
@objc func notification_PlayerTimeJump(notification:Notification){
|
||||
|
||||
// self.player?.play()
|
||||
// Task {
|
||||
// await self.loadVideoAssetReader()
|
||||
// DispatchQueue.main.async {
|
||||
// self.player?.play()
|
||||
// }
|
||||
// }
|
||||
print("time jump....")
|
||||
|
||||
// print("time jump....")
|
||||
|
||||
|
||||
}
|
||||
@ -233,34 +225,32 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_VideoDisplayController)
|
||||
|
||||
|
||||
Task {
|
||||
print("ccs viewdid load ---------")
|
||||
await self.loadVideoAssetReader()
|
||||
print("ccs viewdid load +++++++")
|
||||
}
|
||||
|
||||
|
||||
print("getPlayerItem ========")
|
||||
let playerItem = self.getPlayerItem()
|
||||
player = AVPlayer(playerItem: playerItem)
|
||||
|
||||
player = AVPlayer(playerItem: playerItem)
|
||||
print("getPlayerItem >>>>>>>")
|
||||
self.view.backgroundColor = UIColor(hexString: "#060507")
|
||||
|
||||
//设置返回按钮图片
|
||||
self.setLeftOneBtnImg(imgStr: "spatial_back_button")
|
||||
// self.setLeftBtnImg(imgStr1: "", imgStr2: "spatial_back_button")
|
||||
self.setNavgationBarColorImg(color: .clear)
|
||||
self.setNavgationBarLine(color: .clear)
|
||||
|
||||
self.view.addSubview(mTopImgView)
|
||||
self.view.bringSubviewToFront(self.navtionBar!)
|
||||
// navtionBar?.addSubview(backButton)
|
||||
|
||||
navtionBar?.addSubview(transformButton)
|
||||
navtionBar?.addSubview(mTopCenterTypeButton)
|
||||
// self.view.addSubview(progressView)
|
||||
|
||||
// playerLay = AVPlayerLayer(player: self.player)
|
||||
// playerLay!.backgroundColor = UIColor.clear.cgColor
|
||||
// playerLay!.frame = CGRect.init(x: 0, y: 250, width: self.view.frame.size.width, height: 240)
|
||||
|
||||
|
||||
playerController = AVPlayerViewController()
|
||||
playerController?.player = player
|
||||
playerController?.delegate = self
|
||||
@ -272,10 +262,11 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
|
||||
|
||||
|
||||
|
||||
// 监听 AirPlay 设备的连接状态
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(airPlayStatusDidChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil)
|
||||
self.player!.play()
|
||||
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(notification_PlayerEndTime(notification:)), name: AVPlayerItem.didPlayToEndTimeNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(notification_PlayerTimeJump(notification:)), name: AVPlayerItem.timeJumpedNotification, object: nil)
|
||||
}
|
||||
@ -283,7 +274,11 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
func getPlayerItem() -> AVPlayerItem {
|
||||
let temItem = AVPlayerItem(asset: self.videoOriginalAsset)
|
||||
//实时播放回调可以做滤镜操作
|
||||
temItem.videoComposition = AVVideoComposition(asset: temItem.asset) { [self] request in
|
||||
temItem.videoComposition = AVVideoComposition(asset: temItem.asset) { [weak self] request in
|
||||
guard let weakSelf = self else {
|
||||
print("self 被销毁了.....")
|
||||
return
|
||||
}
|
||||
let compositionTime = request.compositionTime
|
||||
let end:CMTime = CMTimeMake(value: Int64(compositionTime.value+1), timescale: compositionTime.timescale)
|
||||
let tr = CMTimeRange(start: compositionTime, end: end)
|
||||
@ -293,58 +288,74 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
|
||||
|
||||
var ciImg:CIImage? = nil
|
||||
switch self.selectedIndex {
|
||||
switch weakSelf.selectedIndex {
|
||||
case .crossedEyes://交叉眼
|
||||
while let nextSampleBuffer = self.assetOutput!.copyNextSampleBuffer() {
|
||||
}
|
||||
self.assetOutput?.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
|
||||
ciImg = videoTranserConvertor.convertVideo(asset: videoOriginalAsset, assetOutput: self.assetOutput!, type: self.selectedIndex, time: compositionTime)
|
||||
guard let ao = weakSelf.assetOutput else {
|
||||
print("assetOutput 应该是没有被创建成功.....")
|
||||
return
|
||||
}
|
||||
while let nextSampleBuffer = ao.copyNextSampleBuffer() {
|
||||
}
|
||||
ao.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
|
||||
ciImg = weakSelf.videoTranserConvertor.convertVideo(asset: weakSelf.videoOriginalAsset, assetOutput: ao, type: weakSelf.selectedIndex, time: compositionTime)
|
||||
break
|
||||
|
||||
|
||||
case .fsbs:
|
||||
while let nextSampleBuffer = self.assetOutput!.copyNextSampleBuffer() {
|
||||
}
|
||||
self.assetOutput?.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
ciImg = videoTranserConvertor.convertVideo(asset: videoOriginalAsset, assetOutput: self.assetOutput!, type: self.selectedIndex, time: compositionTime)
|
||||
case .fsbs://3d全宽
|
||||
guard let ao = weakSelf.assetOutput else {
|
||||
return
|
||||
}
|
||||
while let nextSampleBuffer = ao.copyNextSampleBuffer() {
|
||||
}
|
||||
ao.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
ciImg = weakSelf.videoTranserConvertor.convertVideo(asset: weakSelf.videoOriginalAsset, assetOutput: ao, type: weakSelf.selectedIndex, time: compositionTime)
|
||||
break
|
||||
|
||||
|
||||
case .hsbs:
|
||||
while let nextSampleBuffer = self.assetOutput!.copyNextSampleBuffer() {
|
||||
}
|
||||
self.assetOutput?.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
|
||||
ciImg = videoTranserConvertor.convertVideo(asset: videoOriginalAsset, assetOutput: self.assetOutput!, type: self.selectedIndex, time: compositionTime)
|
||||
case .hsbs://3d半宽
|
||||
guard let ao = weakSelf.assetOutput else {
|
||||
return
|
||||
}
|
||||
while let nextSampleBuffer = ao.copyNextSampleBuffer() {
|
||||
}
|
||||
ao.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
|
||||
ciImg = weakSelf.videoTranserConvertor.convertVideo(asset: weakSelf.videoOriginalAsset, assetOutput: ao, type: weakSelf.selectedIndex, time: compositionTime)
|
||||
break
|
||||
|
||||
|
||||
case .parallelEyes://平行眼
|
||||
while let nextSampleBuffer = self.assetOutput!.copyNextSampleBuffer() {
|
||||
guard let ao = weakSelf.assetOutput else {
|
||||
return
|
||||
}
|
||||
while let nextSampleBuffer = ao.copyNextSampleBuffer() {
|
||||
|
||||
}
|
||||
self.assetOutput?.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
|
||||
ciImg = videoTranserConvertor.convertVideo(asset: videoOriginalAsset, assetOutput: self.assetOutput!, type: self.selectedIndex, time: compositionTime)
|
||||
}
|
||||
ao.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
|
||||
ciImg = weakSelf.videoTranserConvertor.convertVideo(asset: weakSelf.videoOriginalAsset, assetOutput: ao, type: weakSelf.selectedIndex, time: compositionTime)
|
||||
break
|
||||
|
||||
|
||||
case .monocular2D:
|
||||
case .monocular2D://双眼2d
|
||||
ciImg = request.sourceImage
|
||||
break
|
||||
|
||||
|
||||
case .redBlueSolid://红蓝立体
|
||||
while let nextSampleBuffer = self.assetOutput!.copyNextSampleBuffer() {
|
||||
}
|
||||
self.assetOutput?.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
ciImg = videoTranserConvertor.convertVideo(asset: videoOriginalAsset, assetOutput: self.assetOutput!, type: self.selectedIndex, time: compositionTime)
|
||||
guard let ao = weakSelf.assetOutput else {
|
||||
return
|
||||
}
|
||||
while let nextSampleBuffer = ao.copyNextSampleBuffer() {
|
||||
}
|
||||
ao.reset(forReadingTimeRanges:[NSValue(timeRange: tr)])
|
||||
|
||||
ciImg = weakSelf.videoTranserConvertor.convertVideo(asset: weakSelf.videoOriginalAsset, assetOutput: ao, type: weakSelf.selectedIndex, time: compositionTime)
|
||||
break
|
||||
|
||||
}
|
||||
@ -375,6 +386,7 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
func quickLoadAReader(timeRange:CMTimeRange) {
|
||||
if(assetOutput != nil){
|
||||
assetOutput?.markConfigurationAsFinal()
|
||||
assetOutput = nil
|
||||
}
|
||||
if(assetReader != nil){
|
||||
assetReader?.cancelReading()
|
||||
@ -427,6 +439,7 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
|
||||
private func checkAirPlayStatus() {
|
||||
print("设备连接变化")
|
||||
|
||||
let currentRoute = AVAudioSession.sharedInstance().currentRoute
|
||||
self.isAirPlayActive = currentRoute.outputs.contains { output in
|
||||
return output.portType == AVAudioSession.Port.HDMI ||
|
||||
@ -435,7 +448,6 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
}
|
||||
|
||||
func setttinisScreenMirroring(isScreenMirroring:Bool){
|
||||
|
||||
//已连接
|
||||
if(isScreenMirroring){
|
||||
print("已连接")
|
||||
@ -547,8 +559,8 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
}
|
||||
|
||||
//开始、结束串流的回调
|
||||
menuView.tapFooterActionBlock = {
|
||||
self.startOrEndExternalVR()
|
||||
menuView.tapFooterActionBlock = {[weak self] in
|
||||
self?.startOrEndExternalVR()
|
||||
}
|
||||
|
||||
}else if sender.tag == 203 {
|
||||
@ -580,7 +592,6 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
||||
si = selectedIndex + 4
|
||||
}
|
||||
let rsi : SpatialType = SpatialType(rawValue: si) ?? .monocular2D
|
||||
// player!.play()
|
||||
self.selectedIndex = rsi
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user