Andres A.
Andres A.

Reputation: 1349

How to play a video from WinForms resources in a axWindowsMediaPlayer?

Does anybody know or have any idea for how to play a video from the applications resources into an axWindowsMediaPlayer component?

I mean something like:

axWindowsMediaPlayer1.TheProperty = Resources.MyVideoResource;

Would be very nice, but I don't think such property exists..

Upvotes: 1

Views: 14110

Answers (1)

sihirbazzz
sihirbazzz

Reputation: 718

Add Interop.axWMPLib and / or Interop.WMPLib references to your project

(if i don't remember wrong axWmpLib works with windows mp and if no wmp found on the pc then wmplib connects with any installed -or default- media player automatically which supports wmplib -i.e. winamp or splayer- .. i only worked once with this last year -2011 august- to surprise to my g.f. for her b-day.. so its worked as well before with a media list contains 2 mp3s and i give these codes directly except paths)

        private void axWindowsMediaPlayer1_ClickEvent(object sender, AxWMPLib._WMPOCXEvents_ClickEvent e)
        {
            axWindowsMediaPlayer1.URL = fullPathOfYourFirstMedia;
            axWindowsMediaPlayer1.Ctlcontrols.play(); // activates the play button
            axWindowsMediaPlayer1.Ctlcontrols.next(); // activates the next button
            WMPLib.IWMPMedia media = axWindowsMediaPlayer1.newMedia(fullPathOfYourSecondMedia);
            axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
        }

if you take the medias from the resources then simply add your medias to your project's recources and give the full path strings' start as "Application.Startup"

Upvotes: 3

Related Questions