ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] WindowsMediaPlayer¼½©ñ­µÀÉ°ÝÃD

[µo°Ý] WindowsMediaPlayer¼½©ñ­µÀÉ°ÝÃD

½Ð°Ý¦U¦ì¤j¤j¡A¤p§Ì¨Ï¥Îvba WindowsMediaPlayer¼·©ñ­µÀÉ¡A
¤À§O¥[¤J14­Ó­µÀÉlist«á¡A«oµLªk¤@¦¸¼½§¹¡A¥­§¡¨C4­Ó­µÀÉ·|°±¤î¼·©ñ¡A
¦b·Ð½Ð¤j¤j¸Ñ´bÁÂÁ¡I
µ{¦¡½X¦p¤U
Public Sub macro_test2()

Dim Bk_A As String
Bk_A = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Dim book_name As String
Dim book_path As String

book_name = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
book_path = ThisWorkbook.Path

¤u§@ªí001.WindowsMediaPlayer1.currentPlaylist.Clear

music_path01 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦U¦ì®È«È±z¦n" & ".wav"
music_path02 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_6ÂI" & ".wav"
music_path03 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À50" & ".wav"
music_path04 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À" & ".wav"
music_path05 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¶}©¹" & ".wav"
music_path06 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥x¥_ªº" & ".wav"
music_path07 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸5" & ".wav"
music_path08 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0" & ".wav"
music_path09 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0" & ".wav"
music_path10 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦¸" & ".wav"
music_path11 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_°ªÅK" & ".wav"
music_path12 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥_¤W" & ".wav"
music_path13 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_ªº¦C¨®§Y±N¶i¯¸½Ð«e©¹" & ".wav"
music_path14 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_²Ä¤G¤ë¥x" & ".wav"
music_path15 = ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_·f­¼¨Ã¯d·N¤ë¥x¶¡»ØÁÂÁÂ" & ".wav"

Dim Xwmp As IWMPMedia

¤u§@ªí001.WindowsMediaPlayer1.currentPlaylist.Clear

Set Xwmp = ¤u§@ªí001.WindowsMediaPlayer1.newMedia(music_path05)
¤u§@ªí001.WindowsMediaPlayer1.currentPlaylist.insertItem 0, Xwmp

¤u§@ªí001.WindowsMediaPlayer1.Controls.Play

Set Xwmp = ¤u§@ªí001.WindowsMediaPlayer1.newMedia(music_path06)
¤u§@ªí001.WindowsMediaPlayer1.currentPlaylist.insertItem 1, Xwmp

¤u§@ªí001.WindowsMediaPlayer1.Controls.Play

Set Xwmp = ¤u§@ªí001.WindowsMediaPlayer1.newMedia(music_path07)
¤u§@ªí001.WindowsMediaPlayer1.currentPlaylist.insertItem 2, Xwmp

¤u§@ªí001.WindowsMediaPlayer1.Controls.Play

Set Xwmp = ¤u§@ªí001.WindowsMediaPlayer1.newMedia(music_path08)
¤u§@ªí001.WindowsMediaPlayer1.currentPlaylist.insertItem 3, Xwmp

¤u§@ªí001.WindowsMediaPlayer1.Controls.Play

End Sub

¦^´_ 1# lshsien
§A¤U­±¥u´¡¤J²Ä 5,6,7,8 ­º¨ì¼·©ñ²M³æ¡C
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 1# lshsien
²K¥[¤@­Ó·sªº¼Ò¶ô¡A±N¤U­±ªº¥N½XÖ߶K¨ì¦¹¼Ò¶ô¤¤¡G
  1. Option Explicit

  2. #If VBA7 Then
  3.   Private Declare PtrSafe Function waveOutGetNumDevs Lib "winmm.dll" () As Long
  4.   Private Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringW" (ByVal lpstrCommand As LongPtr, ByVal lpstrRetumString As LongPtr, ByVal uReturnLength As Long, ByVal hwndCallback As LongPtr) As Long
  5.   Private Declare PtrSafe Function GetShortPathNameW Lib "kernel32" (ByVal lpszLongPath As LongPtr, ByVal lpszShortPath As LongPtr, ByVal cchBuffer As Long) As Long
  6.   Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  7.   Private Declare PtrSafe Function PathFindExtension Lib "shlwapi.dll" Alias "PathFindExtensionW" (ByVal pszPath As LongPtr) As LongPtr
  8.   Private Declare PtrSafe Function lStrLen Lib "kernel32.dll" Alias "lstrlenW" (ByVal lpString As LongPtr) As Long
  9.   Private Declare PtrSafe Sub CopyMemoryByPtr Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As LongPtr, ByVal Source As LongPtr, ByVal Length As Long)
  10. #Else
  11.   Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
  12.   Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringW" (ByVal lpstrCommand As Long, ByVal lpstrRetumString As Long, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  13.   Private Declare Function GetShortPathNameW Lib "kernel32" (ByVal lpszLongPath As Long, ByVal lpszShortPath As Long, ByVal cchBuffer As Long) As Long
  14.   Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  15.   Private Declare Function PathFindExtension Lib "shlwapi.dll" Alias "PathFindExtensionW" (ByVal pszPath As Long) As Long
  16.   Private Declare Function lStrLen Lib "kernel32.dll" Alias "lstrlenW" (ByVal lpString As Long) As Long
  17.   Private Declare Sub CopyMemoryByPtr Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
  18. #End If

  19. Private Type FileList
  20.   FileName  As String
  21.   ShortName As String
  22. End Type

  23. Private FileList() As FileList
  24. Private ListCount  As Long

  25. Public Sub Clean()
  26.   ListCount = 0
  27.   Erase FileList
  28. End Sub

  29. Public Property Get Item(ByVal Index As Long) As String
  30.   If Index > 0 And Index <= ListCount Then
  31.     Item = FileList(Index).FileName
  32.   End If
  33. End Property

  34. Public Property Let Item(ByVal Index As Long, ByVal FileName As String)
  35.   Dim I As Long
  36.   If Index = ListCount + 1 Then
  37.     ListCount = ListCount + 1
  38.     ReDim Preserve FileList(1 To ListCount)
  39.   End If
  40.   If (Index > 0) And (Index <= ListCount) Then
  41.     With FileList(Index)
  42.       .FileName = FileName
  43.       
  44.       I = Len(FileName)
  45.       If I > 0 Then
  46.         .ShortName = GetShortPathName(FileName)
  47.       Else
  48.         .ShortName = vbNullString
  49.       End If
  50.     End With
  51.   End If
  52. End Property

  53. Public Function ItemAdd(ByVal FileName As String) As Long
  54.   Dim I As Long
  55.   I = ListCount + 1
  56.   Item(I) = FileName
  57.   ItemAdd = I
  58. End Function

  59. Public Function ItemReMove(ByVal Index As Long) As Boolean
  60.   If Index > 0 And Index <= ListCount Then
  61.     With FileList(Index)
  62.       .FileName = vbNullString
  63.       .ShortName = vbNullString
  64.     End With
  65.   End If
  66. End Function

  67. Public Sub StartPlay()
  68.   Dim I         As Long
  69.   
  70.   If waveOutGetNumDevs > 0 Then
  71.     For I = 1 To ListCount Step 1
  72.       With FileList(I)
  73.         If Len(.ShortName) Then
  74.           Select Case UCase$(ExtractFileExtension(.ShortName))
  75.             Case ".WAV": mciSendString StrPtr("open " & .ShortName & " type waveaudio alias JofornMusic"), 0, 0, 0
  76.             Case ".MDI": mciSendString StrPtr("open " & .ShortName & " type sequencer alias JofornMusic"), 0, 0, 0
  77.             Case Else:   mciSendString StrPtr("open " & .ShortName & " alias JofornMusic"), 0, 0, 0
  78.           End Select
  79.           mciSendString StrPtr("play JofornMusic FROM 0"), 0&, 0, 0
  80.           Do While Not IsEnd
  81.             Sleep 50
  82.             DoEvents
  83.           Loop
  84.           mciSendString StrPtr("close JofornMusic"), 0&, 0, 0
  85.         End If
  86.       End With
  87.     Next I
  88.   End If
  89. End Sub

  90. Private Function IsEnd() As Boolean
  91.   Dim I         As Long
  92.   Dim strStatus As String
  93.   
  94.   strStatus = String$(256, vbNullChar)
  95.   mciSendString StrPtr("status JofornMusic mode"), StrPtr(strStatus), 256, 0
  96.   I = InStr(strStatus, vbNullChar)
  97.   If I > 1 Then
  98.     IsEnd = UCase$(Left$(strStatus, I - 1)) = "STOPPED"
  99.   Else
  100.     IsEnd = True
  101.   End If
  102. End Function

  103. '从¸ô径´£¨ú¤å¥ó¦Z缀¦W
  104. Public Function ExtractFileExtension(ByVal strPath As String) As String
  105.   #If VBA7 Then
  106.     Dim ptrExt As LongPtr
  107.   #Else
  108.     Dim ptrExt As Long
  109.   #End If
  110.   Dim ExtLen As Long
  111.   
  112.   strPath = strPath & vbNullChar
  113.   ptrExt = PathFindExtension(StrPtr(strPath))
  114.   If ptrExt Then
  115.     ExtLen = lStrLen(ptrExt)
  116.     If ExtLen > 0 Then
  117.       ExtractFileExtension = String(ExtLen, vbNullChar)
  118.       CopyMemoryByPtr StrPtr(ExtractFileExtension), ptrExt, ExtLen * 2
  119.     End If
  120.   End If
  121. End Function

  122. Public Sub StopPlay()
  123.   mciSendString StrPtr("close JofornMusic"), 0&, 0, 0
  124. End Sub

  125. Private Function GetShortPathName(ByVal FileName As String) As String
  126.   Dim I       As Long
  127.   Dim strTemp As String
  128.   
  129.   strTemp = Space$(256)
  130.   I = GetShortPathNameW(StrPtr(FileName), StrPtr(strTemp), 256)
  131.   If I > 0 Then GetShortPathName = Left$(strTemp, I)
  132. End Function
½Æ»s¥N½X
±N­ì¦³ªº¥N½X­×§ï¬°¡G
  1. Public Sub macro_test2()

  2.     Dim Bk_A As String
  3.     Bk_A = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
  4.     '-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  5.    
  6.     Dim book_name As String
  7.     Dim book_path As String
  8.    
  9.     book_name = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
  10.     book_path = ThisWorkbook.Path
  11.    
  12.     Clear
  13.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦U¦ì®È«È±z¦n" & ".wav"
  14.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_6ÂI" & ".wav"
  15.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À50" & ".wav"
  16.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À" & ".wav"
  17.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¶}©¹" & ".wav"
  18.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥x¥_ªº" & ".wav"
  19.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸5" & ".wav"
  20.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0" & ".wav"
  21.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0" & ".wav"
  22.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦¸" & ".wav"
  23.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_°ªÅK" & ".wav"
  24.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥_¤W" & ".wav"
  25.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_ªº¦C¨®§Y±N¶i¯¸½Ð«e©¹" & ".wav"
  26.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_²Ä¤G¤ë¥x" & ".wav"
  27.     ItemAdd ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_·f­¼¨Ã¯d·N¤ë¥x¶¡»ØÁÂÁÂ" & ".wav"
  28.     StartPlay
  29. End Sub
½Æ»s¥N½X
§¹¦¨¤W­±ªº¨â¨B¾Þ§@«á¹B¦æmacro_test2´ú¸Õ¡C
¥@¬É¨º»ò¤j¡A¥i§Ú·Q¥h­þ¡H

TOP

ª`¡G¼Ó¤Wªº¥N½X¤£»Ý­nMediaPlayer±±¥ó¡C
¥@¬É¨º»ò¤j¡A¥i§Ú·Q¥h­þ¡H

TOP

¦^´_ 1# lshsien
¥¿¦p Joforn ¤j¤j©Ò´£¥Üªº¡A¥H¤Uªº
¥N½X¤£»Ý­n MediaPlayer ªº¤ä´©±±¥ó¡C
¦pªG§A¸û²ßºD¨Ï¥Î MediaPlayer ±±¥ó
¨º»ò§A«K¥i¥H¤£¥Î©¹¤U¾\Äý¤F¡C
  1. Option Explicit

  2. Private Const SND_APPLICATION = &H80         '  look for application specific association
  3. Private Const SND_ALIAS = &H10000            '  name is a WIN.INI [sounds] entry
  4. Private Const SND_ALIAS_ID = &H110000        '  name is a WIN.INI [sounds] entry identifier
  5. Private Const SND_ASYNC = &H1                '  play asynchronously
  6. Private Const SND_FILENAME = &H20000         '  name is a file name
  7. Private Const SND_LOOP = &H8                 '  loop the sound until next sndPlaySound
  8. Private Const SND_MEMORY = &H4               '  lpszSoundName points to a memory file
  9. Private Const SND_NODEFAULT = &H2            '  silence not default, if sound not found
  10. Private Const SND_NOSTOP = &H10              '  don't stop any currently playing sound
  11. Private Const SND_NOWAIT = &H2000            '  don't wait if the driver is busy
  12. Private Const SND_PURGE = &H40               '  purge non-static events for task
  13. Private Const SND_RESOURCE = &H40004         '  name is a resource name or atom
  14. Private Const SND_SYNC = &H0                 '  play synchronously (default)

  15. #If VBA7 Then
  16.     Private Declare PtrSafe Function PlaySoundA Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
  17.     '  ¥H¤W«Y .Wav Àɤ§°Ñ¼Æ«Å§i¡F ¤U¦C¤T¦æ¬° .MP3 Àɮ׫ŧi¤§¤Þ¥Î¥\¯à¨ç¦¡¤ÎÅܼƫŧi¡C
  18.     Private Declare PtrSafe 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
  19.     Private Declare PtrSafe Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
  20. #Else
  21.     Private Declare Function PlaySoundA Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
  22.     '  ¥H¤W«Y .Wav Àɤ§°Ñ¼Æ«Å§i¡F ¤U¦C¤T¦æ¬° .MP3 Àɮ׫ŧi¤§¤Þ¥Î¥\¯à¨ç¦¡¤ÎÅܼƫŧi¡C
  23.     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
  24.     Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
  25. #End If

  26. Dim Mp3File, LastMp3File As String, lst() As String, idx As Long

  27. Sub Ex()
  28.     Dim cnt As Long
  29.    
  30.     idx = 0
  31.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦U¦ì®È«È±z¦n.wav")
  32.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_6ÂI.wav")
  33.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À50.wav")
  34.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¤À.wav")
  35.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¶}©¹.wav")
  36.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥x¥_ªº.wav")
  37.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸5.wav")
  38.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0.wav")
  39.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¨®¦¸0.wav")
  40.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¦¸.wav")
  41.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_°ªÅK.wav")
  42.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_¥_¤W.wav")
  43.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_ªº¦C¨®§Y±N¶i¯¸½Ð«e©¹.wav")
  44.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_²Ä¤G¤ë¥x.wav")
  45.     addList (ThisWorkbook.Path & "\" & "±`¥Î¼s¼½" & "\" & "°ê»y_·f­¼¨Ã¯d·N¤ë¥x¶¡»ØÁÂÁÂ.wav")
  46.         
  47.     For cnt = 1 To UBound(lst)
  48.         If UCase(Right(lst(cnt), 4)) = ".WAV" Then
  49.             PlaySound (lst(cnt))
  50.         ElseIf UCase(Right(lst(cnt), 4)) = ".MP3" Then
  51.             MMStop (LastMp3File)
  52.             LastMp3File = lst(cnt)
  53.             MMPlay (lst(cnt))
  54.         End If
  55.     Next cnt
  56.         
  57.     rmvList
  58. End Sub

  59. Public Function addList(ByVal fn As String)
  60.     Dim num As Long
  61.    
  62.     If idx = 0 Then num = 1 Else num = UBound(lst) + 1
  63.     ReDim Preserve lst(num)
  64.     lst(num) = fn
  65.     idx = idx + 1
  66. End Function

  67. Public Function rmvList()
  68.     If idx = 0 Then Exit Function
  69.     ReDim Preserve lst(0)   '  lst :  String(0 to 0)
  70.     idx = 0                 '  UBound(lst) = 0 : Long
  71. End Function

  72. ' Purpose     :  Plays an audio file
  73. ' Inputs      :  sFilePath           The location of the wav file
  74. '                lFlags              Can be one or many of the constants given above
  75. ' Outputs     :  The text found on the web site
  76. ' Author      :  Andrew Baker
  77. ' Date        :  21/10/2000 12:37
  78. ' Notes       :  Code adapted from code found on www.allapi.net (excellent site!)
  79. ' Revisions   :

  80. Function PlaySound(sFilePath As String, Optional lFlags As Long = SND_FILENAME Or SND_ASYNC) As Long
  81.     PlaySound = PlaySoundA(sFilePath, 0&, lFlags)
  82. End Function

  83. Function ConvShortFilename(ByVal strLongPath$) As String
  84.     Dim strShortPath$
  85.     If InStr(1, strLongPath, " ") Then
  86.         strShortPath = String(LenB(strLongPath), Chr(0))
  87.         GetShortPathName strLongPath, strShortPath, Len(strShortPath)
  88.         ConvShortFilename = Left(strShortPath, InStr(1, strShortPath, Chr(0)) - 1)
  89.     Else
  90.         ConvShortFilename = strLongPath
  91.     End If
  92. End Function

  93. Private Sub MMPlay(ByRef FileName As String)
  94.     FileName = ConvShortFilename(FileName)
  95.     mciSendString "close " & FileName, vbNullString, 0, 0
  96.     mciSendString "open " & FileName, vbNullString, 0, 0
  97.     mciSendString "play " & FileName, vbNullString, 0, 0
  98. End Sub

  99. Private Sub MMStop(ByRef FileName As String)
  100.     FileName = ConvShortFilename(FileName)
  101.     mciSendString "stop " & FileName, vbNullString, 0, 0
  102.     mciSendString "close " & FileName, vbNullString, 0, 0
  103. End Sub
½Æ»s¥N½X
1

µû¤À¤H¼Æ

TOP

To stillfish00¤j¤j
¤£¦n·N«ä¡A¤p§Ì¨S¶K¨ì«á­±ªº¡C
To Joforn¡Bc_c_lai¨â¦ì¤j¤j
·PÁ±zªº«ü¾É¡A¥Ø«e¥¿¦b§V¤O´ú¸Õ¤¤¡A
¦]¤p§Ì¾Ç²ß­è°_¨B¡A¹ï©ó¨â¦ì¤j¤j©Ò¼gªºÁÙ¬O¤@ª¾¥b¸Ñ¡A
¥Ø«e§V¤Oªº²z¸Ñ¤¤¡A
·Q½Ð°Ý¤j¤j¡A­Y¨Ï¥ÎMediaPlayer ±±¥ó¡A
¬O§_¦³¿ìªk¸Ñ¨M¤p§Ìªº°ÝÃD¡A
ÁÂÁÂ!

TOP

¥H¡eµu»y­µ¡fmp3¹ê´ú¡A
WindowsMediaPlayer¨ÃµL¥|ÀɧY°±¼½°ÝÃD¡A

©Î³\¤W¶ÇÀɮ׸û¥i¯à§ä¥X­ì¦]¡ã¡ã

TOP

¦^´_ 6# lshsien
ÁöµM§A°¾¦n¨Ï¥Î Windows Media Player¡A
¦ý§Ú¨Ï¥Î Joforn ¤j¤j´£¨Ñªºµ{¦¡½X´ú¸Õ
¤TºØ«¬ºAªº´CÅéÀÉ (*.mp3;*.wav;*.mp4)
¥¦¦b°õ¦æ¼·©ñ¹Lµ{«D±`í©w¡ADoEvents ªº
®É¬q®³®º±o«ê·í¡A¤×¨ä¬O mp4 ¼v¤ù¼·©ñ
µøµ¡¤]«Ü¬yºZ¡AÆZ­È±o§A±Ä¥Î¡C¨ä¹ê
Windows Media Player¤¸¥ó¥ç¨Ï¥Î¦P¼Ë¤§
Windows System µ{¦¡®w (Lib)¡C
  1. Sub Ex()
  2.     ItemAdd (ThisWorkbook.Path & "\" & "¤j´d©G¤Ñ¨Ïªiù»e.wav")
  3.     ItemAdd (ThisWorkbook.Path & "\" & "µÎ§B¯S ¤p©]¦± ¤j´£µ^ºt«µ .mp4")
  4.     ItemAdd (ThisWorkbook.Path & "\" & "Ä_æשG.mp3")
  5.     ItemAdd (ThisWorkbook.Path & "\" & "¸t½Ï§Ö¼Ö 01.mp4")
  6.     ItemAdd (ThisWorkbook.Path & "\" & "01_¤Ú«¢ G©¶¤§ºq Air On the G string.mp3")
  7.     ItemAdd (ThisWorkbook.Path & "\" & "µÎ§B¯S ¤p©]¦± ¤j´£µ^ºt«µ .mp4")
  8.     ItemAdd (ThisWorkbook.Path & "\" & "02_NOCTURNE.mp3")
  9.     ItemAdd (ThisWorkbook.Path & "\" & "03_SAULT D' AMOUR.mp3")
  10.     ItemAdd (ThisWorkbook.Path & "\" & "04_JUNE(BARCAROLLE).mp3")
  11.    
  12.     StartPlay
  13. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# Joforn

½Ð°Ý¼½©ñ¥H«á¦p¦óÁ{®É¼È°±©Î¤¤Â_¼·©ñ
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_  Joforn

½Ð°Ý¼½©ñ¥H«á¦p¦óÁ{®É¼È°±©Î¤¤Â_¼·©ñ
ML089 µoªí©ó 2016-1-22 20:04
  1. Public Property Get Pause() As Boolean
  2.   Dim I         As Long
  3.   Dim strStatus As String
  4.   
  5.   strStatus = String$(256, vbNullChar)
  6.   mciSendString StrPtr("status JofornMusic mode"), StrPtr(strStatus), 256, 0
  7.   I = InStr(strStatus, vbNullChar)
  8.   If I > 1 Then
  9.     Debug.Print Left$(strStatus, I - 1)
  10.     Pause = UCase$(Left$(strStatus, I - 1)) = "PAUSED"
  11.   End If
  12. End Property

  13. Public Property Let Pause(ByVal Value As Boolean)
  14.   If Value Xor Pause Then
  15.     If Value Then
  16.       mciSendString StrPtr("pause JofornMusic"), 0, 0, 0
  17.     Else
  18.       mciSendString StrPtr("resume JofornMusic"), 0, 0, 0
  19.     End If
  20.   End If
  21. End Property
½Æ»s¥N½X
½Õ¥ÎPause=True´N¥i¥H¼È°±¡APause=FalseÄ~Äò¼½©ñ¡C
¥@¬É¨º»ò¤j¡A¥i§Ú·Q¥h­þ¡H

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¨S¦³©Ò¦³Åv¡A¥u¦³¥Í©Rªº¨Ï¥ÎÅv¡C
ªð¦^¦Cªí ¤W¤@¥DÃD