I have a uiview that contains avplayer asset. I want to control the way of how the video is played.
Moving forward is grate and run smoothly, but when I'm trying to play it on backwards with rate= -1 the video is jumpy and choppy..
Is there better practice of running video inside uiview on backwards?
Related
I am working on a kids ABC learning app which will be somewhat like this app.
Petting Zoo
The user can do these gestures... Swipe UP, DOWN, LEFT , RIGHT and TOUCH and each gesture has a small animation clip (approx duration 1 -3 secs each ) linked to it like the character jumping on Swipe UP, etc. There will also be an IDLE loopable movie which will be playing continuously when there is no input from user.
So I am trying to use videos in MP4 and M4V format for these gestures but the problem is that the videos are lagging just before playing. Means they dont play instantly upon doing a gesture but take a time of say micro second to load and play.
I am looking for output like the video above. You can see that the animations are so responsive and do not hang even for little time.
My developer once achieved such smooth output with the MP4 video clips but those clips didnt have audio embedded in them and then when he used videos with audio embedded in them, they were lagging again.
Can audio be the issue for lag here ? Or anything else you experts will like to suggest.
Please help guys. Yours inputs will be very valuable for me.
You can use - (void)replaceCurrentItemWithPlayerItem:(AVPlayerItem *)item of AVPlayer.
This methods helps you to load the new item to an existing AVPlayer.
Here is the important reference for playing multiple videos using single AVPlayer.
When I load a web page into a UIWebView (even a www.youtube.com page) that contains an embedded youtube video, it plays just fine for IOS7 or IOS8. But when I switch to WKWebView (IOS8) and load the same web page, the youtube video doesn't play at all on the first click, then plays for a second or two on subsequent play clicks (on the youtube player). Like it is running out of buffer space and pausing until I hit play again only to play for another second.
From Safari this (or any other) youtube video plays from start to finish on the same LAN. Likewise, as I mentioned earlier, UIWebView has no problem inside of IOS7 or IOS8. So it is not a problem with my wireless data thru put or connection.
Is there something I need to do to keep the player going? Maybe increase the streaming video buffer space for WKWebViews?
OK I figured out why this is happening and also why no one else was affected by it. WKWebView and indeed IOS 8 handles several things that are not deprecated yet act differently in IOS 8. And this is one.
My app samples audio from the microphone in real time. This was fine in prior versions of IOS, but apparently in IOS 8 when a WKWebView starts a video stream, the audio sample can kill it (god only knows precisely why).
However, I need to be able to sample audio with WKWebView but I don't necessarily need to do it when a video is playing. So the challenge will be to figure out when the user has clicked on a youtube or vimeo or apparently any other streaming video and pause my audio sampler while the video is streaming. At the moment I don't know how to do that.
I also discovered another difference between IOS8 and prior when using UIView animations. prior to IOS 8 you could animate a swap between images in the UIWebView and the animation was persistent only as long as you set the duration AND you didn't have to enable animations.
[UIView beginAnimations:#"fade1" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationsEnabled:YES];
[UIView commitAnimations];
Now in IOS8, apparently you have to set a listener and disable animations after it finishes, otherwise your UIView animation is applied to all sorts of unexpected, and even native, behaviors. Like finger scrolling a native list or when the user vertically scrolls a web page in the UIWebView. Disable the animations and these strange affects on other objects disappear.
[UIView setAnimationsEnabled:NO];
And now I am totally confused about what the commit does. It doesn't seem to be needed in IOS 8 anymore.
To know when the video is playing, you can try this solution from Paulo Fierro.
Anyone know how to add the auto playing video background in iOS? I am guessing its actually images? But the video lasts for 15 seconds so if its images then at 24fps minimum that is a lot of images.
I tried using the UIImageView swapping of images, but it seems like a hack way to do this.
See Uber's app and I think Airbnb has it also.
You can make them images as you guessed, or play video using either MPMoviePlayerController or AvPlayer. Just add any as a subview to your view and make it play at viewWillAppear. I used AvPlayer as the app home screen background before and it worked perfectly.
I have been successfully running the example, Creating a Video Application: http://www.samsungdforum.com/Guide/tut00055/index.html
What I am trying to figure out is how I can smoothly transition from one video to another using a cross fade or any other transition. In this example you are forced to call stop on the player before loading up another video causing a black flash in between.
I've tried going down the path of creating two Video instance one behind eachother and using JQuery to fade out/fade in but I am having a lot of trouble. it appears jquery fades don't even apply to the video element. Also, Is there some kind of limitation with playing two videos at the same time? Is there a better way to go about this? Would it be better to look into doing this using WebGl instead?
Thanks!
If you use Samsung API you can play only one video at time. I can't find documentation page at the moment.
You can try different approaches:
use html5 <video> tag, maybe browser will be capable of playing 2
of them.
use screenshot from second video, and fadeOut it over video
before stopping first video and starting next.
you can recode your videos in 1 continious video in any video editing software. If you need to switch between videos, you can jump to position of next video start.
I wanna merge animation and dynamic video i.e video recording taken using camera and also the animation must be shown in the screen when the video is taken . How to do this i simply have no idea from where to start. I have seen video given in the below mentioned site :
http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos
but here in the above case animation is added at to an existing video but i want to add animation at runtime while the video is recorded and the video should have the animation recorded in it. Hope to get a lead so that i can get started to it..