Hello Allan,
The Windows Media Player control does have a x64 version on Windows XP x65
Edition. I'm not sure why it crashes, but using a debugger can help finding
out the root cause.
If you don't want to do that, you may try upgrade the Media Player to
version 11 and see if the problem sovles:
http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx
From the link above, choose WMP 11 for Windows XP x64, download and setup.
By the way, is the crash happens on all of your x64 XP machines?
Also, there is another way to play the AVI inside your application without
using the WMP control.
You can use the Windows MCI functions to control the video playback in your
WinForm application.
I wrote some sample code on how to do that, please create a new WinForm
project to test it out:
1. Put a picture box named picPlayer on the form. Set the picPlayer's size
to your video's size, or at least keep the same width:hight ratio.
2. Put a text box named txtFileName on the form. Set the text to the full
path of your AVI file.
3. Put three buttons named btnPlay, btnPause, btnStop on the form.
4. Paste the following code into the form's code, and import the
System.Runtime.InteropServices namespace.
[DllImport("winmm.dll", CharSet = CharSet.Auto)]
private static extern Int32 mciSendString(
String command,
StringBuilder buffer,
Int32 bufferSize,
IntPtr hwndCallback);
[DllImport("winmm.dll", CharSet = CharSet.Auto)]
private static extern Int32 mciGetErrorString(Int32 errorCode,
StringBuilder errorText, Int32 errorTextSize);
private const string VideoAlias = "myVideo";
private void btnPlay_Click(object sender, EventArgs e)
{
string cmd;
// open the device
cmd = string.Format("open \"{0}\" alias {1} wait",
txtFileName.Text.Trim(), VideoAlias);
SendMCIString(cmd, IntPtr.Zero);
// set the picture box as player window
cmd = string.Format("window {0} handle {1} wait", VideoAlias,
picPlayer.Handle);
SendMCIString(cmd, IntPtr.Zero);
// set the destination rect
cmd = string.Format("put {0} destination at {1} {2} {3} {4} wait",
new object[] { VideoAlias, 0, 0, picPlayer.Width, picPlayer.Height
});
SendMCIString(cmd, IntPtr.Zero);
// start playing
cmd = string.Format("play {0}", VideoAlias);
SendMCIString(cmd, IntPtr.Zero);
}
private void btnPause_Click(object sender, EventArgs e)
{
string cmd = string.Format("status {0} mode", VideoAlias);
// first check the playing status
if (SendMCIString(cmd, IntPtr.Zero).ToLowerInvariant() == "paused")
{
// if already paused, then play
cmd = string.Format("play {0}", VideoAlias);
}
else
{
// if already playing, then pause
cmd = string.Format("pause {0}", VideoAlias);
}
SendMCIString(cmd, IntPtr.Zero);
}
private void btnStop_Click(object sender, EventArgs e)
{
// close the device
string cmd = string.Format("close {0}", VideoAlias);
SendMCIString(cmd, IntPtr.Zero);
}
private string SendMCIString(string mciString, IntPtr hWndCallback)
{
StringBuilder buffer = new StringBuilder(512);
int errCode;
errCode = mciSendString(mciString, buffer, buffer.Capacity,
hWndCallback);
// If error occurred, get the error text and throw exception
if (errCode != 0)
{
buffer = new StringBuilder(256);
mciGetErrorString(errCode, buffer, buffer.Capacity);
throw new ApplicationException(buffer.ToString());
}
return buffer.ToString();
}
5. Hook up the buttons' events with the code, like btnPlay_Click etc.
6. Run the project and see if that works for you.
I've tested the above code on my x64 system (but not XP), please let me
know if that works for you.
Best regards,
Jie Wang
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.