I have a serious problem with my VB 6 application. In it, I have a reference to wmp.dll
in a Form, the idea it's play media video files, i have a ListView called LV1
in which I show the playlist filenames. I wish to know the current index from the current Playlist.
This sub is in charge of detecting the changes:
Private Sub Wmp1_CurrentItemChange(ByVal pdispMedia As Object)
I can get the totall count into the playlist with this line:
Val=Wmp1.currentPlaylist.Count
How I can obtain the current track (index) in reproduction, if i want coordinate this with my ListView, to select the same track 开发者_如何学编程with the same index into the playlist.
Thanks for your help.
You can use setItemInfo
on the media before adding to currentPlaylist
like this:
Option Explicit
Private Sub Form_Load()
Dim sFile As String
Dim oMedia As IWMPMedia
sFile = Dir("c:\temp\*.avi")
Do While LenB(sFile) <> 0
Set oMedia = Wmp1.newMedia("c:\temp\" & sFile)
oMedia.setItemInfo "Index", Wmp1.currentPlaylist.Count
Wmp1.currentPlaylist.appendItem oMedia
sFile = Dir
Loop
End Sub
Private Sub Wmp1_CurrentItemChange(ByVal pdispMedia As Object)
Debug.Print Wmp1.currentPlaylist.Item(Wmp1.currentMedia.getItemInfo("Index")).Name
End Sub
This is the answer. You have to search again in the loop
Dim i As Integer
For i = 0 To WindowsMediaPlayer1.currentPlaylist.Count - 1
If WindowsMediaPlayer1.currentPlaylist.Item(i).isIdentical(WindowsMediaPlayer1.currentMedia) = True Then Exit For
Next
List1.Selected(i) = True
精彩评论