I engaged into this more than two days. I couldn't get any solution please.
I have requirement is video should play Portrait inline , full screen , landscape. My problem here is how to identify the video is playing full-screen landscape or Portrait. I have implemented viewWillTransitionToSize
method. But AVPlayer
has full-screen arrow button. How I can identify user clicked that option.
The second requirement , once video complete, create view on top of video show replay or next or previous option.
This is my code;
if videoCellVal == nil {
videoCellVal = videoCell
comPlayerControl = AVPlayerViewController()
if let player = comPlayerControl {
let videoURL: String = "http://cdnapi.kaltura.com/p/11/sp/11/playManifest/entryId/"+selectedSubmission.transcodeRefId+"/format/applehttp/protocol/http/a.m3u8"
let playerItem = AVPlayerItem(URL: NSURL(string: videoURL)! )
commmentPlayer = AVPlayer(playerItem: playerItem)
player.player = commmentPlayer
player.view.frame = videoCell.frame
player.view.sizeToFit()
player.showsPlaybackControls = true
NSNotificationCenter.defaultCenter().addObserver(self, selector: "playerDidFinishPlaying:",
name: AVPlayerItemDidPlayToEndTimeNotification, object: playerItem)
videoCell.addSubview(player.view)
}
}
func playerDidFinishPlaying(note: NSNotification) {
print("Video Finished")
let DynamicView=UIView(frame: CGRectMake(100, 200, 100, 100))
DynamicView.backgroundColor=UIColor.greenColor()
DynamicView.layer.cornerRadius=25
DynamicView.layer.borderWidth=2
DynamicView.bringSubviewToFront(self.view)
self.view.addSubview(DynamicView)
}