我有两个AVPlayers,我的目标是在左声道中播放一个,在右声道中播放第二个。
我知道可以使用AVAudioPlayer轻松实现,但事实是我具有自定义的CachingPlayerItem类,可帮助播放缓存中的视频。
override func viewDidLoad() {
super.viewDidLoad()
titleLabel.text = vidTitle
let playerItem = CachingPlayerItem.init(data: tmpData, mimeType: "video/mp4", fileExtension: ".mp4")
self.player = AVPlayer(playerItem: playerItem)
self.player.automaticallyWaitsToMinimizeStalling = false
//self.player.pan = -1
let voiceUrl = getDocumentsDirectory().appendingPathComponent(voicePath)
let voiceItem = AVPlayerItem(url: voiceUrl)
self.voicePlayer = AVPlayer(playerItem: voiceItem)
self.voicePlayer.automaticallyWaitsToMinimizeStalling = false
//self.voicePlayer.pan = 1
}