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