标签:img 头部 技术 meta 中间 doc cal mic initial
下载AudioPlayer - 440.79 KB 介绍 在本文中,我使用多媒体MCI控件来制作动画作为定时器控制。您可以使用StatusUpdate事件来完成此操作。StatusUpdate事件会在你给UpdateInterval属性合适的值>时自动发生。0精确地作为定时器控制间隔。 背景 使用多媒体MCI控件,你必须知道StatusUpdate事件允许应用程序更新显示,以通知用户当前MCI设备的状态,如位置、长度和模式。可以为UpdateInterval属性设置任何正值(以毫秒为单位)。如果该值很小,则显示速度快,如果值很大,则显示速度慢,但如果该值为0,则不会发生StatusUpdate事件。 我的表单有一些控件: mciWave (MMControl),不可见ImageList1包括30个图像ImageList2包括6 dancepic图片(图片框)来保存图像ImageList2包括moviepic(图片框)来保存图像ImageList1包括btnplay(按钮)来执行(玩)命令btnpause(按钮)来执行(停顿)命令btnstop(按钮)来执行(停止)命令btnopen(按钮)加载音乐文件songname(标签)文件名songtime(标签)时间长度的文件elapsedtime(标签)下载音乐文件格式(mid, mp3, wav, wma) 使用的代码 在声明中将UpdateInterval属性的值50作为常量。请参考声明部分中的其他变量。 LoadMusicFile()过程: 隐藏,复制Code
‘ ‘ Set the number of milliseconds =0, let StatusUpdate events not occurred.: ‘ mciWave.UpdateInterval = 0 ‘ ‘ Display the File Open dialog box: ‘ With CommonDialog1 .FilterIndex = 1 .Flags = cdlOFNReadOnly Or cdlOFNFileMustExist .CancelError = True .FileName = "" .Filter = "Sound Formats|*.mid;*.mp3;*.wav;*.wma|mid (*.mid)| *.mid|mp3 (*.mp3)|*.mp3|wav (*.wav)|*.wav|wma (*.wma)|*.wma" .DialogTitle = "Choose sound file..." End With CommonDialog1.ShowOpen If Err <> 0 Then ‘ No file selected to play. Exit Sub End If MusicFile = CommonDialog1.FileName MusicName = CommonDialog1.FileTitle InitPlay ‘ Go to InitPlay() procedure
InitPlay()过程: 隐藏,复制Code
‘ ‘ Close a device if open: ‘If Not mciWave.Mode = mciModeNotOpen ‘Then mciWave.Command = "Close" End If ‘ ‘ Opens a device using the MCI_OPEN command: ‘mciWave.Command = "Open" ‘ Time of the song: mciWave.TimeFormat = mciFormatMilliseconds msec = (CDbl(mciWave.Length) / 1000)
btnPlay_Click()过程: 隐藏,复制Code
‘ ‘ Set the number of milliseconds = ConInterval, let StatusUpdate events: ‘ mciWave.UpdateInterval = ConInterval ‘ ‘ Plays a device using the MCI_PLAY command: ‘ mciWave.Command = "Play"
btnPause_Click()过程: 隐藏,复制Code
‘ ‘ StatusUpdate events not occurred: ‘ mciWave.UpdateInterval = 0 ‘ ‘ Pauses playing using the MCI_PAUSE command: ‘ mciWave.Command = "Pause"
btnStop_Click()过程: 隐藏,复制Code
‘ ‘ StatusUpdate events not occurred: ‘ mciWave.UpdateInterval = 0 ‘ ‘ Stops playing using the MCI_STOP command: ‘ mciWave.Command = " Stop"
mciWave_StatusUpdate()过程: 隐藏,收缩,复制Code
‘ ‘ If the device is not playing, reset to the beginning: ‘ If mciWave.Position = mciWave.Length Then mciWave.UpdateInterval = 0 ‘ no StatusUpdate events occur. Exit Sub End If ‘ ‘ Determine how much of the file has played: ‘ CurrentValue = mciWave.Position Value = CDbl((CurrentValue / 1000)) ‘ ‘ view elapsed time: ‘ ElapsedTime.Caption = Format$(Value, "00:00") ‘ ‘ Wait a moment before change new picture from ImageList2: ‘ Counter = Counter + 1: If Counter = 25 Then Counter = 0 ‘ view dance picture from ImageList2: If(Counter / 5) = Int(Counter / 5)Then PicNum = Counter / 5 + 1 DancePic.Picture = ImageList2.ListImages(PicNum).Picture End If ‘ ‘ Wait a moment before change new picture from ImageList1: ‘ MasterCounter = MasterCounter + 1:If MasterCounter = 1500 ThenMasterCounter = 0 ‘ view dance picture from ImageList1: If (MasterCounter / 50) = Int(MasterCounter / 50) Then ImgNum = MasterCounter / 50 + 1 MoviePic.Picture = ImageList1.ListImages(ImgNum).Picture ‘ view new picture End If
您可以返回到项目AudioPlayer的源文件来阅读完整的代码。有关更多帮助,您可以参考Visual Basic帮助中的多媒体MCI控件。 讲话 在解压AudioPlayer.zip文件时,您可以找到项目AudioPlayer的源文件。 最后一句话 我希望本文对您有用,并帮助您使用MMControl作为定时器创建一些应用程序。如果你有任何想法或发现任何问题,请告诉我。感谢代码项目和所有人。 历史 2008年2月2日:初始版本 本文转载于:http://www.diyabc.com/frontweb/news2486.html
标签:img 头部 技术 meta 中间 doc cal mic initial
原文地址:https://www.cnblogs.com/augustuss/p/13455051.html