I have a axWindowsMediaPlayer on WinForm with uiMode=none. I am using my custom controls to handle playback. I am using this method to associate a trackBar with axWindowsMediaPlayer.
I want to change the video position (jump to specific time) when the user scrolls the trackBar, just like windows media player.
private void trackBar_Scroll(object sender, EventArgs e)
{
if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
axWindowsMediaPlayer.Ctlcontrols.currentPosition = trackBar.Value;
}
}
This is not working. I have checked many Stackoverflow answers including this, this, and the Microsoft documentation but none is working.
I have two objectives:
When playing media, the trackBar should show the current position of the media file being played. This is working fine.
When the user scrolls the trackBar, the media player should change the video current position based on the trackBar value. This is not working.
Any help will be highly appreciated.
I solved the issue. The problem was not with the media player, the problem was with the media files being played with the axWindowsMediaPlayer.
axWindowsMediaPlayer plays the files such as MKV fine, but if the proper codecs are not installed, the Ctlcontrols mainly the Trackbar does not work from code or UI. With natively supported formats, this code works perfectly fine.
private void trackBar_Scroll(object sender, EventArgs e)
{
if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
axWindowsMediaPlayer.Ctlcontrols.currentPosition = trackBar.Value;
}
For media files not natively supported, their codecs need to be installed. For details of supported file formats, see this KB article File types supported by Windows Media Player
Related
I am creating a game, I want to display a short tutorial video to the player after they have registered. I am using a windows media player control. I don't know how to hide the video after it has finished playing ?
I tried using the following:
WMP.Ctlcontrols.play();
Thread.Sleep(3000);
WMP.Dispose();
I am using the disposing as a way to close down the video. I tried hide and close as well but they close the video before it's finished playing, after 3 seconds.
You can handle PlayStateChange event of control and check if e.newState==1, it means the playing has been stopped. Then you can hide the control.
void axWindowsMediaPlayer1_PlayStateChange(object sender,
AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if(e.newState== 1) // Stopped
axWindowsMediaPlayer1.Hide();
}
Hello I have an application that used to allow me to watch videos from youtube, but now the screen is completely black, I cannot view videos. I am using axmediaplayer and here is my code.
private void Form1_Load(object sender, EventArgs e)
{
// play video in embedded media player
axWindowsMediaPlayer1.URL = "http://www.youtube.com/v/Of9JCZ6zraQ";
}
Is it a change made on youtube or does any one know alternatives? it used to work before but not it is not working any more. does any one know what the problem is please?
I am using Aforge .NET framework to get a webcam in my app but I always get an all gray image frame.
this.videoSource = new VideoCaptureDevice(this.Moniker);
this.videoSource.DesiredFrameSize = GetHighestResolution(this.videoSource.VideoCapabilities);
this.videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
this.videoSource.Start();
The vent handler:
private void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
this.outputBox.Image = (Bitmap)eventArgs.Frame.Clone();
}
This should do the trick. DesiredFrameSize is set to the highest value the cam can support.
Any hints why the image is always gray? Even when writing it do disk...
Edit: To add: The same problem occurs with the sample application SimplePlayer from Aforge samples. My webcam is a Logitech QuickCam Pro 9000.
Edit2: The same goes for small DesiredFramesizes.
maybe the camera isnt wrapped around directshow (some sort of directx stuff).
some camera's come with their own driver, or different inner working.
I have some highspeed industrial camera's, with simmilar issues.
I had to retrieve the raw images from them using diffrent methods, then do aforge stuff on those images.
Maybe check your code using older cheap USB2 camera's
Figure 1,i have one or a few pictures,and some mp3 files. i want to develop a winform and load picture into winform,then, when mouse over certain areas of the picture,the area change,and play mp3 file when the mouse click.
question:How do I know the mouse over the designated area?and then change the color of the area? how to know which areas of mouse clicks? and play mp3 files
These areas may be round, oval, rectangular...
perhaps this is hotspot image question.
anyone help me? thanks!
Use OvalShape and the MouseHover event. Then simply call code to modify the opacity/color/whatever of the oval, and play an mp3 which is a separate problem.
One way to do that is to create a hidden bitmap of the same size with a white or black background, and shade each bubble with a different color.
Then you can just do something like this:
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
int foundColor = _Mask.GetPixel(e.X, e.Y).ToArgb();
if (foundColor == Color.Red.ToArgb())
// do something with this bubble
else if (foundColor == Color.Blue.ToArgb())
// do something with this bubble
else
// do nothing
}
I am looking for some C# code .. or .NET component to record the activity of a form on my screen (not the whole desktop) along with audio, similar to what programs like Camtasia allow to do.
The video part is actually pretty easy. All you need to have is a timer running 20 times a second that will save form's canvas to a image files as frames. Then create an animation out of these pictures.
To capture image:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
tVideo.Start();
}
int i = 0;
private void tVideo_Tick(object sender, EventArgs e)
{
String lFile = String.Format("c:\\{0}.bmp", i);
SaveAsBitmap(this, lFile);
i++;
}
public void SaveAsBitmap(Control aCtrl, string aFileName)
{
if (File.Exists(aFileName))
File.Delete(aFileName);
Graphics lGraphics = aCtrl.CreateGraphics();
Bitmap lImage = new Bitmap(aCtrl.Width, aCtrl.Height);
aCtrl.DrawToBitmap(lImage, new Rectangle(0, 0, aCtrl.Width, aCtrl.Height));
lImage.Save(aFileName);
lImage.Dispose();
}
}
This is just a light sample, of course you would have to add some compression and try to avoid saving the same image twice. Knowing how many images are the same + knowing about the framerate, you know how long to display the same frame.
To add a cursor you would have to keep some variables with mouse x,y and an event on mouse click. And then just add it to pictures.
Of course, this won't work for 3d games inspite of overlay which is drawn after the win32 paints.
For that you would have to go with DirectX/OpenGl/XNA. I think the idea is the same.
For audio, DirectX also.
My complete source:
http://deathsquad.pl/archiwum/Inne/so/answer-1934452.rar
Some DirectX audio samples:
http://www.codeproject.com/KB/directx/audiosav.aspx
Check out Gallio: It is a great testing framework, and it has built in screen recording API.
This post shows a few examples:
http://blog.bits-in-motion.com/2009/09/announcing-gallio-and-mbunit-v31.html