Private Sub Form_Resize()
WMP.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
End Sub
Private Sub mnuOpen_Click()
With CommonDialog1
.FileName = ""
.Filter = "支持的常见格式|*.mp3;*.wav;*.mid;*.cda;*.avi;*.mpg;*.mpeg;*.dat;*.m3u;*.asf;*.asx;*.wma;*.wmv|所有文件(*.*)|*.*"
.ShowOpen
If Len(.FileName) Then WMP.URL = .FileName
End With
End Sub
Private Sub munFull_Click()
On Error GoTo Err
WMP.fullScreen = True
Err:
End Sub
Dim DltValue As Single
Dim SourMax As Long
Dim ImaT(10) As Long
Dim DltVolue As Single
Dim PlayFile As String
Dim SelFile As String
Dim SourVolue As Long
'---------------------------
Dim MediaLen As Long
Dim ListID As Long
Dim ListMax As Long
Dim DltLen As Single
Public FShow As Boolean
Dim StarPlay As Boolean
Private Sub FolserSel_FolderClick(Folder As CCRPFolderTV6.Folder, Location As CCRPFolderTV6.ftvHitTestConstants)
Dim Fpath As String
Dim a As Long
Dim TmpMax As Long
On Error Resume Next
Fpath = Folder.Name
If Mid$(Fpath, 2, 1) = ":" Then
If Right$(Fpath, 1) <> "\" Then Fpath = Fpath & "\"
If UCase$(Fpath) <> UCase$(List1.Tag) Then
File1.Path = Fpath: File1.Refresh: DoEvents
TmpMax = File1.ListCount - 1
If TmpMax > 0 Then
ListMax = TmpMax: List1.Visible = False: List1.Clear
For a = 0 To ListMax
List1.AddItem File1.List(a)
Next
List1.Visible = True: DoEvents
MediaLen = 99999: List1.Tag = Fpath
ListID = 0
SelFile = List1.List(ListID)
List1.ListIndex = ListID: Label4.Width = 15
Me.Caption = SelFile
MediaPlay.FileName = List1.Tag & SelFile
MediaPlay.Play
MediaLen = MediaPlay.SelectionEnd
DltLen = (Label3.Width - 30) / MediaLen
Timer1.Enabled = True
End If
End If
End If
End Sub
Private Sub Form_Load()
Dim a As Long
Dim ImaMax As Long
Dim Fpath As String
On Error Resume Next
Screen.MousePointer = 11
BkSourPlay.Hide
If P_TopWin Then TopWindow Me.hWnd
P_Lsound = True:
FShow = False
ImaMax = Image2.Count - 1
For a = 0 To ImaMax
ImaT(a) = Image2(a).Top
Next
Fpath = P_StarPath
MediaLen = 99999
File1.Pattern = P_Pattern
If Dir$(Fpath, vbDirectory + vbHidden) <> "" Then
If Right$(Fpath, 1) <> "\" Then Fpath = Fpath & "\"
FolserSel.SelectedFolder = Fpath
ListID = 0: File1.Path = Fpath
DoEvents: ListMax = File1.ListCount - 1
If ListMax > 0 Then
List1.Clear
For a = 0 To ListMax
List1.AddItem File1.List(a)
Next
List1.Tag = Fpath
End If
End If
MediaPlay.DisplayMode = mpTime
SourMax = -3000: SourVolue = -500
DltVolue = Image1.Width / (-SourMax / 100)
MediaPlay.Volume = SourVolue
Label1.Width = Image1.Width - (SourMax / SourVolue) * DltVolue
Screen.MousePointer = 0
BkSourPlay.Visible = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
MediaPlay.Stop
Timer1.Enabled = False
P_Lsound = False
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim K As Long
Label1.Width = X
If X <= 60 Then
K = -5500
Else
K = (X - Image1.Width) * 100 / DltVolue
If K > 0 Then K = 0
End If
MediaPlay.Volume = K
End Sub
Private Sub Image2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2(Index).Top = ImaT(Index) + 8
End Sub
Private Sub Image2_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Dim Fpath As String
Dim SelStr As String
Dim ML As Long, MW As Long
Dim a As Long
Dim Spath As String
Dim Ppath As String
On Error Resume Next
Image2(Index).Top = ImaT(Index)
SelStr = Image2(Index).Tag
Select Case SelStr
Case Is = "播放"
SelFile = Trim$(List1.List(ListID))
If Len(SelFile) > 0 Then
Timer1.Enabled = False
MediaLen = 99999
List1.ListIndex = ListID
Me.Caption = SelFile
MediaPlay.FileName = List1.Tag & SelFile
MediaPlay.Play
MediaLen = MediaPlay.SelectionEnd
DltLen = (Label3.Width - 30) / MediaLen
Timer1.Enabled = True
End If
Case Is = "停止"
MediaPlay.Stop
Timer1.Enabled = False
Case Is = "文件"
ML = Me.Left: MW = Me.Width
FShow = Not FShow
If FShow Then
Spath = List1.Tag
If Dir(Spath, vbDirectory) <> "" Then
Ppath = FolserSel.SelectedFolder
If Right$(Ppath, 1) <> "\" Then Ppath = Ppath & "\"
If UCase$(Ppath) <> UCase$(Spath) Then
FolserSel.SelectedFolder = Spath
End If
End If
Me.Left = ML
Me.Width = 5745
Else
Me.Left = ML
Me.Width = 2970
End If
Case Is = "退出"
BkSourPlay.Visible = False
End Select
End Sub
Private Sub Label3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If DltLen > 0 Then
Label4.Width = X
MediaPlay.CurrentPosition = X / DltLen
End If
End Sub
Private Sub List1_Click()
ListID = List1.ListIndex
SelFile = List1.List(ListID)
End Sub
Private Sub List1_DblClick()
On Error Resume Next
If Len(SelFile) > 0 Then
MediaPlay.Stop
Me.Caption = SelFile
MediaPlay.FileName = List1.Tag & SelFile
Label4.Width = 15
MediaPlay.Play
MediaLen = MediaPlay.SelectionEnd
DltLen = (Label3.Width - 30) / MediaLen
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
Dim CurTime As Long
Dim Lwidth As Long
Static OleTime As Long
On Error Resume Next
CurTime = MediaPlay.CurrentPosition
If OleTime <> CurTime Then Label4.Width = 15 + CurTime * DltLen: OleTime = CurTime
If CurTime >= (MediaLen - 0.5) And ListMax > 0 Then
ListID = ListID + 1
If ListID > ListMax Then ListID = 0
SelFile = List1.List(ListID)
If Len(SelFile) > 0 Then
List1.ListIndex = ListID
Label4.Width = 15
Me.Caption = SelFile
MediaPlay.FileName = List1.Tag & SelFile
MediaPlay.Play
MediaLen = MediaPlay.SelectionEnd
DltLen = (Label3.Width - 30) / MediaLen
End If
End If
End Sub
CTRL+T==>WINDOWS MEDIA PLAYER
'***********************************
例如:
Public Function ShowPlay(Optional StarPath As String = "", Optional TopWin As Boolean = False, Optional Pattern As String = "*.MP3;*.WAV;*.MID;*.WMA;*.MPA;*.MP2;*.MP1;*.MPG;*.DAT")
On Error Resume Next
If Len(Trim$(StarPath)) = 0 Then
StarPath = GetSetting("SMBACKAUDIOPLAY", "AUDIOPLAY", "SM" & UCase$(App.EXEName) & "MEDIAPATH", "C:\")
End If
If Len(Trim$(Pattern)) = 0 Then Pattern = "*.MP3;*.WAV;*.MID;*.WMA;*.MPA;*.MP2;*.MP1;*.MPG;*.DAT"
P_Pattern = Pattern
P_StarPath = StarPath
P_TopWin = TopWin
BkSourPlay.Show
End Function
Public Function StopPlay() As Boolean
On Error Resume Next
If P_Lsound Then
BkSourPlay.MediaPlay.Stop
Unload BkSourPlay
Set BkSourPlay = Nothing
End If
Err.Clear
End Function