Post

Replies

Boosts

Views

Created

AVFragmentedAssetMinder not working on iPhone device but works on simulator
Hi, We have fragmented movie data that comes through WebSecureSocket (wss://). We are writing that into a temp.mp4 and simultaneously playing the fragments that got written into the file. So, we used AVFragmentedAsset and AVFragmentedAssetMinder for this. It works as expected in the simulator. But in the device, it doesn't update the duration of the asset and doesn't post .AVAssetDurationDidChange notification. Not sure what could be the issue. Already spent 2 days figuring out this but no luck. Can someone help me on this please, This is the code. // WSS listener func onDataReceived(data:Data) { tempMovieFile.write(data) if !startedPlay { // called only at the begining startedPlay = true DispatchQueue.global().async { sleep(2) streamDelegate?.didReceivedInitialData() } } } And protocol StreamDataDelegate {   func didReceiveInitialData(); } class PlayerController: StreamDataDelegate {       static let ASSET_MINDER = AVFragmentedAssetMinder()       let player = AVPlayer()       var fragmentedAsset:AVFragmentedAsset? = nil       init(){     NotificationCenter.default.addObserver(self, selector: #selector(onVideoUpdate), name: .AVAssetDurationDidChange, object: nil)   }       func didReceiveInitialData() {     // URL --> same file where movie data is currently being written     self.fragmentedAsset = AVFragmentedAsset(url: getTemporaryMovieFile()!)     self.fragmentedAsset?.loadValuesAsynchronously(forKeys: ["duration", "containsFragments", "canContainFragments"]) {       PlayerController.ASSET_MINDER.mindingInterval = 1       PlayerController.ASSET_MINDER.addFragmentedAsset(self.fragmentedAsset!)       self.player.replaceCurrentItem(with: AVPlayerItem(asset: self.fragmentedAsset!))       self.player.play()     }   }       @objc   func onVideoUpdate() {     // This is not called in device.. but in simulator it works as expected   } }
3
1
468
Sep ’21
AVFragmentedAssetMinder not working on iPhone device but works on simulator
Hi, We have fragmented movie data that comes through WebSecureSocket (wss://). We are writing that into a temp.mp4 and simultaneously playing the fragments that got written into the file. So, we used AVFragmentedAsset and AVFragmentedAssetMinder for this. It works as expected in the simulator. But in the device, it doesn't update the duration of the asset and doesn't post .AVAssetDurationDidChange notification. Not sure what could be the issue. Already spent 2 days figuring out this but no luck. Can someone help me on this please, This is the code. // WSS listener func onDataReceived(data:Data) { tempMovieFile.write(data) if !startedPlay { // called only at the begining startedPlay = true DispatchQueue.global().async { sleep(2) streamDelegate?.didReceivedInitialData() } } } And protocol StreamDataDelegate {   func didReceiveInitialData(); } class PlayerController: StreamDataDelegate {       static let ASSET_MINDER = AVFragmentedAssetMinder()       let player = AVPlayer()       var fragmentedAsset:AVFragmentedAsset? = nil       init(){     NotificationCenter.default.addObserver(self, selector: #selector(onVideoUpdate), name: .AVAssetDurationDidChange, object: nil)   }       func didReceiveInitialData() {     // URL --> same file where movie data is currently being written     self.fragmentedAsset = AVFragmentedAsset(url: getTemporaryMovieFile()!)     self.fragmentedAsset?.loadValuesAsynchronously(forKeys: ["duration", "containsFragments", "canContainFragments"]) {       PlayerController.ASSET_MINDER.mindingInterval = 1       PlayerController.ASSET_MINDER.addFragmentedAsset(self.fragmentedAsset!)       self.player.replaceCurrentItem(with: AVPlayerItem(asset: self.fragmentedAsset!))       self.player.play()     }   }       @objc   func onVideoUpdate() {     // This is not called in device.. but in simulator it works as expected   } }
Replies
3
Boosts
1
Views
468
Activity
Sep ’21