So, ich bins nochmal ;)
Habs jetzt hingekriegt, für die die es auch mal irgendwann brauchen hab ich hier mal den Code auskommentiert:
Public Class Form1
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal _
hWnd As IntPtr, ByVal Msg As IntPtr, ByVal wParam As IntPtr, ByVal lParam _
As IntPtr) As IntPtr
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal _
lpClassName As String, ByVal lpWindowName As String) As IntPtr
Const WMP_PLAYPAUSE As Long = &H4978
Const WMP_STOP As Long = &H4979
Const WMP_NEXT As Long = &H497B
Const WMP_PREV As Long = &H497A
Const WMP_PLAYSPEED1 As Long = &H4994
Const WMP_PLAYSPEED2 As Long = &H4993
Const WMP_PLAYSPEED3 As Long = &H4992
Const WMP_RANDOM As Long = &H499A
Const WMP_REPEAT As Long = &H499B
Const WMP_VOLUP As Long = &H497F
Const WMP_VOLDOWN As Long = &H4980
Const WMP_MUTE As Long = &H4981
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
'### Methode mit SendMessage
'Dim handle As IntPtr = FindWindow("WMPlayerApp", "Windows Media" & _
"Player")
'SendMessage(handle, &H111, WMP_PLAYSPEED2, &H0)
'###
Dim wmp = New wmpuiceLib.WMPApp
Dim player = wmp.Core
MsgBox(wmp.Running) 'WMP gestartet?
player.controls.play() 'Play-Befehl
MsgBox(player.playstate) 'Wiedergabestatus (0 = ?, 1
' = Gestoppt, 2 = Pausiert, 3 = Wiedergabe)
MsgBox(player.CurrentPlaylist.Name) 'Name der aktuellen
' Wiedergabeliste
For i = 0 To player.CurrentPlaylist.Count - 1
ListBox1.Items.Add(player.currentPlaylist.item(i).name.ToString)
Next
Dim track = player.CurrentMedia 'Liefert das aktuelle Lied
' als Object
MsgBox(track.Name) 'Titel
MsgBox(track.getItemInfo("Author")) 'Interpret
MsgBox(track.getItemInfo("WM/AlbumTitle")) 'Album
MsgBox(track.durationString) 'Dauer des Lieds als String
MsgBox(track.getItemInfo("WM/Genre")) 'Genre
MsgBox(track.getItemInfo("WM/Year")) 'Jahr
MsgBox(track.getItemInfo("Description")) 'Beschreibung (?)
MsgBox(track.getItemInfo("Bitrate")) 'Bitrate in bit/sec (
' Umrechnung: Wert / 1000)
ListBox1.SelectedItem = track.Name
TrackBar1.Maximum = track.Duration
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Timer1.Tick
Dim wmp = New wmpuiceLib.WMPApp
Dim player = wmp.Core
Dim pos = player.controls.currentPosition 'Aktuelle Position in
' Sekunden (Double)
TrackBar1.Value = CInt(pos)
Label1.Text = player.controls.currentPositionString
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles TrackBar1.Scroll
Dim wmp = New wmpuiceLib.WMPApp
Dim player = wmp.Core
player.controls.currentPosition = TrackBar1.Value
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Dim wmp = New wmpuiceLib.WMPApp
Dim player = wmp.Core
player.controls.PlayItem(player.currentPlaylist.item( _
ListBox1.SelectedIndex))
End Sub
End Class Die Konstanten hab ich nur noch mal dabeigelassen falls jemand mit SendMessage arbeitet ;)
lg, matthes |