avplayerviewcontroller

AVPlayerViewController doesn't play local videos

て烟熏妆下的殇ゞ 提交于 2019-12-02 07:37:26
I have added a DemoVideo.mp4 in my project and added it to copy resource file. But when i run the app it doesn't play my video. Here is my method. private func setUpAndPlayVideo() { guard let videoPath = Bundle.main.path(forResource: "DemoVideo.mp4", ofType: nil) else { return } let videoURL = NSURL(string: videoPath) let player = AVPlayer(url: videoURL! as URL) playerViewController = AVPlayerViewController() playerViewController.player = player playerViewController.view.frame = self.videoPlayerView.bounds self.videoPlayerView.addSubview(playerViewController.view) playerViewController

Always show AVPlayer controls

扶醉桌前 提交于 2019-12-02 04:30:35
问题 I have an AVPlayerViewController with a AVPlayer in it, and what I need is that the controls of the player (play, pause, time slider) never hides. Right now after more or less 4 seconds of playing the video the become hidden, and you have to tap the screen to show them again. I haven't been able to find a solution to that.. any ideas? thx! 回答1: You can set that by using Key-Value Coding Swift: // playerController : AVPlayerViewController playerController.setValue(false, forKey:

Always show AVPlayer controls

自作多情 提交于 2019-12-02 01:31:24
I have an AVPlayerViewController with a AVPlayer in it, and what I need is that the controls of the player (play, pause, time slider) never hides. Right now after more or less 4 seconds of playing the video the become hidden, and you have to tap the screen to show them again. I haven't been able to find a solution to that.. any ideas? thx! You can set that by using Key-Value Coding Swift: // playerController : AVPlayerViewController playerController.setValue(false, forKey: "canHidePlaybackControls") 来源: https://stackoverflow.com/questions/39660095/always-show-avplayer-controls

AVPlayer Rotate View makes cannot tap to the screen

早过忘川 提交于 2019-12-01 05:26:23
问题 I used AVPlayer for movie player in my app. I explained the problem with diagrams. When I click Play button in movie view controller(Portrait mode),then goes to movie details view. When I tap on the screen , the navigation bar and movie player bar appear. If you tap again the screen, it will disappear. This goes well when the device is in Portrait mode. But, I changed my code to Landscape mode when I click on play button, it will automatically change to Landscape mode in movie details view.

Why this Objective-C code won't play an AVPlayerViewController video?

走远了吗. 提交于 2019-11-30 16:11:39
Both are in viewDidLoad(). What's wrong with this objective-c source file? The swift version works like a charm... Xcode ver. 8.2 iOS 10 Swift (OK): let path : String = Bundle.main.path(forResource: "charlie", ofType: "mp4")! let movieurl : URL = URL(fileURLWithPath: path) let movie : AVPlayerViewController = AVPlayerViewController() movie.view.frame = self.view.bounds let player : AVPlayer = AVPlayer(url: movieurl) movie.player = player self.view.addSubview(movie.view) player.play() Objective-C (Won't show/play the video): AVPlayerViewController* movie; AVPlayer* player; NSString *path = [

How to detect fullscreen mode using AVPlayerViewController in Swift?

偶尔善良 提交于 2019-11-29 07:57:15
I am trying to detect when the AVPlayerViewController is in full-screen mode, but I'm having a difficult time achieving this. I'd like to know when the user selects the expand button to enter full screen as shown here: I've added the appropriate observer per these suggestions: Detect Video playing full screen in Portrait or landscape How to detect fullscreen mode of AVPlayerViewController The appropriate code: var avWidth:CGFloat = 375 var avHeight:CGFloat = 300 override func viewDidLoad() { super.viewDidLoad() let path = NSBundle.mainBundle().pathForResource("cable pressback", ofType: "mp4")

iOS AVPlayer cant play 240 fps video

☆樱花仙子☆ 提交于 2019-11-28 13:13:19
I recorded a 240 fps video after changing the AVCaptureDeviceFormat. If I save that video in the photo library, the slowmo effect is there. But, If I play that file from documents directory, using an AVPlayer, I cant see the slowmo effect. Code to play the video: AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:[AVAsset assetWithURL:[NSURL fileURLWithPath:fullPath]]]; AVPlayer *feedVideoPlayer = [AVPlayer playerWithPlayerItem:playerItem]; AVPlayerViewController *playerController = [[AVPlayerViewController alloc] init]; playerController.view.frame = CGRectMake(0, 0, videoPreviewView

AVPlayer with playback controls of avplayerviewcontroller

橙三吉。 提交于 2019-11-28 09:56:18
I am putting n avplayer inside of a view controller to customize some other elements of the view controller but I still want the playback and scrubbing controls used in AVPlayerViewController. Is there a way to enable these controls for the Avplayer when I am not using AvPlayerViewcontroller? No. The usual solution (explicitly advised by Apple) is to use the AVPlayerViewController as an embedded view controller - i.e., make your view controller a custom parent view controller and the AVPlayerViewController its child, and now you can place its view (the movie and the controls) inside your view

AVPlayer UITapGestureRecognizer not working

删除回忆录丶 提交于 2019-11-28 03:25:09
问题 I have this code for my AVPlayerViewController . UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAvPlayer)]; [self.avPlayerViewController.view addGestureRecognizer:tap]; but this is not working.. :S, I tried setting [self.avPlayerViewController.view setUserInteractionEnabled:YES]; still no good.. The only working solution is to use UIGestureRecognizer and implement it's shouldReceiveTouch delegate and check if the av player is touched.. but

Play a video from Youtube in a AVPlayerViewController in Swift [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-11-28 00:13:17
This question already has an answer here: How to embed a Youtube video into my app? 6 answers Okay so I'm looking to play film trailers in my app. The user will press a button, and then it plays the video. I have added the import AVKit and import AVFoundation lines to my file. This is the code I have so far for making the video play: @IBAction func playTrailerPressed(sender: AnyObject) { let videoURL = NSURL(string: "https://youtu.be/d88APYIGkjk") let player = AVPlayer(URL: videoURL!) let playerViewController = AVPlayerViewController() playerViewController.player = player self