Exemplo n.º 1
0
        private bool ValidatePPSOperate(SoundPlayerStatus targetStatus)
        {
            if (!this.HandleValid())
            {
                string operate;
                switch (targetStatus)
                {
                case SoundPlayerStatus.Playing:
                    operate = "播放";
                    break;

                case SoundPlayerStatus.Paused:
                    operate = "暂停";
                    break;

                case SoundPlayerStatus.Stoped:
                    operate = "停止";
                    break;

                default:
                    throw new NotImplementedException($"未实现的操作状态{targetStatus.ToString()}验证");
                }

                throw new WavException($"执行{operate}操作失败,未加载音频数据");
            }

            if (this._status == targetStatus)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     if (this.ValidatePPSOperate(SoundPlayerStatus.Stoped))
     {
         this._status = SoundPlayerStatus.Stoping;
         WavHelper.ChannelStop(this._handle);
         this._status = SoundPlayerStatus.Stoped;
         this.OnPlayStatusChanged();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 暂停
 /// </summary>
 public void Pause()
 {
     if (this.ValidatePPSOperate(SoundPlayerStatus.Paused))
     {
         this._status = SoundPlayerStatus.Pausing;
         WavHelper.ChannelPause(this._handle);
         this._status = SoundPlayerStatus.Paused;
         this.OnPlayStatusChanged();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 播放
 /// </summary>
 public void Play()
 {
     if (this.ValidatePPSOperate(SoundPlayerStatus.Playing))
     {
         this._status = SoundPlayerStatus.StartPlaying;
         WavHelper.ChannelPlay(this._handle, this.Status == SoundPlayerStatus.Stoped);
         this._status = SoundPlayerStatus.Playing;
         this.OnPlayStatusChanged();
     }
 }