TRVideoView 0.1.5

TRVideoView 0.1.5

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2019年10月
SPM支持 SPM

Tim Roesner维护。



  • Tim Roesner

TRVideoView

这是一个简单的 WKWebView,用于从 YouTube 和 Vimeo 嵌入视频。

功能

  • 提供文本并返回 WKWebView
  • 检查文本中是否有链接
  • 返回不包含链接的字符串
  • 调整 WebView 大小

screen shot 2017-09-21 at 1 47 28 pm

screen shot 2017-09-21 at 1 48 26 pm

要求

  • iOS 9.0
  • Swift 3.2
  • Xcode 9

安装

CocoaPods

使用 CocoaPods 将其整合到您的 Xcode 项目中,请在您的 Podfile 中添加它。

pod 'TRVideoView'

然后,运行以下命令

$ pod install

使用方法

// Initialize  
let video = TRVideoView(text: "This is some sample text with a YouTube link https://www.youtube.com/watch?v=QPAloq5MCUA")  

// Set the frame as always
video.frame = CGRect(x: 0, y: 0, width: 300, height: 150)

// Returns true or false (checks for YouTube and Vimeo urls)
video.containsURLs()

// Returns String with out URLs (i.e. "This is some sample text with a YouTube link")
let text = video.textWithoutURLs()

// Finally add it to your view
self.view.addSubview(video)

关于链接的说明

对于 YouTube,请使用 https://youtu.be/QPAloq5MCUAhttps://www.youtube.com/watch?v=QPAloq5MCUA
对于 Vimeo,请使用 https://vimeo.com/86033976
如果链接中包含其他参数,没有关系,它们会被整理好。

贡献

想看到支持更多视频服务?您可以从创建一个问题开始,我会看看我能做什么。
如果您想分叉此项目并添加更多功能,请继续提交 PR,我很高兴看到您的贡献。