• 大小: 468KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: 其他
  • 标签: C#,Winform  

资源简介

详细内容见博客http://blog.csdn.net/qq_34802416/article/details/77220654

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CSDNBlog
{
    public partial class Form1 : Form
    {
        private List randomList;       
        private int listIndexPointer;       //List索引
        private int removedIndex;           //用户选择的音乐,在第一轮序列中排除
        private int PlayMode = 2;           //播放模式(0=列表循环,1=单曲循环,2=随机播放)
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            odlgFile.Multiselect = true;
        }

        private void btnOpenFile_Click(object sender EventArgs e)
        {
            this.odlgFile.InitialDirectory = @“C:\Users\Rhine\Desktop\QQsound“;
            this.odlgFile.Filter = “媒体文件|*.mp3;*.wav;*.wma;*.avi;*.mpg;*.asf;*.wmv“;
            if (odlgFile.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < odlgFile.FileNames.Length; i++)
                {
                    string path = odlgFile.FileNames[i];
                    lstSong.Items.Add(path);
                }
            }
        }

        //播放列表双击事件,双击选中播放音乐
        private void lisSong_MouseDoubleClick(object sender MouseEventArgs e)
        {
            int index = lstSong.IndexFromPoint(e.Location);
            //双击的是曲目,则播放
            if (index != ListBox.NoMatches)
            {
                PlayMusic();
            }
        }

        private void btnPlay_Click(object sender EventArgs e)
        {
            //播放列表没有选中
            if(lstSong.SelectedIndex == -1)
            {
                MessageBox.Show(“请先选择要播放的音乐!“);
                return;
            }
            else
            {
                PlayMusic();
            }
        }

        private void PlayMusic()
        {
            //获得播放列表选中的曲目序号
            removedIndex = lstSong.SelectedIndex;

            if (PlayMode == 2)
            {
                //生成随机播放序列,第一轮
                randomList = GetRandomList(lstSong.Items.Count true);
            }

            //重设WindowsMediaPlayer控件的播放路径
            AxWmp.URL = lstSong.SelectedItem.ToString();
            AxWmp.Ctlcontrols.play();
        }
        
        //播放器状态改变事件
        private void AxWmp_PlayStateChange(object sender AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
        {
            //当前音乐播放完毕
            if (AxWmp.playState.ToString() == “wmppsMediaEnded“)
            {
                Console.WriteLine(“    “+lstSong.SelectedIndex + “:播放完毕“);
                //获取下一次首音乐的文件路径
                string musicPath = GetFilePath();
                //播放下一首音乐
                WMPLib.IWMPMedia media = AxWmp.newMedia(musicPath);
                AxWmp.currentPlaylist.appendItem(media);
          

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     50688  2018-01-10 16:19  CSDNBlog\.vs\CSDNBlog\v15\.suo

     文件          0  2018-01-09 18:13  CSDNBlog\.vs\CSDNBlog\v15\Server\sqlite3\db.lock

     文件    1179648  2018-01-10 16:19  CSDNBlog\.vs\CSDNBlog\v15\Server\sqlite3\storage.ide

     文件        184  2018-01-10 15:55  CSDNBlog\CSDNBlog\App.config

     文件      53760  2018-01-10 15:58  CSDNBlog\CSDNBlog\bin\Debug\AxInterop.WMPLib.dll

     文件      12800  2018-01-10 16:13  CSDNBlog\CSDNBlog\bin\Debug\CSDNBlog.exe

     文件        184  2018-01-10 15:55  CSDNBlog\CSDNBlog\bin\Debug\CSDNBlog.exe.config

     文件      24064  2018-01-10 16:13  CSDNBlog\CSDNBlog\bin\Debug\CSDNBlog.pdb

     文件     330752  2018-01-10 15:58  CSDNBlog\CSDNBlog\bin\Debug\Interop.WMPLib.dll

     文件       4293  2018-01-10 15:58  CSDNBlog\CSDNBlog\CSDNBlog.csproj

     文件       6307  2018-01-10 16:19  CSDNBlog\CSDNBlog\Form1.cs

     文件       4698  2017-08-16 11:42  CSDNBlog\CSDNBlog\Form1.Designer.cs

     文件       6697  2017-08-16 11:42  CSDNBlog\CSDNBlog\Form1.resx

     文件      53760  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\AxInterop.WMPLib.dll

     文件         42  2017-08-15 20:45  CSDNBlog\CSDNBlog\obj\Debug\CoreCompileInputs.cache

     文件         42  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.csproj.CoreCompileInputs.cache

     文件       2040  2018-01-10 16:07  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.csproj.FileListAbsolute.txt

     文件       1012  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.csproj.GenerateResource.Cache

     文件        772  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.csproj.ResolveComReference.cache

     文件       6747  2018-01-10 16:07  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.csprojResolveAssemblyReference.cache

     文件      12800  2018-01-10 16:13  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.exe

     文件        707  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.Form1.resources

     文件      24064  2018-01-10 16:13  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.pdb

     文件        180  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\CSDNBlog.Properties.Resources.resources

     文件      31647  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7063  2018-01-10 16:13  CSDNBlog\CSDNBlog\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件     330752  2018-01-10 15:58  CSDNBlog\CSDNBlog\obj\Debug\Interop.WMPLib.dll

     文件          0  2017-08-13 16:56  CSDNBlog\CSDNBlog\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2017-08-13 16:56  CSDNBlog\CSDNBlog\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2017-08-13 16:56  CSDNBlog\CSDNBlog\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

............此处省略33个文件信息

评论

共有 条评论

相关资源