Track subsystem


Functions

bool sp_track_is_loaded (sp_track *track)
sp_error sp_track_error (sp_track *track)
int sp_track_num_artists (sp_track *track)
sp_artistsp_track_artist (sp_track *track, int index)
sp_albumsp_track_album (sp_track *track)
const char * sp_track_name (sp_track *track)
int sp_track_duration (sp_track *track)
int sp_track_popularity (sp_track *track)
int sp_track_disc (sp_track *track)
int sp_track_index (sp_track *track)
void sp_track_add_ref (sp_track *track)
void sp_track_release (sp_track *track)

Function Documentation

void sp_track_add_ref ( sp_track track  ) 

Increase the reference count of a track

Parameters:
[in] track The track object
Examples:
track.c.

sp_album* sp_track_album ( sp_track track  ) 

The album of the specified track

Parameters:
[in] track A track object
Returns:
The album of the given track. You need to increase the refcount if you want to keep the pointer around. If no metadata is available for the track yet, this function returns 0.
Examples:
track.c.

sp_artist* sp_track_artist ( sp_track track,
int  index 
)

The artist matching the specified index performing on the current track.

Parameters:
[in] track The track whose participating artist you are interested in
[in] index The index for the participating artist. Should be in the interval [0, sp_track_num_artists() - 1]
Returns:
The participating artist, or NULL if invalid index

int sp_track_disc ( sp_track track  ) 

Returns the disc number for a track

Parameters:
[in] track A track object
Returns:
Disc index. Possible values are [1, total number of discs on album] This function returns valid data only for tracks appearing in a browse artist or browse album result (otherwise returns 0).
Examples:
browse.c.

int sp_track_duration ( sp_track track  ) 

The duration, in milliseconds, of the specified track

Here is a snippet from track.c:

static void print_track(sp_track *track)
{
    int duration = sp_track_duration(track);

    printf("Track \"%s\" [%d:%02d] has %d artist(s), %d%% popularity\n",
           sp_track_name(track),
           duration / 60000,
           (duration / 1000) / 60,
           sp_track_num_artists(track),
           sp_track_popularity(track));
}

Parameters:
[in] track A track object
Returns:
The duration of the specified track, in milliseconds If no metadata is available for the track yet, this function returns 0.
Examples:
browse.c, search.c, and track.c.

sp_error sp_track_error ( sp_track track  ) 

Return an error code associated with a track. For example if it could not load

Parameters:
[in] track The track
Returns:
Error code

int sp_track_index ( sp_track track  ) 

Returns the position of a track on its disc

Parameters:
[in] track A track object
Returns:
Track position, starts at 1 (relative the corresponding disc) This function returns valid data only for tracks appearing in a browse artist or browse album result (otherwise returns 0).
Examples:
browse.c.

bool sp_track_is_loaded ( sp_track track  ) 

Get load status for the specified track. If the track is not loaded yet, all other functions operating on the track return default values.

Here is a snippet from track.c:

    if (!g_track || !sp_track_is_loaded(g_track))
        return;

    print_track(g_track);

    request_cover(session, g_track);

    // We increased the reference count in session_ready(), better decrease it here.
    sp_track_release(g_track);
    g_track = NULL;

Parameters:
[in] track The track whose load status you are interested in
Returns:
True if track is loaded, otherwise false
Examples:
jukebox.c, and track.c.

const char* sp_track_name ( sp_track track  ) 

The string representation of the specified track's name

Here is a snippet from track.c:

static void print_track(sp_track *track)
{
    int duration = sp_track_duration(track);

    printf("Track \"%s\" [%d:%02d] has %d artist(s), %d%% popularity\n",
           sp_track_name(track),
           duration / 60000,
           (duration / 1000) / 60,
           sp_track_num_artists(track),
           sp_track_popularity(track));
}

Parameters:
[in] track A track object
Returns:
The string representation of the specified track's name. Returned string is valid as long as the album object stays allocated and no longer than the next call to sp_session_process_events() If no metadata is available for the track yet, this function returns empty string.
Examples:
browse.c, jukebox.c, search.c, and track.c.

int sp_track_num_artists ( sp_track track  ) 

The number of artists performing on the specified track

Parameters:
[in] track The track whose number of participating artists you are interested in
Returns:
The number of artists performing on the specified track. If no metadata is available for the track yet, this function returns 0.
Examples:
browse.c, search.c, and track.c.

int sp_track_popularity ( sp_track track  ) 

Returns popularity for track

Parameters:
[in] track A track object
Returns:
Popularity in range 0 to 100, 0 if undefined If no metadata is available for the track yet, this function returns 0.
Examples:
browse.c, search.c, and track.c.

void sp_track_release ( sp_track track  ) 

Decrease the reference count of a track

Parameters:
[in] track The track object
Examples:
track.c.


Generated on Tue Apr 7 15:21:55 2009.
Copyright © 2006–2009 Spotify Ltd