Setting videoCompostion of AVItemPlayer rotates video - ios

I have to apply filters on videos on playback, to do so I tried to use AVVideoComposition, Specifically this
However, when I set this composition to my playerItem the video rotates completely. By rotate I mean the width becomes the height and vice versa and so the image stretches.
How can I prevent my video from rotating ?
NOTE: When I put the app in the background by clicking on home button, and then open it again I get the correct result.

Related

How to rotate a player view like what Youtube app does

Here is my app:
Screen record
But the animation is autorotation default. It's not looking very smooth. I want my video player rotate and expend to whole screen like what Youtube iOS app does. How to do that? Any suggestion?
Actually it seems only the video player view is rotated and expanded to full screen for Youtube App. But the whole view of UIViewController is rotated in my case.

How to implement apple like camera app using AVCaptureSession?

In the iOS(9) camera app the controls overlay does not rotate but when 'Record' is selected the video is outputted with the correct orientation. Has anyone got any ideas how apple implemented this.
You've got a few different options to achieve the same effect:
You can rotate the camera, but keep the UI the same, when the device itself is rotated so that it matches UIDevice.currentDevice().orientation.
You could store the device orientation at the time of capture and then rotate the video afterwards.
You could even set the capture connection of the capture session to match the devices orientation while keeping the preview connection the same. Check this out for a similar question
I implemented exactly what you're looking for using 2 different UIWindow instances, one for the video preview layer and one for the UI to be displayed on top of it. The UIWindow with the UI needs to have a transparent background in order for the preview layer to remain visible.

Youtube video in a UIWebView with small frame

In my app I'm supposed to make a menu where users can play a video from a list. The list is presented in a horizontal UIScrollView and I have a frame of 120x80 (in points, in pixels it's 240:160 on retina). The links for videos are either youtube urls or addresses of .m3u8 files on our server (I put them in a simple html from apple's http live streaming documentation).
My problem is with the youtube urls. These pages opened in UIWebView always have a bar on top that limits the tappable surface to half. Also when I play the video for first time another bar shows up (for like, dislike and things like that), which limits the space that will launch the video on tap to 0.
My goal here is to have the videos represented by images (UIImageViews) with buttons on top of them in shape of the "Play" triangle. When I press that UIButton, the video should show, as normal, inside an MPMovieController.
So I need 1 of 2 things:
Have the UIWebView show just the video of the youtube page, without the bars.
Make the youtube video show inside an MPMovieController after user taps a UIButton.
Any tips on how to do either of these?
Yes you can do like this and you need use set property on UIWebView.look this example
here

How can I force a video played in a UIWebView to be full screen on an iPad?

I'm playing a YouTube video using a UIWebView, like so:
self.webView.mediaPlaybackRequiresUserAction = NO;
self.webView.allowsInlineMediaPlayback = NO;
[self.webView loadHTMLString:videoEmbedCode baseURL:nil];
I want to force the video to play in full screen without the user tapping the button at the bottom right. This works fine on an iPhone (tap the player to play and it automatically enters full screen), but doesn't work on an iPad (the normal inline player is shown).
I assumed that setting allowsInlineMediaPlayback to NO would do the trick, but apparently not.
Is there a way to force HTML5 videos to play in full screen on an iPad?
If you are trying to play a youtube video in fullscreen directly, then Use a webview of size fullScreen and then handle its rotation accordingly and change the player size of Rotation too. If you need more help then i can help you with the code too for how to change the player size on rotation too.

Show video when first frame is loaded (no black screen)

I need to find a way to display the view of a MPMoviePlayerController after the first frame of the video is cached.
My App shows the first frame of the video as a png and I want the video then to be shown without the screen going black for a second. How can I do that?
Display that image as a view-overlay on top of your MPMoviePlayerController by adding it as a subview of MPMoviePlayerController.view.
Once the video has started the playback (use the MPMoviePlayerPlaybackStateDidChangeNotification to react upon that), hide / remove your overlay.

Resources