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.
Related
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)
(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
I have a game I am making where I want that the player has no animations until it hits a certain trigger. Then I want a short animation to be played, then it will stop the animation again.
To get this effect I have the above animator state machine attached to my player, and when the player collides with the trigger it plays the Halfway animation, then it goes back to the empty state. All of this seems to work fine at first but while my player is in this empty state loop thing, I cannot move it. I am using "rb.velocity = new Vector3(stuff);" to move my player, and when I disable the animator component I can move fine. I was wondering if
There is any way to enable movement while I am in this empty state,
There is some way to get rid of the entry transition entirely so I don't have to have the empty state at all, or
Pretty much anything else that would make this work :P
If you need more information let me know, I will try and help you help me as much as I can. Thanks!
Let's say my app is running dozens of animations simultaneously and I want to pause them all as if this were a game and the user hit the pause button. What's the best way to do that? I'm using a combination of CAKeyFrameAnimations, UIView.Animate(), CABasicAniamtions, etc. Obviously I could manually stop them all when the user hits pause, and resume them from where they stopped when the user un-pauses.. But is there a better way to do this?
Edit: I want to be able to Pause & Resume via user pressing a button.
2nd Edit: I got like 90% of the way there, but I'm still having a problem...
Here's my Xamarin iOS project:
https://www.dropbox.com/s/5zbhhao6cijtb1i/Test_Pause.zip
Useful Apple reference:
https://developer.apple.com/library/ios/qa/qa1673/_index.html
I have an app that starts an position animation. When I pause it the first time, it pauses correctly. When I hit resume, it resumes correctly from right where it was paused. But when you hit pause again a 2nd time (during the same animation) it resumes at a position as if it had never paused to begin with. It pauses way ahead of where it should be. The desired result of course is to have it halt exactly where it is when you hit the pause button.
Sorry if this sounds confusing, the example project i've attached is really simple, to reproduce the problem, download my app from the link above. Run it. Make sure to Pause, Resume, then Pause again all within the same animation. Any idea what I'm doing wrong?
you can use a Boolean at the beginning of the drawing method, if the boolean is true (means no animation ) then it goes directly to the end
You can use a CAAnimationGroup, which is a subclass of CAAnimation, and manipulates its component Animations as a group (I'm not sure if they're strictly synchronized, but I think they're close enough for visual purposes).
I can now successfully pause and resume animations with CAMediaTiming, all without having to Stop the aniamtion and change the duration and start it again. See this useful resource
Class Level Variables:
UIView MyImage;
double timeSincePause = 0;
double pauseTime = 0;
Pause Function:
MyImage.Layer.Speed = 0.0f;
MyImage.Layer.TimeOffset = MyImage.Layer.ConvertTimeFromLayer(CAAnimation.CurrentMediaTime(), MyImage.Layer) - timeSincePause;
Resume Function:
pauseTime = MyImage.Layer.TimeOffset;
MyImage.Layer.Speed = 1.0f;
MyImage.Layer.TimeOffset = 0.0f;
MyImage.Layer.BeginTime = 0.0f;
timeSincePause = (MyImage.Layer.ConvertTimeFromLayer(CAAnimation.CurrentMediaTime(), MyImage.Layer) - pauseTime);
MyImage.Layer.BeginTime = timeSincePause;
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?