简体   繁体   English

Windows窗体不会与DirectX.AudioVideoPlayback一起显示-C#

[英]Windows Form won't show with DirectX.AudioVideoPlayback - C#

I'm trying to make a media player application with DirectX.AudioVideoPlayback, but when I try to run it, the project builds successfully and the application runs, but the Form doesn't show. 我正在尝试使用DirectX.AudioVideoPlayback制作媒体播放器应用程序,但是当我尝试运行它时,项目会成功构建并且应用程序会运行,但是Form不会显示。 The application just hangs on Application.Run(). 该应用程序仅挂在Application.Run()上。 However, when I comment out all of the DirectX code, the application runs like it is supposed to. 但是,当我注释掉所有DirectX代码时,应用程序将按预期运行。

Here is my code: 这是我的代码:

Video v_Video = null;

void MainFormLoad(object sender, EventArgs e)
{
    v_Video.Size = VideoViewer.Size; //VideoViewer is a PictureBox
    v_Video.Owner = VideoViewer;
}

void PlayButtonClick(object sender, EventArgs e)
{
    v_Video = new Video(File.ReadAllText("VideoLocation.txt") + "\\Video.wmv");
    v_Video.Play();
    PauseButton.BringToFront();
}

I have used this DLL before. 我以前使用过此DLL。 When I attempt to open a media file, Visual Studio throws this exception: 当我尝试打开媒体文件时,Visual Studio抛出此异常:

DLL 'C:\\Windows\\assembly\\GAC\\Microsoft.DirectX\\1.0.2902.0__31bf3856ad364e35\\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. DLL'C:\\ Windows \\ assembly \\ GAC \\ Microsoft.DirectX \\ 1.0.2902.0__31bf3856ad364e35 \\ Microsoft.DirectX.dll'尝试在OS Loader锁内进行托管执行。 Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang. 不要尝试在DllMain或图像初始化函数中运行托管代码,因为这样做可能导致应用程序挂起。

I suggest you using another library. 我建议您使用另一个库。 Take a look here . 在这里看看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM