json - swift play list play selected song -


i can't find way online explains how play song when select item in tableview. have external urls loaded in array called track_url.

i know need in tableview function didselectrowatindexpath. can't figure out how set url avplayer when click on cell.

can 1 share code me can url load in avplayer. can find stuff rhat pars , uses pfobect. have appended var. came json done swiftyjason.

i hope 1 can give me suction/example can understand this. new swift.

thanks

according apple's qa, cannot stream audio avaudioplayer:

the avaudioplayer class not provide support streaming audio based on http url's. url used initwithcontentsofurl: must file url (file://). is, local path.

fortunately, same qa says can stream avplayer:

import avfoundation var player: avplayer?  func playsong(url: nsurl) {     let asset = avurlasset(url: url)     let playeritem = avplayeritem(asset: asset)     player = avplayer(playeritem: playeritem)     player?.play() } 

to try out ios 9, should (temporarily) add nsapptransportsecurity dictionary nsallowsarbitraryloads boolean key info.plist.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -