示例#1
0
 /// <summary>
 /// 暂停
 /// </summary>
 public void Puase()
 {
     if (m.State == PlayState.Playing)
     {
         WAPI.mciSendString("Pause Media", null, 0, 0);
         m.State = PlayState.Puased;
     }
 }
示例#2
0
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     if (m.State != PlayState.Stopped)
     {
         WAPI.mciSendString("Stop Media", null, 0, 0);
         m.State = PlayState.Stopped;
     }
 }
示例#3
0
 /// <summary>
 /// 播放
 /// </summary>
 public void Play()
 {
     if (m.State != PlayState.Playing)
     {
         WAPI.mciSendString("Play Media", null, 0, 0);
         m.State = PlayState.Playing;
     }
 }
示例#4
0
        /// <summary>
        /// 设备初始化
        /// </summary>
        private void InitDevice()
        {
            string DeviceID = GetDeviceID(Url);          //返回类型

            WAPI.mciSendString("Close All", null, 0, 0); //关闭所有设备
            if (DeviceID != "RealPlay")
            {
                string MciCommand = String.Format("Open {0} type {1} Alias Media", Url, DeviceID);
                WAPI.mciSendString(MciCommand, null, 0, 0);//初始化设备
                m.State = PlayState.Stopped;
            }
        }
示例#5
0
        private int GetDuration()
        {
            string Length = string.Empty;

            Length = Length.PadLeft(20, ' ');//设置定长字符串long是19位,足够表示时间了
            WAPI.mciSendString("Status Media Length", Length, Length.Length, 0);
            Length = Length.Trim();
            if (Length.Length > 1)
            {
                Length = Length.Substring(0, Length.Length - 1);
                return((int)(long.Parse(Length) / 1000));
            }
            return(0);
        }
示例#6
0
        /// <summary>
        /// 设备是否准备就绪
        /// </summary>
        /// <returns></returns>
        public bool IsReady()
        {
            string Ready = new string(' ', 10);

            WAPI.mciSendString("Status Media Ready", Ready, Ready.Length, 0);
            Ready = Ready.Trim();
            if (Ready.Contains("true"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
0
        //设置静音
        public void VolumeOff(bool IsOff)
        {
            string SetOnOff = string.Empty;

            if (IsOff)
            {
                SetOnOff = "Off";
            }
            else
            {
                SetOnOff = "On";
            }
            string MciCommand = String.Format("Set Audio Media {0}", SetOnOff);

            WAPI.mciSendString(MciCommand, null, 0, 0);
        }
示例#8
0
        /// <summary>
        /// 恢复播放
        /// </summary>
        public void Resume()
        {
            int RefInt = WAPI.mciSendString("Resume Media", null, 0, 0);

            m.State = PlayState.Playing;
        }