I need to implement music player using AV Player i

2019-10-17 17:08发布

I need to implement streaming music player using AV Player in SWIFT

that music file Stored in server.Please help me to any one..How to implement this one

1条回答
走好不送
2楼-- · 2019-10-17 17:49

According to this: http://www.techotopia.com/index.php/IOS_8_Video_Playback_using_AVPlayer_and_AVPlayerViewController

You could add following code in your ViewController, like viewDidLoad method or viewWillAppear, depends on the view will show repeatedly or not. If Yes, add it in the viewWillAppear method.

let player = AVPlayer(URL: url)
let playerController = AVPlayerViewController()

playerController.player = player
self.addChildViewController(playerController)
self.view.addSubview(playerController.view)
playerController.view.frame = self.view.frame

player.play()
查看更多
登录 后发表回答