国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
API播放mp3,mid,wav格式音頻 C#相對路徑解決方法
API播放mp3,mid,wav格式音頻 C#相對路徑解決方法
2009年06月02日 星期二 14:12

        //文件路徑

        public static string path = AppDomain.CurrentDomain.BaseDirectory + @"..\..\sound\";

        #region 調(diào)用AP函數(shù)I播放音樂,要用到   mciSendString
        /// <summary>
        /// 播放MP3格式的音頻文件方法
        /// </summary>
        /// <param name="lpstrCommand"></param>
        /// <param name="lpstrReturnString"></param>
        /// <param name="uReturnLength"></param>
        /// <param name="hwndCallback"></param>
        /// <returns></returns>
        [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
        public static extern int mciSendString(
        string lpstrCommand,//Pointer to a null-terminated string that specifies an MCI command string. For a list, see Multimedia Command Strings.
        string lpstrReturnString,//Pointer to a buffer that receives return information. If no return information is needed, this parameter can be NULL.
        int uReturnLength,//Size, in characters, of the return buffer specified by the lpszReturnString parameter.
        int hwndCallback);//Handle to a callback window if the "notify" flag was specified in the command string.
       
        /// <summary>
        /// 播放MID格式音頻的方法
        /// </summary>
        /// <param name="lpstrCommand"></param>
        /// <param name="lpstrReturnString"></param>
        /// <param name="uReturnLength"></param>
        /// <param name="hwndCallback"></param>
        /// <returns></returns>
        [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
        public static extern long mciExecute(
        string lpstrCommand,//Pointer to a null-terminated string that specifies an MCI command string. For a list, see Multimedia Command Strings.
        string lpstrReturnString,//Pointer to a buffer that receives return information. If no return information is needed, this parameter can be NULL.
        int uReturnLength,//Size, in characters, of the return buffer specified by the lpszReturnString parameter.
        int hwndCallback);//Handle to a callback window if the "notify" flag was specified in the command string.
        #endregion

        #region mp3和mid文件的播放方法
        /// <summary>
        /// 背景音樂播放方法
        /// </summary>
        /// <param name="path"></param>
        private void playMID(string path)
        {
            mciExecute("Open " + path + " alias mid", null, 0, 0);
            mciExecute("Play mid", null, 0, 0);
        }

        /// <summary>
        /// 背景音樂停止方法
        /// </summary>
        private void pauseMID()
        {
            mciExecute("Close mid", null, 0, 0);
        }

        public void playWAV(string path)
        {
            mciSendString("Open " + path + " alias wavType", null, 0, 0);
            mciSendString("Play wavType", null, 0, 0);
        }

        public void pauseWAV()
        {
            mciSendString("Close wavType", null, 0, 0);
        }
        #endregion

       //在窗體加載事件里調(diào)用上面的兩個(gè)方法來播放mp3和mid

         private void Form1_Load(object sender, EventArgs e)
        {

            this.playMID(path + "back2.mid");

            this.playWAV(path + "back.mp3");//此方法也可以播放WAV格式音頻文件

        }


本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
在游戲中播放音樂 -- EasyX Library for C++
C++ 播放聲音
做個(gè)mp3播放器
項(xiàng)目經(jīng)驗(yàn)分享——Java常用工具類集合
Java讀取FTP上的txt文件
struts 1.2 文件上傳與下載
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服