Check the audio player's current playback time every 0.1 seconds - iphone

How can i use the CurrentTime property in the AVAudioPlayerto check the audioplayer's current playback time every 0.1 second. and how i can synchronize it with the views in this fashion that after 11 seconds of audiofile first view loads then second view is loaded after 23 seconds third view is loaded after 27 sec fourth view is loaded after 24 secs and fifth view is loaded after 24 secs so that is how for each view timer varies.
So that when i pause the audio views update is also paused and when it is resumed views update begins from that point where it was paused.
Thanks for the answer.

set your timers NOT to repeat and just create a new instance of the timer each time the new view loads.

Related

How to make play an animation from current frame until N seconds en Rive

I have an animation and an input, I want to play my animation N seconds from current frame every time my input change his value
I was using scrub function but that only jumps between frames, that help to has controll over the animation but it seem a little laggy

SwiftUI: Repeat animation forever with delay at the end, without autoreverse

I want to repeat an animation forever, without it to autoreverse, and with a delay/pause between the repetitions after the animation played.
I know there is a .delay() modifier, but it delays the beginning of the animation:
let ani = Animation.easeInOut.delay(1.0).repeatForever(autoreverses: false)
In addition with the .repeatForever modifier, after the animation played it immediately jumps back to its beginning. But I want the last keyframe to remain visible on the screen for a short amount of time.
I’ve also tried it the other way around, adding a .delay() after the .repeatForever modifier, but without success (delay has no effect).
let ani = Animation.easeInOut.repeatForever(autoreverses: false).delay(1.0)
How can I add a delay after the animation played?

Displaying iPhone StopWatch like time in my own application ,should consists of minutes seconds and hundrerth seconds

i have to keep iphone type of stop watch on my app..if the user touches the start button in my app..
i already developed up to seconds. such like 00:01:45
and my problem is i have to get the hundredth second i.e like 01:014:48:95 ,if it crosses the 100 number the second will increase to 1
THanks in Adv...
Set a timer. If 1 == 1 second then 0.01 == 100th of a second.
[NSTimer scheduledTimerWithInterval:0.01 ...

small delays/pause in animation

Hi all can anyone help me out with the solution to this problem...
I have a project where I have NSTimer fire about 20 times a sec and thus using only one image(loaded programatically)produces the same image on the iPhone screen about twenty times in a second and these images fall from the top of the screen to the bottom where they are removed(more or less simulating rain fall or rain droplets).
My problem is that looking at the animation, I noticed that there are very small delays and which looks like a break, pause or small vibrations. Thus the flow isn't smooth.
Can anyone help me with the solution please.
Thanks in advance
You can check the CADisplayLink class.
Just because you ask for a timer in the UI run loop to go off at a certain rate, doesn't mean you will get called at exactly that rate or at evenly spaced intervals. You should check the time and the elapsed time "dt" inside each timer callback, and change your animation position, y + dy * dt, etc., accordingly.
Timer's arn't designed to be used for animation.
The best thing to do, is to have a thread running in an infinite loop, where you check if it's time to animate again, or just always animate (giving you a higher frame rate), but using the time elapsed as a reference for the state you are drawing.
You really shouldn't be using a timer for this. Instead you should be using the built in UIView animation methods:
animateWithDuration:animations:
animateWithDuration:animations:completion:
animateWithDuration:delay:options:animations:completion:

What's the effect of setting timeOffset when animating?

The CAMediaTiming Protocol defines a timeOffset property. Now, they say it's a time offset. It sounds straightforward, but howefer, when I set it to 15.0 for example, the animation still imediately starts. The timeOffset doesn't seem to have any effect.
Maybe someone can point that out a little bit?
The timeOffest property changes the starting point of the animation to a time other than the beginning.
Lets say you have an animation with a duration of 5 seconds. Normally your animation would run from time 0 to time 5. If you set a timeOffset of 2, your animation will start out at time 2, reach time 5 and then 'wrap around' and run time 0 to time 2.
To delay the start of your animation, use the beginTime property.