123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.CallerWizard
- {
- public partial class FrmPlayer : LYFZ.Software.UI.CallerWizard.FrmPlayer
- {
- public string Path;
- private Audio ad = null;
- public FrmPlayer()
- {
- }
- #region 加载
- protected override void FrmPlayer_Load(object sender, EventArgs e)
- {
- try
- {
- ad = new Audio();
- updateToolBar();
- updateSum();
- if (!string.IsNullOrEmpty(Path))
- {
- try
- {
- string FileName = Path.ToString();
- ad.RenderMedia(FileName, true);
- trackBar1.Maximum = ad.MediaDuration;
- updateToolBar();
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region 播放快进
- protected override void trackBar1_Scroll(object sender, EventArgs e)
- {
- ad.Seek(trackBar1.Value);
- }
- #endregion
- #region 播放
- protected override void tsbPlay_Click(object sender, EventArgs e)
- {
- try
- {
- ad.Play();
- updateToolBar();
- }
- catch { MessageBoxCustom.Show("无法找到播放文件!"); }
- }
- #endregion
- #region 暂停
- protected override void tsbPause_Click(object sender, EventArgs e)
- {
- ad.Pause();
- updateToolBar();
- }
- #endregion
- #region 中止
- protected override void tsbStop_Click(object sender, EventArgs e)
- {
- ad.Stop();
- updateToolBar();
- }
- #endregion
- #region 打开文件
- protected override void tsbOpen_Click(object sender, EventArgs e)
- {
- // OpenFileDialog ofd = new OpenFileDialog();
- // ofd.Filter = "All Files|*.*";
- // if (ofd.ShowDialog() != DialogResult.OK)
- // return;
- //// = ofd.FileName.ToString();
- // ad.RenderMedia(ofd.FileName, true);
- // trackBar1.Maximum = ad.MediaDuration;
- // updateToolBar();
- // labelEx1.Text = Application.StartupPath + "\\CallerWizard\\" + Path.ToString();
- }
- #endregion
- #region 音量快进
- protected override void trackBar2_Scroll(object sender, EventArgs e)
- {
- ad.MediaVol = trackBar2.Value;
- }
- #endregion
- #region 时间
- protected override void timer1_Tick(object sender, EventArgs e)
- {
- if (ad.MediaStatus == 3)
- updateSum();
- else if (ad.MediaStatus == 1)
- {
- updateToolBar();
- updateSum();
- }
- }
- private void updateSum()
- {
- lbSum.Text = string.Format("{0} / {1}", ad.MediaCurPos2, ad.MediaDuration2);
- trackBar1.Value = ad.MediaCurPos;
- }
- #endregion
- #region 关闭
- protected override void FrmPlayer_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (ad != null)
- ad.CloseMedia();
- }
- #endregion
- #region
- private void updateToolBar()
- {
- trackBar2.Enabled = trackBar1.Enabled = true;
- switch (ad.MediaStatus)
- {
- case 0:
- trackBar2.Enabled = trackBar1.Enabled = false;
- tsbPlay.Enabled = false;
- tsbPause.Enabled = false;
- tsbStop.Enabled = false;
- break;
- case 1:
- tsbPlay.Enabled = true;
- tsbPause.Enabled = false;
- tsbStop.Enabled = false;
- break;
- case 2:
- tsbPlay.Enabled = true;
- tsbPause.Enabled = false;
- tsbStop.Enabled = true;
- break;
- case 3:
- tsbPlay.Enabled = false;
- tsbPause.Enabled = true;
- tsbStop.Enabled = true;
- break;
- }
- trackBar2.Value = ad.MediaVol;
- }
- #endregion
- }
- }
|