ISDBApplication::PlaylistByID: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (introduced → template) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
{{MethodParameters | {{MethodParameters | ||
|ID |Long |ID of the playlist to get (use -1 to get root of all playlists)}} | |ID |Long |ID of the playlist to get (use <tt>-1</tt> to get root of all playlists)}} | ||
===Property description=== | ===Property description=== | ||
Line 10: | Line 10: | ||
Retrieves [[SDBPlaylist]] object of the given playlist ID. | Retrieves [[SDBPlaylist]] object of the given playlist ID. | ||
Call method with <tt>-1</tt> as the argument to get the (virtual) root playlist node. Then you can use its [[ISDBPlaylist::ChildPlaylists|ChildPlaylists]] property to get all the first-level playlists. | |||
'''WARNING:''' Also if no playlist with the specified ID exists, the | '''WARNING:''' Also if no playlist with the specified ''ID'' exists, the (virtual) root playlist will be returned. Be aware of this fact, especially if you are planning to remove a playlist. Making an error could remove the root, and so all playlists. | ||
Introduced | {{Introduced|4.0}} | ||
===Example code=== | ===Example code=== | ||
<source lang="vb">Dim Playlist : Set Playlist = SDB. | <source lang="vb"> | ||
' Safe PlaylistByID wrapper - returns Nothing when playlist with given ID is not found | |||
Sub SafePlaylistByID(ID) | |||
Dim RootList : Set RootList = SDB.PlaylistByID(-1) ' Get root node | |||
SafePlaylistByID = SDB.PlaylistByID(ID) ' Get playlist by ID | |||
If SafePlaylistByID Is RootList Then | |||
SafePlaylistByID = Nothing ' Do not return playlist when nothing was found | |||
End If | |||
End Sub | |||
</source> | |||
Example for playlist nodes iteration: | |||
<source lang="vb">Dim Playlist : Set Playlist = SDB.PlaylistByID(-1) ' Playlist represents the root (virtual) playlist | |||
Dim List : Set List = Playlist.ChildPlaylists ' List represents a list of all first-level playlists | Dim List : Set List = Playlist.ChildPlaylists ' List represents a list of all first-level playlists | ||
Line 28: | Line 41: | ||
' in this case, fout represents a TextStream object (not shown here)</source> | ' in this case, fout represents a TextStream object (not shown here)</source> | ||
===Related Topics=== | |||
* [[ISDBApplication::PlaylistByTitle]] | |||
[[Category:Scripting|{{PAGENAME}}]] | [[Category:Scripting|{{PAGENAME}}]] |
Latest revision as of 20:57, 20 April 2013
CoClass SDBApplication, Interface ISDBApplication
Property Get PlaylistByID(ID As Long) As ISDBPlaylist
Parameters
Name | Type | Description |
---|---|---|
ID | Long | ID of the playlist to get (use -1 to get root of all playlists) |
Property description
Retrieves SDBPlaylist object of the given playlist ID.
Call method with -1 as the argument to get the (virtual) root playlist node. Then you can use its ChildPlaylists property to get all the first-level playlists.
WARNING: Also if no playlist with the specified ID exists, the (virtual) root playlist will be returned. Be aware of this fact, especially if you are planning to remove a playlist. Making an error could remove the root, and so all playlists.
Introduced in MediaMonkey version 4.0.
Example code
' Safe PlaylistByID wrapper - returns Nothing when playlist with given ID is not found
Sub SafePlaylistByID(ID)
Dim RootList : Set RootList = SDB.PlaylistByID(-1) ' Get root node
SafePlaylistByID = SDB.PlaylistByID(ID) ' Get playlist by ID
If SafePlaylistByID Is RootList Then
SafePlaylistByID = Nothing ' Do not return playlist when nothing was found
End If
End Sub
Example for playlist nodes iteration:
Dim Playlist : Set Playlist = SDB.PlaylistByID(-1) ' Playlist represents the root (virtual) playlist
Dim List : Set List = Playlist.ChildPlaylists ' List represents a list of all first-level playlists
Dim i, itm
For i = 0 To List.Count - 1 ' For all (first-level) playlists in List...
Set itm = List.Item(i) ' ... print out the number of child playlists and tracks
fout.WriteLine itm.Title & " (" & CStr(itm.ChildPlaylists.Count) & "/" & CStr(itm.Tracks.Count) & ")"
Next
' in this case, fout represents a TextStream object (not shown here)