使用C#在Windows资源管理器中预览所选文件 [英] Preview selected file in Windows Explorer using C#

查看:261
本文介绍了使用C#在Windows资源管理器中预览所选文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WinForms C#。我希望我的应用程序能够在Windows资源管理器中预览所选文件。一个例子?如果我在Windows资源管理器中选择一首歌,我的应用程序应该显示并预览该歌曲可能使用axWindowsMediaPlayer。



类似于OpenFileDialog的东西,除非这样做通过全局热键,在这种情况下是Space键,所以如果我在Windows资源管理器中按下它,应该预览所选文件。



在此先感谢 - CCB

I am working with WinForms C#. I want my app to be able to make a preview of the selected file in the windows explorer. An example? If I select a song in the windows explorer, my app should show and preview that song maybe using the axWindowsMediaPlayer.

Something similar to an OpenFileDialog, unless this will be made through a global hotkey, in this case "Space" key, so if I press it in the windows explorer, the selected file should be previewed.

Thanks in Advance - CCB

推荐答案

ChrisCreateBoss问:
ChrisCreateBoss asked:

...还有什么可以用来玩几个视频和音频格式?格式如mkv,mpeg,mov,avi,m2ts; wav,mp3。哦,那是因为我的项目是关于快速文件预览应用程序,就像在mac os x计算机上,你选择一个文件,按空格,弹出一个漂亮的窗口显示所选文件。

…What else can I use to play several video and audio formats? Formats such as mkv, mpeg, mov, avi, m2ts; wav, mp3. Oh and that is because my project is about a quick file preview app just like on mac os x computers, you select a file, press space, and a nice window pops up showing the selected file.

哦,我现在看到了...



你看,微软媒体软件(叹息......)尽管假装很花哨,而且它们的一些优质媒体容器和编解码器总是出了名的坏支持所有这些格式和流。首先要明白的是:没有格式。有媒体容器和压缩算法,用于不同编解码器支持的不同种类的流,这些容器可以托管这些流的某些子集(Matroska可能是唯一一个支持几乎所有的,有时称为容器。)请参阅:

http://en.wikipedia.org/wiki/Digital_container_format

http://en.wikipedia.org/wiki/Codec

http://en.wikipedia.org/wiki/List_of_codecs

http://en.wikipedia.org/wiki/List_of_codecs#Video_compression_formats



你能看到你可能有多少组合?视频和音频流不是全部,还有其他(字幕等)。



现在,微软我dia组件......不,我甚至不想讨论它们。随着您对支持容器的胃口......微软并不认真。我甚至从某些计算机上完全删除了Windows Media Player。是的,如果您高度扩展支持的编解码器和格式集,它可以工作(我强烈建议使用免费软件K-Lite Codec Pack并保留最新版本, http://en.wikipedia.org/wiki/K-Lite_Codec_Pack ),但即便如此,到目前为止并非一切都会奏效。为了改善您在这种方法中的游戏体验,我建议,例如,开源Windows Player经典家庭影院:

http://mpc-hc.sourceforge.net

http:// sourceforge .net / projects / mpc-hc

http://mpc-hc.sourceforge .net / downloads



此外,对于认真的用户来说,它的专业性和便利性要高出百万倍,不仅仅是媒体的消费者,还有那些如何生产,支持或重新设置东西。



但是对于组件,我不知道哪个允许立即嵌入此产品。相反,我只能推荐嵌入VLC,也是非常通用的播放器。它的概念是不同的:它不依赖于编解码器,只使用FFMpeg / libav,直接包含所有支持的库。请参阅:

http://en.wikipedia.org/wiki/VideoLAN

http://www.videolan.org/

也强烈推荐:

http://en.wikipedia.org/wiki/FFmpeg
http://ffmpeg.org/

http://en.wikipedia.org/wiki/Libavcodec

http://libav.org/



对于VLC,您可以找到.NET和系统的组件。 Windows.Forms

http://sourceforge.net/projects/libvlcnet

https://wiki.videolan.org/C_Sharp

https://github.com/ZeBobo5/Vlc.DotNet [ ^ ]。



请注意,VLC(VideoLAN)并不是真的播放器。它主要用作播放器,但它也可用于许多其他事情,例如转码(但我宁愿推荐FFMpeg / libav,见上文),特别是流媒体。



另见我以往的答案:

需要帮助从C#中的其他计算机获取流媒体视频

Streaming没有WMP的vb.net中的音乐文件



-SA

Oh, I see now…

You see, Microsoft media software is (sigh…), despite of pretending to be fancy and some of their good quality media containers and codecs, was always notoriously bad in supporting all those formats and streams. First thing to understand: there are no just formats. There are media containers and compression algorithms for different kinds of streams supported by different codecs, and those containers can host some subset of those streams (Matroska is perhaps the only one supporting nearly everything, sometimes called "king of containers.) Please see:
http://en.wikipedia.org/wiki/Digital_container_format,
http://en.wikipedia.org/wiki/Codec,
http://en.wikipedia.org/wiki/List_of_codecs,
http://en.wikipedia.org/wiki/List_of_codecs#Video_compression_formats.

Can you see how many combination you might have? And video and audio streams are not all, there are others (captions, and so on).

Now, Microsoft media components… no, I don't even want to discuss them. With your appetites for the supported containers… Microsoft is just not serious. I even removed Windows Media Player completely from some computers. Yes, it can work if you highly extend the set of supported codecs and formats (I would highly recommend to have freeware K-Lite Codec Pack and keep the latest versions, http://en.wikipedia.org/wiki/K-Lite_Codec_Pack), but even then not everything will work, by far. To improve your playing experience in just this approach I would advise, for example, open-source Windows Player Classic Home Cinema:
http://mpc-hc.sourceforge.net,
http://sourceforge.net/projects/mpc-hc,
http://mpc-hc.sourceforge.net/downloads.

Besides, it is million times more professional and convenient for serious users, not just consumers of media, but those how produce, support or remaster things.

But as to the components, I don't know any which allows to embed this product immediately. Instead, I can only recommend to embed VLC, also very universal player. It's concept is different: it does not depend on codecs, only uses FFMpeg/libav, the library which include all support directly. Please see:
http://en.wikipedia.org/wiki/VideoLAN,
http://www.videolan.org/,
also highly recommended:
http://en.wikipedia.org/wiki/FFmpeg,
http://ffmpeg.org/,
http://en.wikipedia.org/wiki/Libavcodec,
http://libav.org/.

For VLC, you can find components for .NET and System.Windows.Forms:
http://sourceforge.net/projects/libvlcnet,
https://wiki.videolan.org/C_Sharp,
https://github.com/ZeBobo5/Vlc.DotNet[^].

Note that VLC (VideoLAN) is not really a player. It is mostly used as a player, but it can also be used for many other things, such as transcoding (but I would rather recommend FFMpeg/libav, see above), and, notably, for streaming.

See also my past answers:
need help in getting the streaming video from an other computer in C#,
Streaming music files in vb.net without WMP.

—SA


这篇关于使用C#在Windows资源管理器中预览所选文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆