我需要在SWIFT中使用AV Player来实现音乐播放器 [英] I need to implement music player using AV Player in SWIFT

查看:254
本文介绍了我需要在SWIFT中使用AV Player来实现音乐播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在SWIFT中使用AV Player来实现流音乐播放器

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

推荐答案

据此: http://www.techotopia.com/index.php/IOS_8_Video_Playback_using_AVPlayer_and_AVPlayerViewController

您可以在ViewController中添加以下代码,例如viewDidLoad方法或viewWillAppear,取决于视图是否重复显示.如果是,则将其添加到viewWillAppear方法中.

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()

这篇关于我需要在SWIFT中使用AV Player来实现音乐播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆