您的位置:程序门 -> .net技术 -> c#



用winmm.dll播放wav文件,怎么知道wav文件播放时间长度?或者播放结束后有事件通知?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


用winmm.dll播放wav文件,怎么知道wav文件播放时间长度?或者播放结束后有事件通知?
发表于:2007-01-23 10:25:29 楼主
public   class   sound
{
public   sound()
{
//
//   todo:   在此处添加构造函数逻辑
//
}

public   static   void   play(   string   strfilename,   playsoundflags   soundflags)  
{
playsound(   strfilename,   intptr.zero,   soundflags);
//   passes   to   playsound   the   filename   and   a   pointer
//   to   the   flag
}

[dllimport( "winmm.dll ")]   //inports   the   winmm.dll   used   for   sound
private   static   extern   bool   playsound(   string   szsound,   intptr   hmod,   playsoundflags   flags   );
}
[flags]   //enumeration   treated   as   a   bit   field   or   set   of   flags
public   enum   playsoundflags:   int  
{
snd_sync   =   0x0000,   /*   play   synchronously   (default)   */
snd_async   =   0x0001,   /*   play   asynchronously   */
snd_nodefault   =   0x0002,   /*   silence   (!default)   if   sound   notfound   */
snd_loop   =   0x0008,   /*   loop   the   sound   until   nextsndplaysound   */
snd_nostop   =   0x0010,   /*   don 't   stop   any   currently   playingsound   */
snd_nowait   =   0x00002000,   /*   don 't   wait   if   the   driver   is   busy   */
snd_filename   =   0x00020000,   /*   name   is   file   name   */
snd_resource   =   0x00040004   /*   name   is   resource   name   or   atom   */  
}
发表于:2007-06-13 16:53:421楼 得分:0
帮顶一下,我近期也在找这个功能,读取媒体文件播放时间.


快速检索

最新资讯
热门点击