Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Comments
Sergey Alexandrovich Kryukov 7-Apr-15 19:04pm    
Why not using HTML video element?
—SA
ChrisCreateBoss 7-Apr-15 19:13pm    
as the "file preview player" ??
Sergey Alexandrovich Kryukov 7-Apr-15 19:15pm    
Absolutely. What's the difference? For such dynamic things, you have to have some server-side technology anyway, so you can always dynamically generate any HTML markup on preview. What is that?
—SA
ChrisCreateBoss 7-Apr-15 21:32pm    
The media element is the same as in WPF right? So I can embed it to my Project. Can you name which video and audio formats supports the html media element?
Sergey Alexandrovich Kryukov 7-Apr-15 21:36pm    
No. Sorry. How come we are talking about WinForms? Probably I mixed up your post with something else, or misread your "Explorer". Forget HTML5. Sorry for the confusion.

No, WPF UIElements and Forms controls are totally unrelated.

Now, why in Explorer? Do you mean that you want your application to start on the Shell commands like "Open" when you use some media files? I would not advise doing so...

—SA

1 solution

ChrisCreateBoss asked:
…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.
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
 
Share this answer
 
v6
Comments
ChrisCreateBoss 8-Apr-15 17:23pm    
Thanks for that great information, I'll try between VLC and FFmpeg, then I'll comment which advantages and disadvantages I found for my project(what works and what do not too). And yes, I know Windows Media Player is not a good option for this project and don't use it often in my computer, I prefer iTunes for music and K_Lite for video.
Sergey Alexandrovich Kryukov 8-Apr-15 17:42pm    
You are welcome.

Let me explain one thing: FFMpeg or separate product libav have analogous sets of utilities (one-to-one, actually, under slightly different names), including the player. But primarily, they are libraries. The player is good, because it does some tricky things, but it is good only for... developers (or people doing re-masterting, support, and the like). It is not even convenient as a player, it is very simple. And I never saw the .NET UI components based directly on them. (If you find some, please share.) The utilities will certainly be helpful for your work but for downloading, filtering, muxing/demuxing, extracting/combining channels, and, importantly, trans-coding. For such purposes, I just never knew anything better.

That's why I focused on the use of VLC as a player. This is the only product with so much diversity and with .NET UI player wrapping components I know. I hope you will use it successfully.

I also expect you to accept my answer formally.
In all cases, your follow-up questions will be welcome.

—SA
Sergey Alexandrovich Kryukov 8-Apr-15 17:44pm    
I believe, by "K_Lite" video you mean the player which comes with K-lite, which is the same very "Windows Player Classics" and ""Windows Player Classics Home Video", a separate product which is just bundled with K-Lite. Great thing, and I wish I could find some .NET components for it. I am sure it's even better than VLC in a number of respects.
—SA
ChrisCreateBoss 8-Apr-15 17:51pm    
As far as I know, the one I have installed is named K_Lite_Codec... it has a cinema -like icon. And yes, I will accept your answer(sorry, sometimes I forget that an Accept Solution button exists.) and thanks for your future helping, I will be greatly thankful :)
Sergey Alexandrovich Kryukov 8-Apr-15 17:53pm    
Oh yes, this is that very thing. I always highly recommend it and wish it had .NET UI wrapper.
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900