看得破的人,处处都是生机;

看不破的人,处处都是困境;

拿得起的人,处处都是担当;

拿不起的人,处处都是疏忽;

放得下的人,处处都是大道;

放不下的人,处处都是迷茫;

想得开的人,处处都是春天;

想不开的人,处处都是凋枯;

做何人,在自己;

小自我,大天地;

c# 播放MP3音乐

摘录网上的:

        /// <summary>
        /// 使用API
        /// </summary>
        public static uint SND_ASYNC = 0x0001; // play asynchronously 
        public static uint SND_FILENAME = 0x00020000; // name is file name
        [DllImport("winmm.dll")]
        public static extern int mciSendString(string m_strCmd, string m_strReceive, int m_v1, int m_v2);
        [DllImport("Kernel32", CharSet = CharSet.Auto)]
        static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength); 

        private void button1_Click(object sender, EventArgs e)
        {
            string name = "a bottle of.mp3";
            if (File.Exists(name))
            {
                StringBuilder shortpath = new StringBuilder(80);
                int result = GetShortPathName(name, shortpath, shortpath.Capacity);
                name = shortpath.ToString();
                mciSendString(@"close all", null, 0, 0);
                mciSendString(@"open " + name + " alias song", null, 0, 0); //打开
                mciSendString("play song", null, 0, 0); //播放
            }
        }

  

posted @ 2014-10-16 13:05  心电心  阅读(224)  评论(0)    收藏  举报