添加观察者
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"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "325"
|
||||
endingLineNumber = "325"
|
||||
startingLineNumber = "340"
|
||||
endingLineNumber = "340"
|
||||
landmarkName = "viewDidAppear(_:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -627,8 +627,8 @@
|
||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "611"
|
||||
endingLineNumber = "611"
|
||||
startingLineNumber = "627"
|
||||
endingLineNumber = "627"
|
||||
landmarkName = "selectedSpatialType(selectedIndex:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
|
||||
@ -235,23 +235,38 @@ class CCSpatialVideoDisplayController: BaseController {
|
||||
await self.loadVideoAssetReader()
|
||||
DispatchQueue.main.async {
|
||||
self.configureInfo()
|
||||
// print("ccs viewdid load +++++++")
|
||||
// 检查当前是否已连接到 AirPlay 设备
|
||||
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(){
|
||||
|
||||
print("getPlayerItem ========")
|
||||
// let playerItem = self.getPlayerItem()
|
||||
|
||||
// player = AVPlayer(playerItem: playerItem)
|
||||
player = AVPlayer()
|
||||
player?.allowsExternalPlayback = true
|
||||
player?.usesExternalPlaybackWhileExternalScreenIsActive = true
|
||||
|
||||
player?.addObserver(self, forKeyPath: "status", context: nil)
|
||||
|
||||
print("getPlayerItem >>>>>>>")
|
||||
self.view.backgroundColor = UIColor(hexString: "#060507")
|
||||
@ -506,6 +521,7 @@ class CCSpatialVideoDisplayController: BaseController {
|
||||
releaseVideoComposition()
|
||||
assetReader?.cancelReading()
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
player?.removeObserver(self, forKeyPath: "status")
|
||||
}
|
||||
|
||||
func releaseVideoComposition() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user