I’m working on a project that works on retrieving / displaying different types of media in a form. Basically, a user chooses an image, video, audio, or txt file with an OpenFileDialog, and the program will then store those in List. (I created custom classes for each type of media that all implement from a single interface.)
The form needs to hold a “preview” of these files that can be paged through with next/back buttons. However, since the form doesn’t know what type of Media it will be, I put a Panel on the form, and then send a reference of that panel to my IMedia.DisplayMedia method, and each class is in charge of drawing its own representation in the panel. (A PictureBox or RichTextField for instance.)
For text and images I’ve created the controls in code, then added them using:
myPanel.Controls.Add(myControl);
However, I can’t do this for Windows because WMPLib.WindowsMediaPlayer doesn’t inherit from control.
Any ideas how to achieve this? I’m no married to WMP, I just need something that will play most standard video/audio formats.
Thank you.
You can actually add a WindowMediaPlayer to a form as a control:
Creating the Windows Media Player Control Programmatically
In short, there’s a ActiveX control that wrap around it to be able to add it a form.