UWP Application with video playback - c#

How can I get the time of video playback in UWP C# Application?
I'm using Media Element and I have video playback in my app after I choose it from the file. I can pause it and start it again, but I don't know how can I get the real time of this video, when it's playing.

For retrieve current position of duration look at the MediaElement.Position property.
The amount of time since the beginning of the media. The default is a TimeSpan with value 0:0:0
If you want to know the playback duration you can use MediaElement.NaturalDuration property:
The natural duration of the media. The default value is a Duration structure that evaluates as Automatic, which is the value held if you query this property before MediaOpened.

You can bind on Position property of MediaLement like this:
<MediaElement x:Name="MediaElement1"/>
<TextBlock Text="{Binding Position, ElementName=MediaElement1}"/>

Related

How to refresh animation state in unity to know what animation is playing

Ok so, I did this:
print(Anim.GetCurrentAnimatorStateInfo(0).shortNameHash);
When I play an animation like so
Anim.Play("AnimationName");
The value printed changes and then stays the same and doesn't change back to the default animation.
I also tried with the following:
if (Anim.GetCurrentAnimatorStateInfo(0).IsName("FireAnimation"))
I want to be able to get a constant update on the current animation that is playing. If you have any method that doesn't involve using a clock please do help.
I realized the best way to do this is to use the animation controller and change varialbes using SetBool(); and SetFloat(); etc.

Current value of an animating property of a UWP Composition visual?

I have a SpriteVisual for which I'm animating opacity, offset, and size using KeyFrameAnimations. While the animation is running the property values seem to be unaffected: they show the initial values until the animation finishes, at which point they update to the final values.
I would like to be able to get the current value part-way through the animation without having to either stop the animation to synchronise the properties or to store a separate copy of the animation and the time it started in order to calculate the value myself.
Is this possible?
As far as I known, it is impossible.
When we use the StartAnimation method of the SpriteVisual class to add the KeyFrameAnimation to it and start the animation, that there is no method to get the current value.
We can use the KeyFrameAnimation and the SpriteVisual to change the value of the property during the animation.There is an ForegroundFocusEffects sample that you can refer it, it uses the ScalarKeyFrameAnimation and set the Duration of the animation.

Silverlight media element not showing buffering state after increase play rate

I am using silverlight plugin for playing media files.
I am taking Play rate control for increase/decrease media play rate speed.
There is on pop up with progress bar which is shown when media element is in buffering mode.
This is code for checking media is buffering mode.
if(_myMediaElement.CurrentState == MediaElementState.Buffering)
{
//Show pop_up for with buffering progress bar
}
Issue : when I increase play rate using play rate slider control and than increase media position by reset media element with new time span position than media element goes buffering mode. but _myMediaElement.CurrentState is always showing playing mode. therefore unable to showing pop_up for with buffering progress bar.
Code for changing play rate
_myMediaElement.PlaybackRate = _playRateSliderControl.Value; // it can be 0.5, 1.0, 1.5
Code for increase media position
_myMediaElement.Position = new TimeSpan(0, 0, newPosition);
Any help is appreciate
Thanks
I have fixed it.
when I increase playrate from 1.0 than if media element is in buffering process that time I have assign
playrate = 1.0 and take in another variable of increase playrate value. and than when buffering is completed and media element player played the stream than reset playrate by increase value.

track bar in media file using DirectShow lib in c#

i want to use a track bar in a window form which opens a media file as the video or audio plays i want to move the slider of the track bar accordingly . I had set all the properties of the track bar tool like maximun,minimun, tickfreguency small and large change accordingly.
using mediaposition i collect the currentPosition of the media and total duration using get_duration() method and sets the trackbar value to the current position but the problem is as the media is running the slider of the bar is not moving . i know i am missing something in the code .
Make sure you actually update that information in LOOP. So it would be updated, for example, in timer. Every 1 second.
You can also check what values you get from those two calls(get_duration and get_position) using debugger.

Can I set the frames per second of a MediaElement in C#?

I have a media element that normally plays videos fine, but some videos with high framerates(120) play at the wrong speed. I assume it is something to do with the video not having the right information in the header, and am looking into setting it manually.
Is there a good way to set the Frames Per Second of a MediaElement?
Because there are no methods or variables in the Media Element to get or set the frame rate, the only viable solution I found was to have a text area that set a frame rate multiplier. This multiplier can then be applied to the SpeedRatio of the Media Element, as well as anywhere else where events dependent on the video time are determined.

Categories

Resources