模拟电子钟 带语音报时功能
上面的九个按钮,分别表示九种功能.和普通的录音机上的按钮类似,从左到右分别是:Prev (向前) , Next (向后) , Play (播放) , Pause (暂停) , Back (快速倒带) , Step (快速进带) , Record ( 录音 ) ,和Eject (弹出).
使用时,先要为MMContorl控件指定一个要播放的文件,然后用Open命令打开它.然后再使用Play命令播放文件.最后关闭所打开的文件.
下面我们看看怎样用MMControl来实现语音报时功能.
下面是代码(我们这里主要给出所改动的地方):
‘ = = = = = = = = = = = = = = = = = = = = = = = =
‘ 每秒钟触发一次此事件,从而获取当时的时间,并调用相应的函数,画出三个针的位置 ‘ = = = = = = = = = = = = = = = = = = = = = = = = Private Sub Timer1 _ Timer ( ) miao = Second (time) miao = 60 – miao fen = Minute (time) fen = 60 - fen
shi = Hour (time)
If shi > = 12 Then ‘因为一天之内时针要走二十四个钟头,也就是要走两圈,所以将下午和晚上的时间减去十二,就可以确定时针准确的位置 shi = shi - 12 End If
shi = 12 - shi
miao = xianshimiao ( maio )
fen = xianshifen ( fen ) shi = xianshishi ( shi )
If fen = 0 and miao = 0 then ‘如果分针和秒针都为零,这位整点,根据时针的数报时 Select case shi
Case 0 ‘零点,0.wav报时零点
MMControl1.FileName = App . Path & “ 0.wav ” ‘选择要打开的文件 mond = “ Open ” ‘打开所选择的文件 mond = “ Play ” ‘播放所选择的文件 Case 1 ‘ 一点,1.wav报时一点,以下依次类推
MMControl1.FileName = App . Path & “ 1.wav ” ‘选择要打开的文件 mond = “ Open ” ‘打开所选择的文件 mond = “ Play ” ‘播放所选择的文件 Case 2
MMControl1.FileName = App . Path & “ 2.wav ” mond = “ Open ” mond = “ Play ” Case 3