/// <summary> /// 中奖名单音乐试听 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMusicPrizeBackground_Click(object sender, EventArgs e) { try { string fName = Config.BasePath + @"\Sounds\中奖名单音乐\" + cmBoxMusicPrizeBackground.SelectedItem.ToString(); if (mPlay == null) { mPlay = new MusicPlay(); } if (btnMusicPrizeBackground.Text == "试听") { btnMusicPrizeBackground.Text = "停止"; MusicPlay(fName, true); } else { btnMusicPrizeBackground.Text = "试听"; mPlay.StopT(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void MusicPlay(string m_fName, bool m_bPlay) { if (mPlay != null && m_fName == "") { //MessageBox.Show("关闭"); mPlay.StopT(); } else if (mPlay != null && m_fName != "" && (m_bPlay == false)) { //MessageBox.Show("关闭"); mPlay.StopT(); } else if (mPlay != null && m_fName != "" && (m_bPlay == true)) { //MessageBox.Show("播放"); mPlay = new MusicPlay(); mPlay.FileName = m_fName; mPlay.play(); } else { MessageBox.Show("调用音乐错误"); } //MessageBox.Show("mPlay " + mPlay.FileName); }
/// <summary> /// 播放音乐,只能在UI主线程上播放 /// </summary> /// <param name="none"></param> private void PlayMusic(string none) { //MessageBox.Show("currMusic = " + currMusic + " bCurrPlay = " + bCurrPlay); //Common.mBox.MusicPlay(Common.mBox.fMusicName3, Common.mBox.bPlay3); if (mPlay != null && currMusic == "") { //MessageBox.Show("关闭"); mPlay.StopT(); } else if (mPlay != null && currMusic != "" && (bCurrPlay == false)) { //MessageBox.Show("关闭"); mPlay.StopT(); } else if (mPlay != null && currMusic != "" && (bCurrPlay == true)) { mPlay = new MusicPlay(); mPlay.FileName = currMusic; mPlay.play(); } else { MessageBox.Show("调用音乐错误"); } //MessageBox.Show("mPlay " + mPlay.FileName); }
private void Init() { #region 设置背景 string strBgFile = ""; if (File.Exists(Config.BasePath + @"\bg.bmp")) { strBgFile = Config.BasePath + @"\bg.bmp"; this.BackgroundImage = Image.FromFile(strBgFile); } else if (File.Exists(Config.BasePath + @"\bg.jpg")) { strBgFile = Config.BasePath + @"\bg.jpg"; this.BackgroundImage = Image.FromFile(strBgFile); } #endregion #region 图片宽高 UpdatePicBoxPosition(); #endregion UpdateTitle(); #region 初始化音乐选择控件 string[] arrFilesGenerate = Directory.GetFiles(Config.BasePath + "/Sounds/中奖音乐"); //中奖音乐 string[] arrFilesBackground = Directory.GetFiles(Config.BasePath + "/Sounds/背景音乐"); //背景音乐 string[] arrFilesPrizeList = Directory.GetFiles(Config.BasePath + "/Sounds/中奖名单音乐"); //中奖名单音乐 foreach (string item in arrFilesGenerate) //中奖音乐 { string fName = System.IO.Path.GetFileName(item); cmBoxMusicPrizeGenerate.Items.Add(fName); } cmBoxMusicPrizeGenerate.SelectedIndex = 0; foreach (string item in arrFilesBackground) //背景音乐 { string fName = System.IO.Path.GetFileName(item); cmBoxMusicBackground.Items.Add(fName); } cmBoxMusicBackground.SelectedIndex = 0; foreach (string item in arrFilesPrizeList)//中奖名单音乐 { string fName = System.IO.Path.GetFileName(item); cmBoxMusicPrizeBackground.Items.Add(fName); } cmBoxMusicPrizeBackground.SelectedIndex = 0; #endregion mPlay = new MusicPlay(); }