简体   繁体   中英

Audio streaming iOS from URL

I want to stream sound from URL. I used various cocoacontrols to implement it and also used AVPlayer to stream audio but all works in the same manner that they load complete audio at once and then play which takes lots of time in case of large audio files. So I want to stream my sound from URL as other online players do like other music app (Gaana or Savan).

Thanks in advance.

You can use this function to play audio file but don't forgot to import AVFoundation

   func playRemoteFile() {

       let fileUrl = "http://yourweburl/file.mp3"
       let url = NSURL(string: fileUrl)

       var myPlayer = AVPlayer(URL: url)
       myPlayer.play()
   }

Or check this link for some awesome library in github
MusicPlayer
InteractivePlayerView
bpolat-Musical Player

Or check this link Link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM