【发布时间】:2014-08-24 18:59:58
【问题描述】:
我需要我的应用程序仅在 Windows 使用的播放器/浏览器中运行任何文件(因此对于 AVI,它将使用例如 BSPlayer 或任何具有 PC 设置等)。 我发现的都与 EXE 文件有关。
编辑:我不仅仅指多媒体文件。我的意思也是TXT(我希望记事本打开等等)
【问题讨论】:
我需要我的应用程序仅在 Windows 使用的播放器/浏览器中运行任何文件(因此对于 AVI,它将使用例如 BSPlayer 或任何具有 PC 设置等)。 我发现的都与 EXE 文件有关。
编辑:我不仅仅指多媒体文件。我的意思也是TXT(我希望记事本打开等等)
【问题讨论】:
使用Process.Start(System.String) 启动文件类型的默认应用程序。
例如:
Process.Start(@"C:\MyFile.txt");
或者
Process.Start(@"D:\Videos\Films\SomeFilm.avi");
【讨论】:
如果是控制台/windows应用最好用
System.Diagnostics.Process.Start("your file path and file extension");
【讨论】:
您可以为此使用DirectX。
来自MSDN 论坛
//create the video
Microsoft.DirectX.AudioVideoPlayback.Video video = new Microsoft.DirectX.AudioVideoPlayback.Video(fileName);
//set the System.Windows.Forms.Control to play it in (e.g a panel)
video.Owner = panel1;
//Play the video (put this in a buttons click event)
video.Play();
//Pause the video (put this in a buttons click event)
video.Pause();
//Stop the video (put this in a buttons click event)
video.Stop();
同时检查Playing Audio and Video Files Using C#
编辑:
你可以试试这个:
System.Diagnostics.Process.Start(@"yourfilewith a path");
启动应用程序。
一个示例:
String fileToOpen = "C:/test.avi";
System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo("C:/Program Files/Windows Media Player/wmplayer.exe", fileToOpen);
System.Diagnostics.Process.Start(ps);
【讨论】: