日期:2014-05-17 浏览次数:21231 次
string FilePath = listView.SelectedItems[0].Tag.ToString();//视频的初始路径 axWindowsMediaPlayer_Video.URL = FilePath;//axWindowsMediaPlayer是播放器控件名字 axWindowsMediaPlayer_Video.Ctlcontrols.play();
------解决方案--------------------
工具箱右击 选择项 COM组件 找到window media player 添加 然后在窗体添加这个控件 this.axWindowsMediaPlayer1.URL = "G:\\film\\你若成风.mp3"; this.axWindowsMediaPlayer1.Ctlcontrols.play();//播放 this.axWindowsMediaPlayer1.Ctlcontrols.pause();//暂停
------解决方案--------------------
<SCRIPT type=text/javascript> var IsOpenMusic = true; function MusicOperate() { var obj = document.getElementById("music"); var wma = document.getElementById("wma"); if(IsOpenMusic == true) { wma.stop(); obj.innerHTML = "背景音乐 (开)"; IsOpenMusic = false; } else { wma.play(); obj.innerHTML = "背景音乐 (关)"; IsOpenMusic = true; } } </SCRIPT> <OBJECT id=Object1 style="DISPLAY: none" type=application/x-mplayer2 name=wma><PARAM NAME="src" VALUE="<%=strMu %>"> <PARAM NAME="autostart" VALUE="true"><PARAM NAME="controller" VALUE="true"></OBJECT> <SPAN id=music style="CURSOR: hand" onclick=MusicOperate()>背景音乐 (关)</SPAN>
------解决方案--------------------
using System.Media;
using System.IO;
SoundPlayer music = new SoundPlayer();
music = new SoundPlayer("");
music.Play();
或
[DllImport("winmm.dll")]
public static extern long PlaySound(String fileName,long a,long b);
[DllImport("winmm.dll")]
public static extern long mciSendString(string lpstrCommand,string lpstrReturnString,long length,long hwndcallback);
public static void PlayMusic(string p_FileName)
{
try
{
mciSendString(@"close "+p_FileName ,"",0,0);
mciSendString(@"open " + p_FileName,"",0,0);
mciSendString(@"play " + p_FileName ,"",0,0);
}
catch
{
}
}