Post

Replies

Boosts

Views

Activity

Reply to AVplayer currentTime() display wrong duration after seek flac online streaming song
this is the log of progress time and duration of song : log progress time and duration - https://developer.apple.com/forums/content/attachment/685ef579-70d7-4864-9dd3-a9fdb7627d31 observer that I use to update the duration and progress time: var timeObserver: Any? override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 		if let item = object as? AVPlayerItem, let keyPath = key, item == playerItem { 						 						switch keyPath { 						case "duration": 								let duration = Double(item.duration.seconds) 								 								print("Update display Duration in second: \(duration)") 								 								controller?.doUpdateDuration(duration: duration) 								self.timeObserver = player.addPeriodicTimeObserver(forInterval: interval, queue: .main, using: { time in 										 										self.playerDelegate?.updateProgresTime(time: time.seconds) 								}) 								 						default: 								break 						} 						 				} }
Nov ’20
Reply to AVplayer currentTime() display wrong duration after seek flac online streaming song
my code to handle seek process: MusicPlayer.swift func seek(timeTo: Double) { 		 		let seekTime = CMTime(seconds: timeTo, preferredTimescale: 1) 		 		isPlaying = .Seek 		player.pause() 		player.seek(to: seekTime, toleranceBefore: .zero, toleranceAfter: .positiveInfinity, completionHandler: { [weak self] result in 				self?.presenter?.checkState_Seek(state: (self?.isPlaying)!) 		}) } ViewController.Swift @IBAction func seeking(_ sender: UISlider) { 		 		let second = Float((duration / 100)) * progressBar.value 		 		MusicPlayer.sharedInstance.seek(timeTo: Double(second)) } Note: this issue happend only when seek on play streaming online with .flac format if I seek the song, it work normal if it seek on play streaming online with .mp3 and .m4a format
Nov ’20