0
在我的應用程序中播放音頻直播流,延遲非常重要。我正在使用AVPlayer,但它需要5-6秒才能啓動,我需要延遲3秒。我該怎麼做才能更快開始播放並減少延遲? 設置一個小緩衝區將完成這項工作?如何使用AVPlayer進行設置?無線電流AVPlayer延遲(延遲)是高速3
這是我RadioPlayer類:
import Foundation
import AVFoundation
class RadioPlayer {
static let sharedInstance = RadioPlayer()
private var player = AVPlayer()
private var isPlaying = false
private var language: LanguageDOM?
func play() {
player.play()
isPlaying = true
}
func pause() {
player.pause()
isPlaying = false
}
func toggle() {
if isPlaying == true {
pause()
} else {
play()
}
}
func currentTimePlaying() -> CMTime {
return player.currentTime()
}
func changeLanguage(nlanguage: LanguageDOM){
self.pause()
self.language = nlanguage
player = AVPlayer(url: NSURL(string: nlanguage.url)! as URL)
self.play()
}
func currentlyPlaying() -> Bool {
return isPlaying
}
func currentLanguage() -> LanguageDOM {
return self.language!
}
func currentLanguageId() -> Int {
if self.language == nil {
return -1
}
else {
return language!.id
}
}
}
我想實現AVAudioSession,但我無法理解它 – Jason