我正在使用MobileVLCKit,这是我的代码:
class CameraViewController: UIViewController,VLCMediaPlayerDelegate{
var mediaPlayer = VLCMediaPlayer()
override func viewDidLoad() {
super.viewDidLoad()
mediaPlayer.delegate = self
let url = NSURL(string: "URL HERE")
mediaPlayer.media = VLCMedia(URL: url!)
}
}
我想通过播放,暂停和计时器全屏打开VLC
谢谢,
答案 0 :(得分:0)
*我从Videolan/VLC Kit找到了一种解决方案
首先我们要安装VLC吊舱
pod 'MobileVLCKit'
var mediaPlayer: VLCMediaPlayer = VLCMediaPlayer()
func playDownload(url: URL)
{
self.movieView = UIView()
self.movieView.backgroundColor = UIColor.gray
self.movieView.frame = UIScreen.screens[0].bounds
//Add tap gesture to movieView for play/pause
let gesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.movieViewTapped(_:)))
self.movieView.addGestureRecognizer(gesture)
//Add movieView to view controller
self.view.addSubview(self.movieView)
let media = VLCMedia(url: url)
mediaPlayer.media = media
mediaPlayer.delegate = self
mediaPlayer.drawable = movieView
mediaPlayer.play()
}
@objc func movieViewTapped(_ sender: UITapGestureRecognizer) {
if mediaPlayer.isPlaying
{
mediaPlayer.pause()
let remaining = mediaPlayer.remainingTime
let time = mediaPlayer.time
print("Paused at \(time?.stringValue ?? "nil") with \(remaining?.stringValue ?? "nil") time remaining")
} else {
mediaPlayer.play()
print("Playing")
}
}
答案 1 :(得分:-3)
VLCKit不包含“全屏”功能。您需要将mediaPlayer的drawable设置为UIView,并自己处理视图处理。