INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Why am I not able to get the names of playlists?  (Read 1372 times)

simonk

  • Recent member
  • *
  • Posts: 18
Why am I not able to get the names of playlists?
« on: December 08, 2011, 01:24:56 pm »

I've been racking my brains but cannot see why I am unable to get a list of the Playlist names with the below code, hopefully it's just something simple that I've missed!

Code: [Select]
Public Sub Main(Optional ByVal params As String = "")
        Dim mc As Object
        On Error Resume Next
        mc = GetObject(, "MediaJukebox Application") 'First try to get an already running object
        If Debug Then hs.WriteLog("MusicSk", "GetObject Error Code = " & Err.Number)
        If Err.Number = 429 Then
            mc = CreateObject("MediaJukebox Application") 'Then, create a new object
        End If

' Get Number Of Playlists
        Dim NoPlayListsObj As Object
        NoPlayListsObj = mc.GetPlayLists()

        Dim NoPlayLists As Integer
        NoPlayLists = NoPlayListsObj.GetNumberPlaylists()
        hs.WriteLog("MusicSK", "Number Of Playlists = " & NoPlayLists)

' Get List Of Playlists
        Dim PlayListObj As Object
        Dim PlayListLoop As Integer
        Dim PlayListName As String

        For PlayListLoop = 0 To NoPlayLists
            PlayListObj = mc.GetPlaylistByID(PlayListLoop)
            PlayListName = PlayListObj.Name()
            hs.WriteLog("MediaControl", "PlayList Number " & PlayListLoop & " Playlist Name " & PlayListName)
        Next

    End Sub

Thanks
Simon
Logged

simonk

  • Recent member
  • *
  • Posts: 18
Re: Why am I not able to get the names of playlists?
« Reply #1 on: December 09, 2011, 12:47:47 pm »

Anyone any ideas please or a quick pointer?  I've tried looked at examples but cannot see the problem!

Thanks
Simon
Logged

simonk

  • Recent member
  • *
  • Posts: 18
Re: Why am I not able to get the names of playlists?
« Reply #2 on: December 10, 2011, 07:15:44 pm »

Managed to figure out what I needed to do, the code below now searches through the Playlists to find the required playlist...

Code: [Select]
Dim PlayListLoop As Integer
        Dim pls As Object = mc.GetPlaylists()
        Dim pl As Object
        For PlayListLoop = 0 To (pls.GetNumberPlaylists() - 1)
            pl = pls.GetPlaylist(PlayListLoop)
            hs.WriteLog("MusicSK", "PlayList Number " & PlayListLoop & " Playlist Name '" & pl.Name & "'")           
            If pl.Name = "Christmas" Then
               Exit For
            ElseIf PlayListLoop = (pls.GetNumberPlaylists() - 1) Then
                hs.WriteLog("MusicSK", "PlayList Not Found ")
                Exit Sub
            End If
        Next
Logged
Pages: [1]   Go Up