How to get current frame? - c#

I would like to send to another app current frame (number). Is it possible to access it in axWindowsMediaPlayer control?

I didn't see anything about this on axWindowsMediaPlayer control.
But you can use FrameGrabber project to extract frames from a movie.
FrameGrabber is an open-source library written in c# and it is easy to use.
Hope this helps.

This may be an old thread, but I feel like the question did not properly get answered. This may not be the "frame number" but it does give you a "position" of the video that you could pass. I am using it to sync two videos.
This is for a media player that has already been added to a VB form called AxWindowsMediaPlayer1. I am sure something similar can be called in C#
Dim position As Double
position = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition

Related

Synchronous sound playback from video source in VideoSourcePlayer control

I'm using the Video Source Player control from AForge.Controls to play a few video clips within a winforms application.
The code is something like this.
string fileName = #"C:\path\to\file.example";
videoSourcePlayer.VideoSource = new AForge.Video.AsyncVideoSource(new FileVideoSource(fileName), true);
videoSourcePlayer.Start();
The video file includes both audio and video streams, however as far I'm aware the control only handles video and not audio.
How can I then play the audio stream in a synchronous fashion with the video source player control?
Thank you.
EDIT:
The Video Source Player control has a event named NewFrame, which allows to determine the precise video position which could be useful to keep the audio being played synchronized with the video.
Since you mentioned:
I'm only looking for other alternative in which is possible to
reproduce the audio contained the video file and somehow keep it
synchronized with the video player control...
Maybe you can have a better luck by using a ElementHost and using WPF media control.
If this solution is eligible for you follow this steps:
Create a new WPF UserControl and add to your WindowsForms app.
In this UserControl add a media element and configure the way you want.
Build the solution.
Now in the toolbox must appear YourSolutionName Controls and you controls must be there.
Just drag it to your WindowsForms app and it must create an ElementHost.
I've created the UserControl as follow:
<MediaElement Name="VideoMediaElement"
Source="Media/Wildlife.wmv"
LoadedBehavior="Manual"/>
Just remember in this example this file must be side-by-side with your app in a Media folder. If you miss this step it will give you the strange and not helpful error 0xC00D11B1.
The loaded behavior Manual will give you the chance to control de video more freely.
After that you can do whathever you want in this UserControl like create Play and Pause:
internal void Play()
{
this.VideoMediaElement.Play();
}
And to access them in WindowsForms do this:
private void WindowsFormsButton_Click(object sender, EventArgs e)
{
var videoControl = this.MyElementHost.Child as VideoUserControl;
videoControl.Pause();
}
Hope this helps. WPF MediaElement is much more easy to seach for than other libs.

Inserting time delay between processes in C#

I am new to C# programming. I am trying to create a memory game which displays random numbers in a matrix in windows form at first. After some time I have to clear the cells and display options for answers on the left panel of screen. Could any one help me how to pause the matrix in form for a while before matrix blanks? I used text boxes to display matrix.
Also, Is there any standard code for matrix format display in C#?
Please help me..
In a Windows Forms project you should use a Timer to create an event after a certain amount of time.
You should not use Thread.Sleep because this will make your GUI freeze.
I'm not too clued up on C# myself but perhaps something like this is what you're looking for?
System.Threading.Thread.Sleep(3000);
this.Refresh();
Worth a try...

Animate a sprite by using two images

I would have thought this was a common desire, but I'll be damned if I can find this.
I simply want to Animate an image by swapping two images back and forth. I tried StoryBoard, but apparently you can't change the source in a storyboard. The only answer I can come up with is a Timer, which I don't think is the best way.
Edit: How do I animate image content in WPF? Came up in the "Similiar Questions" window. And while this will do what I want, it is "hackish" as the OP of it says, and it only swaps two images, what if I wanted a whole sequence of 10 or 20 or 100.
I found another post here on SO whose answer sounds like it could solve your problem: Change an image during animation using storyboard
The problem with this approach is that it also doesn't satify your request for supporting an arbitrary number of images.
I was going to propose a different method that involves databinding the Image Source to the image path, and then in code behind simply changing the path, but I haven't gotten it to work yet.
Here's an article that seems to have an elegant way to handle your requirements: http://www.codeproject.com/Articles/364529/Animation-using-Storyboards-in-WPF
Hopefully that will work for you.

wpf custom control: audiowaveform rectangle with selection slider

I'm working on a c# wpf app in which I want to do something with audio. the irrklang audio library provides me with a pcm decoded 16 bit byte array.
I want to create a timeline control which shows the waveform along the timeline with an overlaying rectangle which the user can drag and click/drag the left and right side to increase or decrease the selection.
It is used to the trim the audio track. I would like the selected min and max to be databindable, the minimum and maximum value of the total track to be bindable.
To clarify here is an image mockup:
I'm not asking for a complete control but tips and suggestions on how to tackle this are more than welcome. Perhaps solutions like this already exist but so far I haven't been able to find it.
I think I need to tackle: the control (zooming, panning and changing the selection) and drawing the waveform in the control
Thanks in advance,
I think you should check out this codeplex project
http://wpfsvl.codeplex.com/
Refer to Audio WaveForm Drawing Using WPF.
Something based upon WaveFileTrimmerControl.xaml would be useful, it uses related controls PolygonWaveFormControl.xaml & RangeSelectionControl.xaml (links are to the XAML but refer to the CS also). In any case it'd be a good starting point for building a control that exactly meets what you want.
You could override the render method and use primitives which will give possibly better performance; but like anything related to performance I'd try the above approach first which is almost certainly good enough.

Accessing Windows Media Player's Playback Speed controls

Is there a way to access WMP10+'s playback speed controls in a dotnet app?
User level information on the Playback control information
Add the AxWMPLib to your VB/C# project.
Add an AxWindowsMediaPlayer control to your form.
Use the following method to access playback rate:
AxWindowsMediaPlayer1.URL = "e:\song.mp3"
AxWindowsMediaPlayer1.Ctlcontrols.play()
AxWindowsMediaPlayer1.settings.rate = 0.5
*Note that rate may not always be available depending on the media type. A safer method of accessing rate would look like:
If (player.settings.isAvailable("Rate")) Then
player.settings.rate = 0.5
End If
If that isn't what you're looking for, there also exists the MediaPlayer COM object. I didn't investigate it thoroughly, but intellisense yielded:
Dim mpMediaPlayer As New MediaPlayer.MediaPlayer
mpMediaPlayer.FileName = "e:\song.mp3"
mpMediaPlayer.Rate = 0.5
mpMediaPlayer.Play()
Hope that helps.
If you are using a MediaElement object, I would suggest adjusting the SpeedRatio property. Here is an example from Microsoft.
From your comment, it sounds like the SpeedRatio is the way to go. Because it allows you to adjust the playback speed. The MediaElement or MediaPlayer is basically just a Windows Media Player.

Categories