I want to know that how i can check that AVPlayer
is not playing music when i click on play Button(player.play()
) and it currently (buffering or loading) due to slow internet connection or due to other causes, and also check when it play music after buffering.
Because i need to add UIActivityIndicatorView
on Play button. When Play button is clicked it animate till the buffering and when AVPlayer play song after buffering it stop animating and when it AVPlayer
again start buffering it again animate.
Can anyone please tell me how i can do this with simple way like this
if (player is buffering){
activityIndicator.tartAnimating()
}else if player is playing music{
activityIndicator.stopAnimating()
}
and also check again and again using NSTimer.scheduledTimerWithTimeInterval(0.05, target: self, selector: "check", userInfo: nil, repeats: true)
Or any other simple solution? Thanks.