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

泄露秘密 提交于 2019-12-11 07:26:51

问题


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..


回答1:


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"



来源:https://stackoverflow.com/questions/10761331/how-to-play-a-video-from-winforms-resources-in-a-axwindowsmediaplayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!