I am using the library AudioPlayer as the Player for my app which should play an .mp3 file from a URL. The problem is that it starts playing but after a few seconds it stops and does´t continue by its own.
// I have set the Delegate on the VC
class SearchViewController: AudioPlayerDelegate{
// I have instantiated the AudioPlayer
let player = AudioPlayer()
// Set its delegate and some parameter so that it resumes in case of pause(declared in the viewDidLoad)
player.delegate = self
player.resumeAfterInterruption = true
player.resumeAfterConnectionLoss = true
// Function to check and print when stateChanges
func audioPlayer(audioPlayer: AudioPlayer, didChangeStateFrom from: AudioPlayerState, toState to: AudioPlayerState) {
print("State changed from:\(from)to\(to)")
}
// And a function to start Playing
func play(Link: String) {
let item = AudioItem(highQualitySoundURL: NSURL(string: Link))
player.playItem(item!)
}
The code above is the basic. When the player stops after a few seconds this is what the didChangeStateFrom function prints. But it never starts playing again:
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
State changed from:BufferingtoPlaying
State changed from:PlayingtoBuffering
This is the .MP3 that I´m trying to play: http://www.youtubeinmp3.com/download/get/?i=CdkH4Zt%2BKY32jhzw%2FU6WmvCKfOcHPlgM%2FwDF18DRiW37FTfLBnZGRc8Z1vd5HY28rX1G3pWVrd5p9IYX%2Fvb%2B6A%3D%3D