I am making an iOS Radio app with Swift 3! Now it is working and playing all the url address audio streaming well. But when I am in my workplace the Wifi has restrictions for Play audios streaming, so the app just works with Mobile Data.
When I click on Play button it change to Pause and does not send any sounds, It does not play and the console does not show any connectivity error or something like that. I want to know when the firewall or proxy of some WIFI network is blocking my app to send some UIAlert and change the Pause icon to Play ( if i do not do it the user will be waiting for the music).
I am using Swift 3.0 Xcode 8 , AVPlayer to play the audio. I have tried .addPeriodicTimerObserver, I have validated the url and did a lot of things but I could not get the result that I am looking for. Can some one help me?
var urlStreaming:String = "http://someurl"
playerStreaming = AVPlayer(url: URL(string: url)!)
playerLayer = AVPlayerLayer(player: playerStreaming)
playerLayer.frame = CGRect(x:0, y: 0, width:1, height: 10)
self.view.layer.addsublayer(playerLayer)
playerStreaming?.play()
My playerStreaming?.play()
is not sending me nothing when It can not play because it starts trying to play but after some seconds it stops and it does not send anything. When I using WIFI connection of my workplace it happens, but If i change it to mobile data I can listening the audio. If i play from another wifi connection for example my house, park or starbuck coffee wifi I can listening it too without problems.
I know that the Wifi connection in my workplace has restriction (blocked by firewall or proxy actually I am not sure. )for audio streaming.
I have been looking for a lot of options and I tried all of them but i had gotten the result that I am looking for.
Can you help me?