ios - AVPlayer & AVAudioPlayer not playing audio from URL -


i have trying play audio url. tried both avplayer , avaudioplayer none of them worked.

here url trying play.

here code using.

 // avplayer code  self.avplayeritem = avplayeritem.init(url: urlofaudio)  self.avplayer = avplayer.init(playeritem: avplayeritem)  self.avplayer.volume = 1.0  self.avplayer.play()   // avaudioplayer  if let url = url.init(string: escapecharactorstring){       {            self.playerreference = try avaudioplayer.init(contentsof: url)            guard let player = playerreference else {                 return            }                                player.volume = 1.0            player.preparetoplay()            player.numberofloops = -1                                player.play()        } catch let error {        }   } 

none of them worked me. please let me know going wrong in it.

there nothing wrong code, perfect issue related server settings audio file stored. here working code playing other mp3 file,

var avplayer:avplayer? var avplayeritem:avplayeritem?  override func viewdidload() {     super.viewdidload()  //        let urlstring = "http://www.noiseaddicts.com/samples_1w72b820/2514.mp3"         let urlstring = "https://s3.amazonaws.com/kargopolov/kukushka.mp3"         let url = nsurl(string: urlstring)         print("playing \(string(describing: url))")          avplayeritem = avplayeritem.init(url: url! url)         avplayer = avplayer.init(playeritem: avplayeritem)         avplayer?.volume = 1.0         avplayer?.play()      } 

so please try mp3 file different host solve problem


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -