新聞中心

        EEPW首頁 > 消費電子 > 設計應用 > C#中用API實現MP3等音頻文件的播放類

        C#中用API實現MP3等音頻文件的播放類

        作者: 時間:2009-06-15 來源:網絡 收藏

        public void StopT()

        {

          TemStr = ;

          TemStr = TemStr.PadLeft(128,Convert.ToChar( ));

          ilong = Class.mciSendString(close media, TemStr, 128, 0);

          ilong = Class.mciSendString(close all, TemStr, 128, 0);

          mc.state = State.mStop ;

        }

        public void Puase()

        {

          TemStr = ;

          TemS

        tr = TemStr.PadLeft(128,Convert.ToChar( ));

          ilong = Class.mciSendString(pause media, TemStr, TemStr.Length, 0);

          mc.state = State.mPuase ;

        }

        private string GetCurrPath(string name)

        {

          if(name.Length 1) return ;

          name = name.Trim();

          name = name.Substring(0,name.Length-1);

          return name;

        }

        //總時間

        public int Duration

        {

          get

          {

        durLength = ;

        durLength = durLength.PadLeft(128,Convert.ToChar( )) ;

        APIClass.mciSendString(status media length, durLength, durLength.Length, 0);

        durLength = durLength.Trim();

        if(durLength == ) return 0;

        return (int)(Convert.ToDouble(durLength) / 1000f);

          }

        }

        //當前時間

        public int CurrentPosition

        {

          get

          {

        durLength = ;

        durLength = durLength.PadLeft(128,Convert.ToChar( )) ;

        APIClass.mciSendString(status media position, durLength, durLength.Length, 0);

        mc.iPos = (int)(Convert.ToDouble(durLength) / 1000f);

        return mc.iPos;

          }

        }

          }

          public class APIClass

          {

        [DllImport(kernel32.dll, CharSet = CharSet.Auto)]

        public static extern int GetShortPathName (

          string lpszLongPath,

          string shortFile,

          int cchBuffer

        );

        [DllImport(winmm.dll, EntryPoint=mciSendString, CharSet = CharSet.Auto)]

        public static extern int mciSendString (

          string lpstrCommand,

          string lpstrReturnString,

          int uReturnLength,

          int hwndCallback

        );

          }

        }


        上一頁 1 2 下一頁

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 门源| 化州市| 正镶白旗| 五台县| 姜堰市| 额济纳旗| 澳门| 任丘市| 巴马| 鹤山市| SHOW| 闽清县| 中江县| 五常市| 谷城县| 行唐县| 镇赉县| 平山县| 涞水县| 融水| 庆城县| 平泉县| 和政县| 勐海县| 新泰市| 临朐县| 淮安市| 肃南| 丹江口市| 卫辉市| 疏勒县| 腾冲县| 大石桥市| 富源县| 靖宇县| 苍南县| 都江堰市| 阜新市| 五莲县| 万州区| 行唐县|