AudioPlayer库停止播放流.mp3

时间:2016-09-19 13:25:29

标签: ios swift avplayer audio-player

我正在使用库AudioPlayer作为我的应用的播放器,它应该从URL播放.mp3文件。问题是它开始播放,但几秒后就会停止播放并且不会继续播放。

// 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!)
    }

上面的代码是基本的。当玩家在几秒钟后停止时,这就是didChangeStateFrom函数打印的内容。但它永远不会再次开始播放:

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

这是我尝试播放的.MP3:http://www.youtubeinmp3.com/download/get/?i=CdkH4Zt%2BKY32jhzw%2FU6WmvCKfOcHPlgM%2FwDF18DRiW37FTfLBnZGRc8Z1vd5HY28rX1G3pWVrd5p9IYX%2Fvb%2B6A%3D%3D

0 个答案:

没有答案