Reputation: 1459
I want to add button fullscreen in top of VLC video player. I try this code but it's not working:
class VideoScreen: UIViewController{
@IBOutlet weak var playerView: UIView!
@IBOutlet weak var indicator: UIActivityIndicatorView!
@IBOutlet weak var btnFullSrc: UIButton!
@IBOutlet weak var playerViewHeight: NSLayoutConstraint!
var b : Bool = false;
let player: VLCMediaPlayer = {
let p = VLCMediaPlayer(options: ["--extraintf="])
return p!
}();
override func viewDidLoad() {
title = "Xem camera"
self.initPlayer()
}
override func viewDidDisappear(_ animated: Bool) {
player.stop()
}
func initPlayer() {
let streamUrl = URL(string: rstpFactoryUrl)
let media = VLCMedia(url: streamUrl)
player.media = media
player.delegate = self
player.drawable = playerView
player.play()
(player.drawable as! UIView).bringSubview(toFront: btnFullSrc)
}
}
Here is my storyboard UI:
When video is running the 'btnFullSrc' is hidden likely the video frame always on top. Any help here thanks you
UPDATE: I change code to
self.view.bringSubview(toFront: btnFullSrc)
but still not working
Upvotes: 1
Views: 1918
Reputation: 1831
Your button is a subview of the video view. This is not supported by VLCKit. You need to have the button at the same hierarchy level or above to have it displayed on top of the video.
Upvotes: 3
Reputation: 5797
Your current is bringing the VLC screen to the front. If you want to bring the button to the front, you should do this:
self.view.bringSubview(toFront: btnFullSrc)
or do this:
playerView.bringSubview(toFront: btnFullSrc)
Upvotes: 0