Linking to Windows Media Player

siptah14

New member
Local time
Today, 11:19
Joined
Sep 26, 2017
Messages
2
I have an Access database containing all my music (almost 8,000 entries). I have linked the database to WMP to play a particular track or Playlist, but try as I might, I cannot get WMP to play all the ripped tracks off one album.
I create a dummy playlist and then try to append all the ripped Tracks from that one entry. I know you shouldn't embed a WMPobject onto a form (bloat!) but I like to keep things simple.
The code I used so far

Dim myplayer As WindowsMediaPlayer
Dim mypath$, mytrack$, Trackname$, albumname$
Dim playerobject As Variant

If Me.RippedTRacks.Value = 0 Then
MsgBox "There are no ripped tracks on the selected entry"
Exit Sub
End If

Set rst_data = CurrentDb.OpenRecordset("tbl_paths")
Path1 = rst_data.fields("Path1").Value
Set rst_data = Nothing

mypath = Path1 & Trim(Me.Artist) & "" & Trim(Me.Album) & "" '----------- Artist forename and Album title
albumname = Trim(Me.Album) & "-temp"
Set myplayer = Me.WindowsMediaPlayer5.Object

'-------------- create new playlist ---------------------------------------------
myplayer.playlistCollection.newPlaylist (albumname) '------ This works!!!!!!

'---------- Find album in Tracks table ------------------------------------
Set rst_data = CurrentDb.OpenRecordset("tbl_tracks", dbOpenDynaset)
With rst_data
.FindFirst ("[RecNum] = " & Me.RecNum.Value)
If .NoMatch = True Then
MsgBox "No tracks found for '" & Me.RecNum & ": " & Trim(Me.Album) & "'"
Set myplayer = Nothing
Set rst_data = Nothing
Exit Sub
End If

'------------------- For each ripped track, append to playlist ----------------
For i = 1 To 30 '------ maximum number of tracks allowed for each entry

If .fields("Rip" & Trim(str(i))) = "R" Then
Trackname = mypath & Format(i, "00") & " " & .fields("Track" & Trim(str(i))).Value & ".mp3"
Set playerobject = myplayer.playlistCollection.getByName(albumname).Item(0)
playerobject.appendItem Trackname '------- Type mismatch!!!!!! - Trackname is a string

End If
Next i
End With
Set rst_data = Nothing

myplayer.openPlayer albumname
--------------------------------------------------------------------------------
I have tried defining the variable Trackname as a variant, but I still get the same problem - type mismatch. Is it syntax or am I going the wrong way altogether?
 

Users who are viewing this thread

Back
Top Bottom