I am looking to a great way to implement audio streaming using RMTP url in AVAudioPlayer. Any ways to make this possible? Or any suggestions?
Thanks
UPDATE 1: Code included
So here is the code:
let queue : dispatch_queue_t = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
dispatch_async(queue, { () -> Void in
if let songData = NSData(contentsOfURL: url) {
if let player = AVAudioPlayer(data: songData, error: nil) {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.audioPlayer = player
self.audioPlayer!.delegate = self
if let startTime = startingTime {
self.audioPlayer?.currentTime = startTime
}
self.audioPlayer!.prepareToPlay()
self.audioPlayer!.play()
self.delegate?.mmPlayerManagerDelegate_playerStartedPlaying()
})
}
}
else {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if appDelegate.bIsCurUserListener == false {
//=> Call delegate
self.delegate?.mmPlayerManagerDelegate_prepareNextSongToPlay()
}
})
}
})
And url is here:
- "rtmpLocation" : "rtmp://limelight-fmstream-42.musicnet.com/a4396/e1",
- "rtmpResource" : "mp4:/spl/114/602/883/spl_029.mp4?e=1435348059&h=8b4b2fd16683faa9bda9b4bab6d79705",