Change image source every n seconds wp7 - silverlight

I need to chage image on windows phone 7 app every 25ms. This animation should start after button pressed and play for 10 seconds. Is there any way to do it in wp7?

on the button click event you could create a timer object and start it, then on the timers tick event you check to see whether the current millisecond reading on the timer is divisible by exactly 25 (use the modulo operator) if it is you can then run the code that will change the image source property, and in the same tick event handler you can set a check for if the second reading is 10 seconds, and if it is stop the timer

Related

Calculating button press time with STM32?

I'm trying to calculate the time the button was pressed with the STM32F407 Discovery. Frequency can be any value for now. How do I calculate time?
What I am trying to do is; To enable the microcontroller to perform different operations according to different pressing times with two buttons (For example, changing the flashing times of the led). While doing this, I want to press one button for 1 second and the other button for 4 seconds (short - long press). Let the led continue its operation by not leaving the loop during the time I press it. Let it do whatever it takes when you release the button.
Help.

How to know how long the animation last and how to stop gif at the end in Maple

How do I know how long an animation lasts and how do I stop the gif at the end?
I created a GIF from export tool (Maple) but I don't know how long the animation is, or how to make GIF run in real time. I made a gif for showing how something falls down from an altitude. I need to show some figures like t(time) , h(height), v(speed) while it falls down.
Commands that generate animations in Maple often have an option that controls the default number frames. For example, the plots:-animate uses 25 frames. Moreover, animations that are shown in the Maple GUI can be controlled by the animation toolbar, which sets animations to run at 10 frames per second (fps) by default. When you use the right-click menu to export your animation to a GIF file, the exporter will take the current setting for fps into consideration and produce an animation that is 25 frames / 10 frames per second = 2.5 seconds long. Changing this value in the animation toolbar will result in shorter or longer animations accordingly.
From a couple of quick tests, exporting the animation programmatically does not respect the choice of fps, so in this case you may need to play with the number of frames in order to compensate for the default 10 fps setting.
With respect to stopping the gif, as far as I know, there is no way to control this using Maple. I believe that the only solution is to use a GIF editing program to manually turn off the 'loop' option.

SDL2 - show overlay on mouse motion and hide it some time after mouse stopped

As the title says I'm trying to accomplish an overlay menu in my SDL2 application.
I have a window where I want to show an overlay menu if the mouse starts moving and show it as long the mouse moves. If the mouse stops moving a timer should start with a specific timeout and should hide the menu after the timeout has passed.
I tried using mouse events like SDL_MOUSEMOTION, but that doesn't work. I would rather need something like "mouse motion stopped" events, where I then would start the timer.
I then thought I could combine SDL_MOUSEMOTION with SDL_GetRelativeMouseState() and compare the mouse position deltas and start the timer if the deltas are 0. But that kind of seems too complicated. Is the latter the way to go, or is there a simpler way?
There are several ways you could approach this:
SDL doesn't send 'mouse motion stopped' events but conceptually, a 'mouse motion stopped' event is a frame where you haven't received a mouse motion event. If you have a frame update loop, keep track of whether you've received a mouse motion event in the previous frame and update your menu timer accordingly.
Simply reset your menu's timer every time you receive a SDL_MouseMotion event. It's not elegant but it should work. Run the menu timer as soon as you receive the first motion event and just reset the timer each time you receive a subsequent one until it expires and you hide the menu.

Windows Phone 7 - Playing a specific portion of sound using MediaElement

I'm trying to play a specific portion of a mp3 file using MediaElement. I understand that I can use the Position property to move to a specific time in the sound and start playing from there. But I would also like to restrict the duration when it plays. For example if a given mp3 file is 30 seconds long, i would specifically like to play the sound from 5th second to 10th second and want the playing to stop.
I thought about using a separate background thread or a timer callback that will measure the time and then wakeup to stop the mediaelement. But I was wondering if the MediaElement itself supports one such a way to specify the duration of the time to play.
You can set Markers. Once a Marker is reached, the MarkerReached event is fired and you can stop the sound MediaElement there.

Silverlight - Play MediaElement at a time in a Storboard

I have a MediaElement that should be played at a certain point during a Storyboard (say 0.5 seconds in). Is it possible to kick off MediaElements at any particular point in a Storyboard? The Storyboard is set to repeat forever, so it should fire every time the marker reaches a certain time.

Resources