Embedded Windows Media Player Set Position is slow - c#

So, I have an AxWindowsMediaPlayer control on my form, and I'm looking to, while its playing, change the playback position to another point. I found:
mediaplayer.Ctlcontrols.currentPosition = <position in seconds>
But If I call that whilst its playing, it does jump to the right position and claims to keep playing, but in reality the video stops playing.
I've tried pausing/stopping before I change the position and playing afterwards, but no luck.
How can I get around this?
UPDATE
So, if I wait long enough, playback will resume again, but it will be a few seconds after the point I told it to jump to.
For example, if I tell it to jump to 15 seconds while its playing, it will jump to 15, Ctlcontrols.currentPosition will continue to increment, but the video won't actually start playing again until about five seconds later.
So... why isn't there a five second delay when I load the file? It plays instantaneously when I load it in... And how do I get rid of the delay after the jump?

Related

Prohibit WindowsMediaPlayer wmmpsMediaEnded event

I have C# program in which I use WMPLib WindowsMediaPlayer. When playing goes to an end, it goes to these states:
wmppsMediaEnded --> wmppsTransitioning --> wmppsStopped.
By going to this chain of states, WindowsMediaPlayer.controls.currentPosition sets to 0;
So when player goes to an end, it stops playing and when I click play button, it starts playing from the start again.
I want player not to go into wmppsMediaEnded state and therefore not to start from beginning afterwards.
Is it possible?
I expected that WindowsMediaPlayer should have property, that prohibits to go to the wmppsMediaEnded state when playing ends, but it does not.
I was able to solve the problem. When player goes into wmppsStopped state, I set WindowsMediaPlayer.controls.currentPosition = WmpInstance.currentMedia.duration;
So when playing is finished, player position stays at the end, even though it goes into stopped state.

Particle Effect keeps playing(turned off looping and switched stop action to destroy)

I am trying to create a deatheffect for enemies. I instantiate the particle system when they are killed. After that the particle system plays but keeps playing, But I only want it to play ones and then stop playing.
I turned of looping and set stop action to "destroy".
It might have some sub-emmiters or the object may have particles in children. What you need to do is to Destroy(gameObject) when not needed.

After animation in an animation layer is done playing the character remains in the last position of said animation

DESCRIPTION
I am learning to use Animation Layers. I created one with a mask so only the torso and head are affected. It has an empty state so that the animation isn't played first thing automatically, which transitions to a torso hit animation when a trigger is activated. The animation is set to Additive with weight of 1 as I want the the animation to be played with all of its intensity.
The animation works beautifully and when my character is shot in the torso it seemingly winces from the pain by bending its torso down while continuing to run or do stuff.
PROBLEM
After the animation is completed, the character remains with its torso bent down and continues running/doing stuff in that position instead of simply assuming the position of whichever animation is playing in the Base layer.
WHAT I TRIED
Fiddling with all of the settings visible in the image below, including "has exit time" and "interruption source", creating a transition back to the empty state and googling. Unfortunately, this is the full extent of my knowledge.
SETTINGS
QUESTION
How can I have the character revert back to the position of whichever animation is playing in the Base layer after the hit animation is played?
You don't have any transition back from Torso hit to New State.
Try adding one with
has exit time = true
exit time = 1
Like this (might want to adjust the duration of course)

How to play animation just once whenever i shoot a bullet ( flash animation)

(check image) Hi! I actually have two questions,
THE FIRST ONE: I have two flash animations that I want to play in front of the tank's turret whenever I shoot a bullet (I have different weapons with different fire delays, machine gun, bombs..) so how can I play that flash animation to work in with the fire delay of a gun ? (note that if I uncheck loop time, the animation stops in the last sprite + I don't know how to replay it).
SECOND QUESTION: I want simply to animate my turret when I shoot I just want it to go back a little and return, you know what I mean, only in unity, how, please?
give me just the idea of working and I'll do my research :) thank you!
I have tried to enable my animation when I shoot and uncheck the loop time, but the animation stops at the last animation sprite and I don't know how to replay it.
Using Unity's built in animator, I'm assuming you are using this, you need to have at least have 2 states, in your case Idle and Fire. You would then set the transitions of the animations to go from one another, Fire -> Idle and Idle -> Fire.
Within the Idle-> Fire you will need add a trigger due to it only happening once.
You may also need 2 SpriteRenderer Components to allow for the display of the Shot effect, just make a child GameObject with it and edit it in the Animation Window.
Triggers reset as soon as the transition has been made.
If you do not have a trigger go to the parameter tab and click the '+' button which will allow you to create a new trigger. Now that that is created, in your code whenever you want your tank / boat to fire just add. referenceToAnimator.SetTrigger ("triggerName");
Bringing up your delay you could always add an additional wait state that mirrors the idle state but only runs for the selected amount of time. Your new Animator would look like.
Idle -> Trigger -> Wait -> Fire -> Idle

Set position in mediaElement (ScrubbingEnabled alternative in WP8.1)

I am trying to set position of video while video is paused.
In WPF it is simple with ScrubbingEnabled
property.
But there is nothing like this for windows phone.
So I use:
_mediaElement.Play();
_mediaElement.Position += new TimeSpan(0,0,0,0,50);//move video 50 milisecond forward
_mediaElement.Pause();
It is "working", but when I am trying to go (about)5 miliseconds back, it is moving forward and it is not clear solution...
How can I replace ScrubbingEnabled property on windows phone?
Edit
Code for 5ms back:
_mediaElement.Play();
_mediaElement.Position -= new TimeSpan(0,0,0,0,5);
_mediaElement.Pause();
Even assuming that your video is running at 60 frames per second, there's only one frame every 16.67 ms. So to move 5 ms should probably do nothing in many cases.
That would also explain why when you ask it to move 50 ms, it doesn't move by that exact amount, but rather goes to the time of the closest frame.
(if you move position by only a few frames, due to how digital video compression works it might not work as you expect either)
Ok. This is not exactly the answer, but today WP8.1 is obsolete and setting position with mediaElement on Windows 10 work pretty fine without Play-Pause hack.
So:
_mediaElement.Position -= new TimeSpan(0,0,0,0,33);
is moving video 1 frame back (30 FPS video), and
_mediaElement.Position -= new TimeSpan(0,0,0,0,5);
is not moving anywhere.
One interesting thing:
To move 1 frame you need to change position at least one half of frame time.
_mediaElement.Position -= new TimeSpan(0,0,0,0,16);//not moving
_mediaElement.Position -= new TimeSpan(0,0,0,0,17);//moving every 2nd "click"
Frame time for 30 FPS video is 1000/30 = 33.333 ms

Categories