Is it possible to control an animation or better a video via swiping over it?
I have:
an animation as video (~2sec playtime, can be converted to other file types if needed, but shouldn't be too big)
iOS >= 6.0
I want:
show the first frame of the animation
play the animation back and forward if the user moves his finger tip over the control with a speed, corresponding to the speed of the finger tip.
I'm experimenting with MPMoviePlayerController currently. Are there better Controls? Do you have any suggestions to solve this problem?
Related
Is where a way to smoothly seek playback to some position?
In other words, imagine that some track playing at 0:53 and I need it to play at 0:58 after 2 seconds. So I need it to smoothly increase rate (like using easing functions in animation) and smoothly decrease rate when playback time almost equal 0:58. (it should sound like rewind effect)
Simple seekToTime method is not an option since it just jumps to position.
Here is an illustration:
two________________________seconds_________________________to_seek
0:53__________________________________________________________0:58
|____________↑_________|__________=_________|__________↓__________|
rate=1______smoothly_rate=2.0_______________smoothly_rate=1_____rate=1
I've already tried to use easing methods to smoothly increase rate but looks like it's impossible - rate value changes right away to desired value without easing.
At least I know that it is actually possible. You can try Ampme app from Appstore. They're playing music synchronously on different devices and if there is some lag (buffering, etc) on one of the devices, it's playback smoothly corrects to right value without jumping.
Currently I'm using setRate:time:atHostTime: method and I think it's the right way, but I'm not able to make it work seeking smoothly.
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.
I have to make an animated infographic in iOS. Its consists of about 140 images all 900x700 large. Whats the best approach to do this? I tried CALayerwith indivual images, and also a spritesheet. But it just takes way too long to load and the playback is awful. I also have the animation in a video file, but it needs to be added to a view in a set frame and not be played in full screen.
Try and play the animation video using MPMoviePlayerController. You can play it in a view with custom frame. You can refer the link for sample code too.
I'm trying to build a drum simulator in Xcode for an app for my brother in laws band. I'm having a little trouble doing this. What I'm wanting to do is use a picture of the drummer's drum set and use that as the drum you can play on the iPhone. I was thinking it could kind of be like an image map in HTML where the buttons would play a sound of the drum and everything else. If anyone has any ideas or how-tos on this it would be greatly appreciated.
Thanks
A very basic approach:
Use a UIImageView with an image of the drumkit as background.
Create a transparent UIView in front of each drum. Attach a UITapGestureRecognizer to each UIView. This gesture recognizer should call a different method for each view. Use AVAudioPlayer to play the sound.
That's just a very basic app but not so bad. After you've done with that your next tasks could be:
optimize performance. Sound should play in the moment you touch the display.
multitouch
use core motion to detect the strength of your tap and adjust the sound
A UIImageView with some nice invisible buttons (UIButton's tintColor property as in button.tintColor = [UIColor clearColor];) over the skins would be perfect. Then, take a look at how to play some audio over here: http://blogs.x2line.com/al/archive/2011/05/19/3831.aspx
I've written custom control which allows the user to change the currentPlaybackTime of a MPMoviePlayerController by clicking or dragging on a custom UIButton that displays an image of some musical notation. The code uses the x position of the touch event to update currentPlaybackTime and it all works fine. I also have a CALayer (a vertical red line) that shows the user where they have touched on the control.
What I'd like to do now is have the red line's (CALayer object) position update if the user changes the currentPlaybackTime property of the movie player using the scrubber (slider) control.
Obviously currentPlaybackTime is always updating as the movie plays, but is there a way to detect if the user interferes with this by skipping forward or backwards?
Many thanks.
You could use Key-Value-Observing to track changes of currentPlaybackTime in your MPMoviePlayerController, but that might generate a lot of events and thus negatively affect your performance. Maybe you can also use KVO with the playbackState property of your MPMoviePlayerController, I believe it changes when the user starts seeking.
Another alternative is that you just setup a repeating timer that updates quite frequently, and everytime it fires you check the new value of currentPlaybackTime. But that might look choppy and it could also affect performance.