添加观察者
This commit is contained in:
parent
2b27f2cbbc
commit
5377417a1e
Binary file not shown.
@ -611,8 +611,8 @@
|
|||||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
|
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "325"
|
startingLineNumber = "340"
|
||||||
endingLineNumber = "325"
|
endingLineNumber = "340"
|
||||||
landmarkName = "viewDidAppear(_:)"
|
landmarkName = "viewDidAppear(_:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -627,8 +627,8 @@
|
|||||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
|
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "611"
|
startingLineNumber = "627"
|
||||||
endingLineNumber = "611"
|
endingLineNumber = "627"
|
||||||
landmarkName = "selectedSpatialType(selectedIndex:)"
|
landmarkName = "selectedSpatialType(selectedIndex:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
|
|||||||
@ -235,23 +235,38 @@ class CCSpatialVideoDisplayController: BaseController {
|
|||||||
await self.loadVideoAssetReader()
|
await self.loadVideoAssetReader()
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.configureInfo()
|
self.configureInfo()
|
||||||
// print("ccs viewdid load +++++++")
|
|
||||||
// 检查当前是否已连接到 AirPlay 设备
|
// 检查当前是否已连接到 AirPlay 设备
|
||||||
self.checkAirPlayStatus()
|
self.checkAirPlayStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
||||||
|
print("播放状态status改变....")
|
||||||
|
if(keyPath == "status"){
|
||||||
|
guard let ce = change else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let newVa = ce[NSKeyValueChangeKey.newKey] as! AVPlayer.Status
|
||||||
|
let oldVa = ce[NSKeyValueChangeKey.oldKey] as! AVPlayer.Status
|
||||||
|
if (newVa != oldVa) {
|
||||||
|
if newVa == .readyToPlay {
|
||||||
|
player?.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func configureInfo(){
|
func configureInfo(){
|
||||||
|
|
||||||
print("getPlayerItem ========")
|
print("getPlayerItem ========")
|
||||||
// let playerItem = self.getPlayerItem()
|
|
||||||
|
|
||||||
// player = AVPlayer(playerItem: playerItem)
|
|
||||||
player = AVPlayer()
|
player = AVPlayer()
|
||||||
player?.allowsExternalPlayback = true
|
player?.allowsExternalPlayback = true
|
||||||
player?.usesExternalPlaybackWhileExternalScreenIsActive = true
|
player?.usesExternalPlaybackWhileExternalScreenIsActive = true
|
||||||
|
player?.addObserver(self, forKeyPath: "status", context: nil)
|
||||||
|
|
||||||
print("getPlayerItem >>>>>>>")
|
print("getPlayerItem >>>>>>>")
|
||||||
self.view.backgroundColor = UIColor(hexString: "#060507")
|
self.view.backgroundColor = UIColor(hexString: "#060507")
|
||||||
@ -506,6 +521,7 @@ class CCSpatialVideoDisplayController: BaseController {
|
|||||||
releaseVideoComposition()
|
releaseVideoComposition()
|
||||||
assetReader?.cancelReading()
|
assetReader?.cancelReading()
|
||||||
NotificationCenter.default.removeObserver(self)
|
NotificationCenter.default.removeObserver(self)
|
||||||
|
player?.removeObserver(self, forKeyPath: "status")
|
||||||
}
|
}
|
||||||
|
|
||||||
func releaseVideoComposition() {
|
func releaseVideoComposition() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user