Function Documentation

njb a pointer to the njb_t object to delete the playlist from
plid the playlist ID as reported from NJB_Get_Playlist().

Returns:

0 on success, -1 on failure.

Examples: pl.c.

References njb_struct::device_type, and NJB_DEVICE_NJB1.

njb_playlist_t* NJB_Get_Playlist (njb_t * njb)This gets a playlist from the device. The device should first be rewound using the NJB_Reset_Get_Playlist() function. The playlists are newly allocated and should be destroyed with NJB_Playlist_Destroy() after use.

void NJB_Playlist_Deltrack_TrackID (njb_playlist_t * pl, u_int32_t trackid)This function removes a track from a playlist by way of the track ID (as opposed to the position in the playlist). This function can be called even on playlists that don't have this track in them - this is useful for e.g. looping through all playlists and removing a certain track before deleting the track itself from the device.

You need to call the NJB_Update_Playlist() function for each playlist that has been manipulated by this function, to assure that any changes are written back to the playlist on the device.

Typical use to remove a track with ID id from all playlists on a device:

njb_playlist_track_t* NJB_Playlist_Gettrack (njb_playlist_t * pl)Returns a track from a playlist. The playlist has an internal structure to keep track of the constituent tracks, so the tracks will be retrieved in order. This function should typically be called repeatedly after an initial NJB_Playlist_Reset_Gettrack() call.

Parameters:

pl the playlist to get tracks from.

Returns:

a track or NULL of the last track from a playlist has already been returned

njb_playlist_t* NJB_Playlist_New (void)This function creates a new playlist data structure to hold a name and a number of tracks.

Returns:

a new playlist structure

Examples: pl.c.

References njb_playlist_struct::_state, and NJB_PL_NEW.

Referenced by playlist_unpack().

void NJB_Playlist_Reset_Gettrack (njb_playlist_t * pl)Resets the internal counter used when retrieveing tracks from a playlist. Should typically be called first, before any subsequent calls to NJB_Playlist_Gettrack().

int NJB_Playlist_Set_Name (njb_playlist_t * pl, const char * name)This function sets the name of the playlist. The name will be duplicated and stored internally, so the string is only needed during the function call.

Parameters:

pl the playlist to set the name for
name the name to set for the playlist

int NJB_Update_Playlist (njb_t * njb, njb_playlist_t * pl)This writes back an updated (modified) or new playlist to the device.

This function may modify the playlist ID, i.e. the plid member of the njb_playlist_t struct, which means that if your program has cached this number anywhere, you need to update it using the value from pl->plid afterwards. This stems from the fact that playlists are sometimes updated by deleting the old playlist and creating a new one.

Parameters:

njb a pointer to the njb_t object to update the playlist on
pl the playlist to update.