简体   繁体   中英

How to send parameters with AVPlayer request in iOS swift?

I have a POST request where I have to post parameters (track_id , track_name) to url to get a mp3 file content. Now How can i get this mp3 file streaming in AVPlayer ?

I know how to stream in AVplayer with an url like :

   var player: AVPlayer?
   player = AVPlayer(URL: trackURL)
   player?.play()

But here my URL won't have any content unless I provide its required parameters (track_id , track_name). How can i set the URL with these 2 parameters?

You need to have the url path to the mp3 resource at the time of initialization. Make the POST request first and then initialize the player with the URL that you get in response.

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