示例#1
0
 public void AddAudioFile(AudioModel playfile)
 {
     if (PlayList.Contains(playfile) != true)
     {
         PlayList.Add(playfile);
     }
 }
示例#2
0
        public bool JumpPlay(int index)
        {
            if (PlayList == null)
            {
                return(false);
            }

            if (index < 0 && index >= PlayList.Count - 1)
            {
                return(false);
            }

            Closed();

            _nowPlayData = PlayList[index];

            Open();

            SetVolume(PlayVolume);

            Play();

            _playindex = index;

            return(true);
        }
示例#3
0
        public bool PreviousPlay()
        {
            if (PlayList == null)
            {
                return(false);
            }

            if (_playindex - 1 < 0)
            {
                return(false);
            }

            Closed();

            _nowPlayData = PlayList[_playindex - 1];

            Open();

            SetVolume(PlayVolume);

            Play();

            _playindex = _playindex - 1;

            return(true);
        }
示例#4
0
        public bool NextPlay()
        {
            if (PlayList == null)
            {
                return(false);
            }

            if (_playindex + 1 >= PlayList.Count)
            {
                return(false);
            }

            Closed();

            _nowPlayData = PlayList[_playindex + 1];

            Open();

            SetVolume(PlayVolume);

            Play();

            _playindex = _playindex + 1;

            return(true);
        }
示例#5
0
        public AudioPlayHelper(List <AudioModel> playList)
        {
            PlayList     = new List <AudioModel>(playList);
            _nowPlayData = PlayList[0];
            _playindex   = 0;

            var playTimer = new Timer
            {
                Enabled  = true,
                Interval = 1000
            };

            playTimer.Tick += playTimer_Tick;
        }
示例#6
0
        public AudioPlayHelper(AudioModel playdata)
        {
            _nowPlayData = (AudioModel)playdata.Clone();
            PlayList.Add(_nowPlayData);
            _playindex = 0;

            var playTimer = new Timer
            {
                Enabled  = true,
                Interval = 1000
            };

            playTimer.Tick += playTimer_Tick;
        }
示例#7
0
        public AudioPlayHelper()
        {
            _playindex = -1;

            PlayList = new List <AudioModel>();

            _nowPlayData = new AudioModel();

            var playTimer = new Timer
            {
                Enabled  = true,
                Interval = 1000
            };

            playTimer.Tick += playTimer_Tick;
        }
示例#8
0
        public void RemoveAudioFile(AudioModel playaudio)
        {
            if (PlayList.Contains(playaudio) != true)
            {
                return;
            }

            if (playaudio.Equals(_nowPlayData))
            {
                Closed();
            }

            PlayList.Remove(playaudio);

            if (_playindex >= 0 && _playindex < PlayList.Count)
            {
                _nowPlayData = PlayList[_playindex];
            }
        }
示例#9
0
        private void playTimer_Tick(object sender, EventArgs e)
        {
            if (PlayState != PlayState.Playing)
            {
                return;
            }

            DoOrder(string.Format("status {0} position", _nowPlayData.AliasMovie), _nowplaytime, _nowplaytime.Capacity);

            var returntimeThread = new Thread(ThreadReturnTime)
            {
                IsBackground = true
            };

            returntimeThread.Start(_nowplaytime);

            if (!_nowplaytime.Equals(PlayLenght))
            {
                return;
            }

            Closed();

            _palystate = PlayState.Closed;

            if (EventAudioPlayEnd != null)
            {
                EventAudioPlayEnd();
            }

            if (IsRandLoop)
            {
                _random = new Random((int)DateTime.Now.Ticks);

                _playindex = _random.Next(0, PlayList.Count);

                _nowPlayData = PlayList[_playindex];

                JumpPlay(_playindex);

                return;
            }

            if (IsListLoop)
            {
                if (_playindex + 1 >= PlayList.Count)
                {
                    _playindex = 0;
                }
                else
                {
                    _playindex = _playindex + 1;
                }

                _nowPlayData = PlayList[_playindex];

                JumpPlay(_playindex);

                return;
            }

            if (!IsSingleLoop)
            {
                return;
            }

            JumpPlay(_playindex);
        }