示例#1
0
        private void btn_play_Click(object sender, EventArgs e)
        {
            if (_mp.Media is null)
            {
                return;
            }
            if (_mp.IsPlaying)
            {
                _mp.Pause();
                btn_play.InvokeIfRequired(l => l.Text = "Play");
                foreach (var i in _lsPlays)
                {
                    i.Player.Pause();
                }
                return;
            }
            if (_mp.CanPause)
            {
                _mp.Play();

                return;
            }

            //for(int i=0;i< cklistbox.CheckedItems.Count; i++)
            //{
            //    string outpath = Path.Combine(Environment.CurrentDirectory, "Audio");
            //    outpath = Path.Combine(outpath, $"{cklistbox.CheckedItems[i]}.mp3");
            //    Debug.WriteLine(outpath);
            //    media.AddSlave(MediaSlaveType.Audio,(uint)i , $"file:///" + outpath);
            //}
            string outpath = Path.Combine(Environment.CurrentDirectory, "video_audio.mp3");

            _mp.AddSlave(MediaSlaveType.Audio, $"file:///" + outpath, false);
            Task.Run(() =>
            {
                //PlayMedia(_lsPlays);

                _mp.SetRate(rate);
                Task.Delay(2000).Wait();
                _mp.Play();
            });
        }