I have a UIView that adds a subview on top of it when plays videos, I now want to have elements on top of that Subview that displays a full name and a profile image. I am receiving the data but I think that the subview which displays the video hides the elements on top of it. This is my storyboard below, the black screen below is my UIView which the video is displayed on and I obviously have the full name, time and a UIImage element on top but can not see it. My constraints are good too. This is my code.
class BookViewC: UIViewController {
var timeLineModel = TimeLineModel()
var streamsModel = streamModel()
@IBOutlet weak var Profile_Image: UIImageView!
@IBOutlet weak var VideoView: UIView!
@IBOutlet weak var FullName: UIButton!
@IBOutlet weak var Time: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
FullName.setTitle("John Higgins", for: .normal)
Time.text = "2:30 pm"
PlayVideo(MediaHeight: 400.0, MediaURL: "URL")
Profile_Image.layer.cornerRadius = Profile_Image.frame.height / 2
Profile_Image.clipsToBounds = true
}
func PlayVideo(MediaHeight: Float, MediaURL: String) {
let movieURL = URL(string: MediaURL)
streamsModel.playerView = AVPlayer(url: movieURL!)
streamsModel.MyAVPlayer.player = streamsModel.playerView
streamsModel.MyAVPlayer.videoGravity = AVLayerVideoGravity.resizeAspectFill.rawValue
streamsModel.MyAVPlayer.showsPlaybackControls = false
streamsModel.MyAVPlayer.view.frame = VideoView.bounds
// If comment out the line below the elements show but not the video
VideoView.addSubview(streamsModel.MyAVPlayer.view)
self.addChildViewController(streamsModel.MyAVPlayer)
streamsModel.playerView?.isMuted = false
streamsModel.MyAVPlayer.player?.play()
}
}
I believe the issue is with this line VideoView.addSubview(streamsModel.MyAVPlayer.view) if I comment out that line then the video does not show but you can hear it then the elements of full name, time and profile image are visible. Is it possible to add these elements on top of the SubView? since I have seen some other apps doing that?