测试测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | 自定义 |
发布最新发布 | 2017年8月 |
SwiftSwift版本 | 3.0 |
SPM支持SPM | ✓ |
由Advaita Pandya维护。
一个受YouTube启发的Swift视频播放器。基于SwiftYouTubeFloatingPlayer。
![]() | ![]() |
---|
![]() |
目前YTFPlayer仅支持仅支持横竖屏的iOS应用。要实现以下代码,必须在AppDelegate中实现。
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
}
要运行示例项目,请克隆库,然后首先从示例目录中运行pod install
CocoaPods是一个Cocoa项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
使用CocoaPods将YouTubeFloatingPlayer集成到您的Xcode项目时,请在您的Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'YouTubeFloatingPlayer'
end
然后,运行以下命令
$ pod install
导入库
import YouTubeFloatingPlayer
使用YTFPlayer.initYTF()
方法以期望的属性初始化播放器。
let videoID = "f0NdOE5GTgo"
// Initiates Player with an empty details view
YTFPlayer.initYTF(with: UIView(), videoID: videoID)
// Initiates Player with a tableView with other content
YTFPlayer.initYTF(with: tableView, tableCellNibName: "VideoCell", tableCellReuseIdentifier: "videoCell", videoID: videoID)
一旦初始化,请使用YTFPlayer.showYTFView()
方法,其参数设置为期望的ViewController。
YTFPlayer.showYTFView(viewController: self)
最后,使用finishYTFView()
方法从视图中删除播放器。
// Remove Player
finishYTFView(animated: true)
Advaita Pandya,[email protected]
YouTubeFloatingPlayer可在GNU GPLv3许可证下使用。有关更多信息,请参阅LICENSE文件。