Hello, I am working on a Media Player using MCI Libary.
I can play audio and video, but when I play video it doesnt show the video it self... just give me the sounds. when I move my form I see that the video is really behind my form... I have no idea why, I did exactly like in the MCI libary... this is my code:
Code:
private Player player = new Player();
//Play method:
int index = this.listView1.FocusedItem.Index;
string path2 = this.listView1.Items[index].SubItems[3].Text;
FileInfo file = new FileInfo(path2);
try
{
if (file.Exists)
{
player.Close();
if ((file.Extension == "avi") || (file.Extension == ".mpg") || (file.Extension == ".wmv") || (file.Extension == ".mkv"))
{
player.Open(file.FullName, this.picVideoWindow);
}
else
{
player.Open(file.FullName);
}
player.Play(false);
}
finally
{
}
//Player.open method
public void Open(string sFileName)
{
Pcommand = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
mciSendString(Pcommand, null, 0, IntPtr.Zero);
isOpen = true;
}
public void Open(string sFileName, System.Windows.Forms.PictureBox videobox)
{
Pcommand = "open \"" + sFileName + "\" type mpegvideo alias MediaFile style child parent " + videobox.Handle.ToInt32();
mciSendString(Pcommand, null, 0, IntPtr.Zero);
Pcommand = "put MediaFile window at 0 0 " + videobox.Width + " " + videobox.Height;
mciSendString(Pcommand, null, 0, IntPtr.Zero);
isOpen = true;
}
//Player.play method
public void Play(bool loop)
{
if (isOpen)
{
Pcommand = "play MediaFile";
if (loop)
Pcommand += " REPEAT";
mciSendString(Pcommand, null, 0, IntPtr.Zero);
}
}