• AxWindowsMediaPlayer创建、添加播放列表(C#)


    // 创见打开对话框对象实例
                OpenFileDialog openFileDialog = new OpenFileDialog();

                //设置为可以打开多个文件
                openFileDialog.Multiselect = true;

                //设置打开文件格式
                openFileDialog.Filter = "Mp3文件|*.mp3|Wav文件|*.wav|Wma文件|*.wma|Wmv文件|*.wmv|所有格式|*.*";

                //判断是否单击确定按钮
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //建立播放列表,名字为aa
                    axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.newPlaylist("aa", "");

                    //遍历打开的集合
                    foreach (string fn in openFileDialog.FileNames)
                    {
                        //添加播放列表
                        axWindowsMediaPlayer1.currentPlaylist.appendItem(axWindowsMediaPlayer1.newMedia(fn));
                    }
                }
                //播放
                axWindowsMediaPlayer1.Ctlcontrols.play();
            }

    *************************************************************************

    创建一个音乐对象的LIST来存放 对这个List进行操作
    播放的时候用wmpPlayer.currentMedia.sourceURL获取List中具体的音乐

    **************************************************************************

    c#直接有mediaplayer工具,可在工具箱里添加。播放音乐列表的代码:  

         if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.newPlaylist("fy","");

                foreach (string strFile in openFileDialog1.FileNames)
                {
                   axWindowsMediaPlayer1.currentPlaylist.appendItem(axWindowsMediaPlayer1.newMedia(strFile));
                    axWindowsMediaPlayer1.Ctlcontrols.play();
                }

           }

    ******************************************************

  • 相关阅读:
    【leetcode】Maximum Subarray
    【USACO】
    【leetcode】Remove Duplicates from Sorted Array
    【leetcode】Path Sum II
    【leetcode】Swap Nodes in Pairs
    【leetcode】Word Ladder
    【leetcode】Copy List with Random Pointer
    【leetcode】Longest Palindromic Substring
    #ifdef #endif #if #endif
    tar [options] [list of file]
  • 原文地址:https://www.cnblogs.com/wanzhongjun/p/6263485.html
Copyright © 2020-2023  润新知