ÓÃVB²¥·ÅAvi¡¢Wave¡¢midiµÄÎļþ_VB.net_ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØ--Powered by WWW.RONGSEN.COM.CN

ÓÃVB²¥·ÅAvi¡¢Wave¡¢midiµÄÎļþ

×÷ÕߣººÚ¿Í·ÀÏßÍø°²VB½Ì³Ì»ùµØ À´Ô´£ººÚ¿Í·ÀÏßÍø°²VB½Ì³Ì»ùµØ ä¯ÀÀ´ÎÊý£º0

±¾Æª¹Ø¼ü´Ê£ºÎļþ²¥·Å'&
ºÚ¿Í·ÀÏßÍø°²ÍøѶ£º     CsdnÉÏÒѾ­ÓкöàÅóÓÑÎʹýÖîÈ磺¡°ÈçºÎ²¥·ÅAvi¡¢Wave¡¢midiÎļþ¡±¡¢£º¡°Ë­ÖªµÀÓÃapi²¥·Åavi,mpgµÄÏêϸ·½·¨£¿Òª¿ÉÒÔÉ趨½«Í¼Ïñ·ÅÖõ½É趨µÄ´°ÌåÖС±¡¢¡°ÈçºÎͬʱ²¥·ÅÁ½¸öWavÎļþ¡±µÄÎÊÌâ...
     CsdnÉÏÒѾ­ÓкöàÅóÓÑÎʹýÖîÈ磺
¡°ÈçºÎ²¥·ÅAvi¡¢Wave¡¢midiÎļþ¡±¡¢£º
¡°Ë­ÖªµÀÓÃapi²¥·Åavi,mpgµÄÏêϸ·½·¨£¿Òª¿ÉÒÔÉ趨½«Í¼Ïñ·ÅÖõ½É趨µÄ´°ÌåÖС±¡¢
¡°ÈçºÎͬʱ²¥·ÅÁ½¸öWavÎļþ¡±
µÄÎÊÌ⣬
ÆäʵÓÃÒ»¸öÀàÄ£¿é¾ÍÒ»Çи㶨£¬²»ÐèҪʲô¿Ø¼þÖ®ÀàµÄ¶«Î÷
ÏÂÃæÕâ¸öÀàÄ£¿é,ÎÒÑо¿ºó½«ËüÐ޸ĵøüºÃÓÃÁË
½«ÏÂÃæÕâ¸öÀàÄ£¿é´æΪMmedia.cls
'----------------------------------------------------
Option Explicit
'--------------TrueZq ×îиüÐÂ2001-01-12---------------------
'ÎļþÃû£º MMedia.cls
'˵Ã÷£º : Ò»¸ö¶àýÌåÀà,Äܲ¥·ÅAvi¡¢Wave¡¢MidiÎļþ
'Ó÷¨£º
'Dim Multimedia As New Mmedia
'Multimedia.mmOpen "c: est.wav"
'Multimedia.mmPlay
'£¡¼Çס£ºÔÚ³ÌÐò½áÊøʱ£¬Ò»¶¨ÒªÓÃSet Multimedia=nothingÊÍ·Å×ÊÔ´£¡£¡£¡
'-----------------------------------------------------
' -=-=-=- ÊôÐÔ -=-=-=-
' sFilename µ±Ç°µÄÎļþÃû
' nLength Îļþ³¤¶È£¨Ö»¶Á£©
' nPosition µ±Ç°Î»ÖÃ
' sStatus µ±Ç°×´Ì¬£¨Ö»¶Á£©
' bWait True/False.¾ö¶¨ÊÇ·ñµÈ´ý²¥·ÅÍê
' -=-=-=- ·½·¨ -=-=-=-=-
' mmOpen <Filename> ´ò¿ªÒª²¥·ÅµÄÎļþ
' mmClose ¹Ø±Õµ±Ç°Îļþ
' mmPause ÔÝÍ£
' mmStop Í£Ö¹ Í£Ö¹ºó¿ÉÒÔÌøµ½¿ªÊ¼Ôٴβ¥·Å
' mmSeek <Position> Seeks to a position in the file
' mmPlay ²¥·Å
'--------------------------------------------------------------
Private sAlias As String '±ðÃû
'Private hWnd As Long
Private sFilename As String ' µ±Ç°µÄÎļþÃû
Private nLength As Single ' Îļþ³¤¶È
Private nPosition As Single ' µ±Ç°Î»ÖÃ
Private sStatus As String ' µ±Ç°×´Ì¬
Private bWait As Boolean ' ¾ö¶¨ÊÇ·ñµÈ´ý²¥·ÅÍê
Const WS_CHILD = &H40000000
'------------ API ÉùÃ÷ -------------
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long
'Private Declare Function GetActiveWindow Lib "USER32" () As Integer
'µ±sTheFileÊÇÒ»¸öAviÎļþʱ£¬²ÎÊýhWndÖ¸¶¨¶¯»­ÔÚÄÄÀï²¥·Å
'ÈôhWnd=0£¬ÔòпªÒ»¸ö´°¿Ú²¥·Å¶¯»­¡£
'Èç¹ûÌý²»µ½MidiÒôÀÖ£¬ÇëÔÚWindowsÏÂÓÃýÌå²¥·ÅÆ÷²âÊÔһϡ£
'ÎļþÃû²»ÄÜ´ø¿Õ¸ñ
Public Sub mmOpen(ByVal sTheFile As String, Optional hWnd As Long = 0)
Dim nReturn As Long
Dim sType As String 'ÎļþÀàÐÍ
Static nNum As Integer
If sAlias <> "" Then '¹Ø±Õ¿ªÊ¼´ò¿ªµÄÎļþ
mmClose
End If
If (Dir(sTheFile) = "") Then 'ÅжÏÊÇ·ñÊÇÒ»¸ö´æÔÚµÄÎļþ
sFilename = "Îļþ" & sTheFile & " ²»´æÔÚ£¡"
Exit Sub
Else
sFilename = sTheFile
' nNum = nNum + 1
End If
' Stop
sAlias = sFilename 'ÓÃÎļþÃû×÷±ðÃû£¬±ÜÃâ±ðÃû³åÍ»£¡
' ÅжÏÎļþÀàÐÍ
Select Case UCase$(Right$(sTheFile, 3))
Case "WAV"
sType = "Waveaudio"
Case "AVI"
sType = "AviVideo"
Case "MID"
sType = "Sequencer"
Case Else
' δ֪Îļþ¸ñʽ£¬Í˳ö¡£
Exit Sub
End Select
If sType = "AviVideo" And hWnd > 0 Then
nReturn = mciSendString("open " & sTheFile & " ALIAS " & sAlias _
& " TYPE AVIVideo parent " & hWnd & " style " & LTrim$(Str$(WS_CHILD)), 0&, 0, 0)
Else
nReturn = mciSendString("Open " & sTheFile & " ALIAS " & sAlias _
& " TYPE " & sType, "", 0, 0)
End If
End Sub
'¹Ø±Õµ±Ç°´ò¿ªµÄ¶àýÌåÎļþ
Public Sub mmClose()
Dim nReturn As Long
'Èç¹ûûÓÐÎļþ´ò¿ª£¬ÔòÍ˳ö
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Close " & sAlias, "", 0, 0)
sAlias = ""
sFilename = ""
End Sub
'ÔÝÍ£
Public Sub mmPause()
Dim nReturn As Long
If sAlias = "" Then
Exit Sub
ElseIf Status = "paused" Then 'Èç¹ûÏÈÇ°ÒѾ­ÔÝÍ£ÁË£¬Ôò½â³ýÔÝÍ£
mmPlay
Else
nReturn = mciSendString("Pause " & sAlias, "", 0, 0)
End If
'nPosition = Position
End Sub
'²¥·Å
Public Sub mmPlay()
Dim nReturn As Long
If sAlias = "" Then
Exit Sub
ElseIf Position = Length Then 'Èç¹ûÒѾ­µ½Ä©Î²
mmSeek 0 'Ìøµ½¿ªÊ¼´¦
End If
If bWait Then
nReturn = mciSendString("Play " & sAlias & " wait", "", 0, 0)
Else
nReturn = mciSendString("Play " & sAlias, "", 0, 0)
End If
End Sub
'Í£Ö¹
'Í£Ö¹ºóÌøµ½¿ªÊ¼,ÒÔ±ãÔٴβ¥·Å
Public Sub mmStop()
Dim nReturn As Long
If sAlias = "" Then Exit Sub
nReturn = mciSendString("Stop " & sAlias, "", 0, 0)
mmSeek 0 'Ìøµ½¿ªÊ¼Î»ÖÃ
End Sub
'Ìøµ½Ö¸¶¨µÄλÖÃ,²¢ÇÒ´¦ÓÚÔÝͣ״̬
'µ±nPositionµÄÖµ>Length »òÕßnPosition<0ʱ£¬½«ºöÂÔÕâ´Î²Ù×÷
Public Sub mmSeek(ByVal nPosition As Single)
Dim nReturn As Long
nReturn = mciSendString("Seek " & sAlias & " to " & nPosition, "", 0, 0)
End Sub
'·½·¨Filename·µ»Øµ±Ç°´ò¿ªµÄÎļþÃû
Property Get filename() As String
filename = sFilename
End Property
'Ö¸¶¨Òª²¥·ÅµÄÎļþÃû£¬È»ºó½«Ëü´ò¿ª
'¶ÔÓÚÐèÒªÖ¸¶¨ÈÝÆ÷µÄAviÎļþ£¬²»ÒªÒÔÕâÖÖ·½Ê½´ò¿ª¡£
Property Let filename(ByVal sTheFile As String)
mmOpen sTheFile
End Property
'¶ÁÈ¡ÊôÐÔWaitµÄÖµ
'Msgbox Multimedia.Wait
Property Get Wait() As Boolean
Wait = bWait
End Property
'ÉèÖõȴýÊôÐÔ
'Ó÷¨£ºMultimedia.Wait=True
Property Let Wait(bWaitValue As Boolean)
bWait = bWaitValue
End Property
'»ñµÃ³¤¶ÈÖµ
Property Get Length() As Single
Dim nReturn As Long, nLength As Integer
Dim sLength As String * 255
If sAlias = "" Then
Length = 0
Exit Property
End If
nReturn = mciSendString("Status " & sAlias & " length", sLength, 255, 0)
nLength = InStr(sLength, Chr$(0))
Length = Val(Left$(sLength, nLength - 1))
End Property
Property Let Position(ByVal nPosition As Single)
mmSeek nPosition
End Property
'»ñÈ¡µ±Ç°Î»ÖÃ
Property Get Position() As Single
Dim nReturn As Integer, nLength As Integer
Dim sPosition As String * 255
If sAlias = "" Then Exit Property
nReturn = mciSendString("Status " & sAlias & " position", sPosition, 255, 0)
nLength = InStr(sPosition, Chr$(0))
Position = Val(Left$(sPosition, nLength - 1))
End Property
'µ±Ç°´ò¿ªÎļþµÄ״̬
'ÓÐÒÔϼ¸ÖÖ£ºplaying paused stopped
Property Get Status() As String
Dim nReturn As Integer, nLength As Integer
Dim sStatus As String * 255
If sAlias = "" Then Exit Property
nReturn = mciSendString("Status " & sAlias & " mode", sStatus, 255, 0)
nLength = InStr(sStatus, Chr$(0))
Status = Left$(sStatus, nLength - 1)
End Property
'´ÓÍ·¿ªÊ¼²¥·Å
Public Sub mmRestart()
Dim nReturn As Long
If sAlias = "" Then Exit Sub
mmSeek 0
mmPlay
End Sub
'ÀàµÄ³õʼ»¯
Private Sub Class_Initialize()
' sAlias = "" '±ðÃû³õֵΪ¿Õ
End Sub
'¹Ø±Õ´ò¿ªµÄ¶àýÌåÉ豸
'µ±¸ÃÀàµÄ¶ÔÏóËùÔڵĴ°Ì壨»òÄ£¿é£©Ð¶ÔØʱ£¬×Ô¶¯µ÷Óøùý³Ì
Private Sub Class_Terminate()
mmClose
End Sub
'----------------------------------------------------
[Ó÷¨]
1¡¢
±ÈÈçÒªÔÚ´°ÌåÉϲ¥·ÅÒ»¸ö¶¯»­,Ö»Ðè3¸öÓï¾ä¾Í¸ã¶¨¡£
Dim MmAvi As New Mmedia
MmAvi.mmOpen "G: esourceAviTest.avi", Me.hWnd
MmAvi.mmPlay
2¡¢Ñ­»·²¥·Å
Private Sub Timer1_Timer()
Dim S As String
S = "µ±Ç°Îļþ£º" & MmAvi.filename & vbCrLf & "µ±Ç°Î»Öãº" & MmAvi.Position _
& "×ܳ¤¶È£º" & MmAvi.Length & "µ±Ç°×´Ì¬£º" & MmAvi.Status
Label1.Caption = S
If MmAvi.Status = "stopped" Then MmAvi.mmRestart
End sub
3¡¢Í¬Ê±²¥·Å¼¸¸öÎļþ£¨ÀàÐÍ¿ÉÒÔÏàͬ¡¢¿ÉÒÔ²»Í¬£©
ÔÚForm1ÖмÓÈëPrivate MmWave(1) As New Mmedia
ÔÚÐèÒª²¥·ÅµÄµØ·½¼ÓÉÏ£º
MmWave(0).mmOpen "G: esourcewavem16.wav"
MmWave(1).mmOpen "G: esourcewaveWelcom98.wav"
MmWave(0).mmPlay
MmWave(1).mmPlay
4¡¢½«¶¯»­·ÅÈëÒ»¸öÔ²ÐÎÇøÓò²¥·Å
Dim hr As Long
Dim usew&, useh&
Dim MmAvi As New Mmedia
usew& = Frame1.Width / Screen.TwipsPerPixelX
useh& = Frame1.Height / Screen.TwipsPerPixelY
usew = useh
hr& = CreateEllipticRgn(0, 0, usew, useh)
Call SetWindowRgn(Frame1.hWnd, hr, True)
MmAvi.mmOpen "G: esourceAvistart.avi", Frame1.hWnd
MmAvi.mmPlay
    ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤·½°¸±¾ÆªÁ¬½Ó£ºhttp://www.rongsen.com.cn/show-14930-1.html
Íøվά»¤½Ì³Ì¸üÐÂʱ¼ä:2012-04-03 01:16:45  ¡¾´òÓ¡´ËÒ³¡¿  ¡¾¹Ø±Õ¡¿
ÎÒÒªÉêÇë±¾Õ¾£ºNµã | ºÚ¿Í·ÀÏß¹ÙÍø |  
רҵ·þÎñÆ÷ά»¤¼°Íøվά»¤ÊÖ¹¤°²È«´î½¨»·¾³£¬ÍøÕ¾°²È«¼Ó¹Ì·þÎñ¡£ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØÕÐÉ̽øÐÐÖУ¡QQ:29769479

footer  footer  footer  footer