ProjectBySwift-03-PlayLocalVideo
来源:互联网 发布:excel2007数据透视表 编辑:程序博客网 时间:2024/06/11 20:04
朋友看到我的文章说有点乱,所以我改了一下风格…
第三个Swift小练习
写这篇博客的目的:总结内容,记录学习;
【说明】:
1.该系列Swift项目联系均来自gitHub上一位大牛的贡献:https://github.com/allenwong/30DaysofSwift;
2.如果任何不对或者不适合的地方请多多指教。
项目介绍
1.【功能】
视频列表展示;点击某一视频进行播放
2.【使用】
UITableView,AVPlayerViewController,AVPlayer
3.【展示】
知识点介绍
1.【导入框架】Swift默认是导入UIkit框架的,当你需要使用其他框架下的内容,比如AVPlayerViewController,你需要import AVKit。比如AVPlayer,你需要import AVFoundation。
2.【注册自定义cell】
tableView?.register(UINib.init(nibName: "VideoCell", bundle: nil), forCellReuseIdentifier: "ZYVideoCell")
3.【绘制cell】
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "ZYVideoCell", for: indexPath) as! VideoCell cell.backImgView.image = UIImage(named: imgNameArr[indexPath.row]) return cell }
4.【获取本地视频文件并播放】
let filePath = Bundle.main.path(forResource: "emoji zone", ofType: "mp4")let videoURL = URL(fileURLWithPath: filePath!)player = AVPlayer(url: videoURL)playerVC = AVPlayerViewController()playerVC?.player = player navigationController?.pushViewController(playerVC!, animated: true)
6.【项目链接】https://github.com/codeByLemon/PlayLocalVideo
写着三个项目的感受:
1.写Swift的逻辑和OC一样,只是语法不同,你甚至可以根据OC的方法来确定并推测Swift某函数或属性的写法;
感觉OC基础还是不扎实,加油吧,菇娘。
阅读全文
1 0
- ProjectBySwift-03-PlayLocalVideo
- ProjectBySwift-01-秒表
- ProjectBySwift-02-CustomFont
- 03
- 03
- 03
- 03
- 03
- 03
- 2010-03-03
- 2010-03-03
- 10-03-03 培训
- Python 2011-03-03
- 2010-03-03
- 2011-03-03 LDAP
- 2013-03-03
- 2014/03/03
- 2015-03-03
- 01_SpringMVC流程架构图
- 最近的一些感想
- 【STL】栈适配器stack
- 一个计算机专业普通本科学生的迷茫
- 基于Socket通信的小实例(二)
- ProjectBySwift-03-PlayLocalVideo
- 超级记忆法(5)——第三小时
- 粗浅讨论内存重叠
- iframe使用总结(实战)
- Unable to query for default vendor from RPM: Error while executing process. Cannot run program "rpm"
- Unable to find 'struts.multipart.saveDir'——Struts2报错解决
- hdu1085母函数模板
- 不止于技术
- 最小割方格取数总结,及题目总结