问题
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