大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 其他相关 -> 如何用VB程序来播放WAV文件

如何用VB程序来播放WAV文件

时间: 2021-07-31 作者:daque

wednesday, september 24 2003 1:24 pm 当确定事变实行时,步调发出一定的旗号则不妨减少步调的用户界面个性,比方鄙人载实行大概采用一个吩咐的功夫。运用一个多媒介功效,经过一个vb步调来运转wav文献是一件得心应手的工作。但是,体例必需为这一操纵而安置一个声卡。   你所须要的api因变量称为playsound,以次为该因变量的证明:   public declare function playsound lib "winmm.dll" _   alias "playsounda" (byvallpszname as string, _   byvalhmodule as long, byvaldwflags as long) _   as long    在这一因变量中,第一个变量是称呼,囊括运转的wave文献的路途。第二个变量在运转文献时常常不运用,以是你不妨将它赋值为zero。结果一个变量包括遏制因变量怎样处事的标志。   为了暂时的须要,必需须要两个标志。它们是:   snd_async (value= 1):以异步办法运转,这表示着当播放声响时因变量在运转。   snd_filename (value = &h20000):第一个变量为一个文献名。   以是,以次代码播放了dingdong.wav文献中的声响:   playsound "dingdong.wav", clng(0), _   snd_async or snd_filename    当运转在一个步调中运转音频文献时,再有其余零点犯得着提防。第一,你必需保证一个一定的音频文献生存,要不会爆发缺点。这一进程不妨用以次一个大略的因变量来实行:   public function fileexists(fullfilename) as boolean   ’ passed a filename (with path) returns   ’ true if the file exists, false if not.   dim s   s = dir(fullfilename)       if s = "" then    fileexists = false   else   fileexists = true   end if   end function  第二,步调必需具备为用户供给封闭声响的采用树立。这一进程不妨经过运用一个比方gprogramsoundsenabled的全部布尔变量来实行。   我的本领是在一个因变量中同声处置那些须要,如次所示。(以次代码假如音频文献仍旧寄存在步调文献中)   private sub playsoundx(filename as string)   ’ if sound is enabled and filename exists,   ’ play the specified sound.   filename = app.path & "\" & filename   if fileexists(filename) and gprogramsoundsenabled then    playsound filename, clng(0), snd_async or snd_filename   end if   end sub    精确运用那些因变量,步调就不妨播纵容何wave文献,如次所示:   playsoundx "dingdong.wav"    从vb步调播放音频文献的其余本领囊括窗体上的多媒介遏制。当你不须要那些遏制个性时,之上报告的本领仍旧充满,而且很简单控制。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.