Windows Media Player Embedded in C# Video Speed Change - c#

I currently have a windows media player embedded into my winform on c# and i am now trying to make a button to control the speed of the video play. I currently can use controls to play, pasue and stop, found in ctlcontrols but can't find a way to change the speed of video play through using a button on my form?
An example of my code for pausing the video in it is:
axWindowsMediaPlayer1.Ctlcontrols.pause();
But i need some code to change the play speed so any help would be much appreciated.
Thanks

Settings.Rate is what you are looking for: speed is a double, 1.0 being normal speed.
axWindowsMediaPlayer1.settings.rate = speed;
For rewinding:
if (axWindowsMediaPlayer1.controls.isAvailable('FastReverse'))
axWindowsMediaPlayer1.controls.fastReverse();
For a full scripting reference check the documentation.

Related

set playback speed in vlc dot net (winforms)

i am using vlc player in winforms. its working fine, but the problem is that its playing faster. i have videos recorded at 10fps. i think vlcControl is playing at 30fps, that's why video are playing faster. Referred this, but it didn't help. i couldn't find any function like set_play_back_speed function under vlcControl1.VideoI thought vlcControl would automatically figure out fps & play accordingly. if i open the same video from vlc media player installed on my windows pc, it plays at proper rate.
any clue how to fix this?
P.S: if i open any video recorded at 29.97fps, vlcControl in winforms is playing it at proper speed.
Well, there's no function to set FPS to video thru Vlc.DotNet and I am not sure are you using WinForms or WPF application, but best I can help is probably, if you would play with rate settings as in transpone video.
It's found at vlcControl1.rate (which is float value default is 1.00), if you have 30fps and only want 10fps well, you could try to set:
vlcControl1.rate = (int)(33 / 100);
Which then would decrease video and audio transpone to 10fps from 30fps (assuming 1.00 = 30fps).

Get user inputs from the webcame for the game

I'm creating a simple game using Unity Studio which uses arrow keys to move the player. Now what I want to do is, use webcam as a movement detecting device and track user's movements and move the player according to them. (For example, when user move his hand to right, webcam can track it and move the player to the right...)
So, is this possible ? If so, what are the techniques APIs I should use for this...?
Thanks!
Have a look at OpenCV, it is being used a lot in the field of body and head tracking, and there's a unity plugin which implements it that might be useful.
Video Demo
It can't. But there is a lot of stuff out there on the internet.
This one has some interesting looking links.
Emgu CV looks interesting too.
There is some JavaScript handtracking tool too.
And of course there's kinect, but you need the 3d sensor.
You could also use LeapMoution.

C# playing multiple audio files at once from your resources?

I'd like to be able to press a button to play a sound of a button being pressed while music is already playing. SoundPlayer is no help because it stops the music to play the sound.
I have added the sounds to my Resources (WindowsFormsApplication2.Resources.Properties.button) and I don't want to have to type in the file location.
Answer from MerickOWA
You CANNOT play two sounds at once using SoundPlayer.
SoundPlayer is using the native WINAPI PlaySound function to accomplish the task which has no support for playing simultaneous sounds. Creating multiple instances of SoundPlayer won't help.
There are many options most of which involve implementing a lot of the low level API to window's native audio library or DirectSound (note neither are C# and require alot of interop code)
The simplest option would be to depend on windows media player to play the audio for you.
Add a reference to "C:\Windows\System32\wmp.dll"
then use
var player = new WMPLib.WindowsMediaPlayer();
player.URL = #"..\..\bin\debug\tribal dance.wav";
Note: play starts immediately after setting the URL property
The down side of this approach is your reliance on media player for your application to work properly. On the upside, you can use any file format media player supports.

Dynamically increasing/decreasing speed of a video in a windows forms application

I'm building a Windows Forms application in VS 2010 that smoothly increases or decreases the speed of a video playing back based on the speed of the user input.
I've tried several avenues..
1.) Using the AudioVideoPlayback DirectX class - I set the speed of the video, by setting the current position of the video, based on a timer.. and increased or decreased that value based on user input. While this worked on my PC, it lags a lot on our lower end target PC's. Can anyone think of a more efficient way to increase/decrease the speed of playback using this class?
2.) I've tried the Windows Media Player ActiveX control, and tried setting the rate/position dynamically, but this is extremely jumpy and laggy even on my development PC
3.) I've tried the Apple QuickTime Control 2.0 COM Component that comes with VS 2010, and it's also very laggy.
4.) I'm trying to figure out how to set the speed on the Shockwave Flash Object control, but haven't found that out yet
Can anyone suggest other avenues to explore? I just need to be able to increase/decrease the speed of video playback smoothly based on user input without lag. I don't care what format the video needs to be in, all videos can be converted to the required format.
Any help/ideas will be appreciated.
Thanks
The ultimate way is to decode the Bitmaps from videos, and handle the frames yourself.
Try the CaptureNET example from DirectShow.NET. It allows you to capture bitmaps from each frame. After that, write your own playback control to handle the refresh rate.
After trying many different formats/libraries and components I found the VLC Media Player ActiveX control to be the most efficient method to slow down/speed up video without any noticeable lag.

How can I capture video and play it with C#?

I want to build application which needs to be able to capture video from a web camera using C#. The captured video should be compressed using some codec (nothing special, anything available that saves space) and written to a file while capturing. A live preview of capture is not necessary.
The first question is: Which API is suitable for this and what would you recommend (I have seen DirectShow, Windows Media Foundation wrapper, etc. I am not sure which is would be best for managed environment and C#)?
I also need a video player in WPF which will play captured video. This player must be able to play captured video from an arbitrary position, pause and start/stop video.
Putting it all together, video is captured from a webcam in the background and at the same time the player plays that video being captured, but it can be paused, re-winded, stopped - something like a modern DVR.
The second question: Is it possible to create such a player using WPF MediaElement? (Confusion is about the file which is at the same time filled from the capture and played in the player)
A nice example of how to make all what you want: WebCam
I have used the AForge set of libraries to accept the videos frame by frame. I used the private void videoSourcePlayer1_NewFrame(object sender, ref Bitmap image) function to do this.
I've used VlcDotNet. It is very flexible and simple to use. It has a pretty active user base as well.
I've used it for displaying live video streams as well as recording to files.
You can try the DirectShow.net library.
I can recommend WPF's ffmediaelement. It's built on FFmpeg. So what can FFmpeg, can also ffmediaelement. It can capture video from both the webcam and the capture card. Unlike DirectShow, it's very simple.
Here's how to set up a video source:
Media.Source = new Uri("device://dshow/?video=Osprey-460e Video Device 1C");
... and parameters for it in MediaOpening event:
Media.OnMediaOpening(s, e) =>
{
e.Options.Input["framerate"] = "25";
e.Options.Input["video_size"] = "768x576";
e.Options.Input["pixel_format"] = "yuyv422";
};

Categories