Skip to content

Playcount API ​

Provides track playback statistics inspection and library-wide aggregation backed by foo_playcount.

playcount ​

playcount.get ​

Read the foo_playcount statistics of tracks. Without foo_playcount installed the counts read as zero and the dates are absent.

ParameterTypeRequiredDescription
pathsstring[]YesTrack paths; a |subsong:N suffix selects a CUE subsong. A suffix whose index cannot be read, such as |subsong:abc, is dropped and the path means the first track.

Returns

FieldTypeDescription
countintegerNumber of rows in results.
resultsPlaycountRow[]One row per requested path, in request order.
results[].pathstringThe path as requested, including any |subsong:N suffix, on successful and failed rows alike.
results[].successbooleanWhether the track could be resolved.
results[].errorstringWhy the track could not be resolved; present when success is false.
results[].playCountintegerNumber of plays; 0 when never played. Present when success is true.
results[].firstPlayedstringTime of the first play, as foo_playcount formats it. Absent when unknown.
results[].lastPlayedstringTime of the most recent play. Absent when unknown.
results[].addedstringTime the track was added to the media library. Absent when unknown.
results[].ratingintegerRating from 1 to 5. Absent when the track is unrated, never 0.
results[].inLibrarybooleanWhether the track is in the media library. Present when success is true.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const res = await fb2k.invoke('playcount.get', {
    paths: ['C:\\Music\\song.flac']
});
if (res.success === false) throw new Error(res.error);
const { results } = res;

playcount.getBatch ​

Same as playcount.get, under the name batch callers expect.

ParameterTypeRequiredDescription
pathsstring[]YesTrack paths; a |subsong:N suffix selects a CUE subsong. A suffix whose index cannot be read, such as |subsong:abc, is dropped and the path means the first track.

Returns

FieldTypeDescription
countintegerNumber of rows in results.
resultsPlaycountRow[]One row per requested path, in request order.
results[].pathstringThe path as requested, including any |subsong:N suffix, on successful and failed rows alike.
results[].successbooleanWhether the track could be resolved.
results[].errorstringWhy the track could not be resolved; present when success is false.
results[].playCountintegerNumber of plays; 0 when never played. Present when success is true.
results[].firstPlayedstringTime of the first play, as foo_playcount formats it. Absent when unknown.
results[].lastPlayedstringTime of the most recent play. Absent when unknown.
results[].addedstringTime the track was added to the media library. Absent when unknown.
results[].ratingintegerRating from 1 to 5. Absent when the track is unrated, never 0.
results[].inLibrarybooleanWhether the track is in the media library. Present when success is true.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('playcount.getBatch', { paths: ['C:\\Music\\song.flac'] });

playcount.getStats ​

Summarise play counts and ratings over the whole media library.

This method takes no parameters.

Returns

FieldTypeDescription
totalTracksintegerTracks in the media library.
playedTracksintegerTracks played at least once.
unplayedTracksintegerTracks never played.
ratedTracksintegerTracks with a rating.
totalPlayCountintegerSum of all play counts.
maxPlayCountintegerHighest play count of any track.
averagePlayCountnumberMean play count of the played tracks; 0 when none was played.
averageRatingnumberMean rating of the rated tracks; 0 when none is rated.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('playcount.getStats');

playcount.set ​

Placeholder: foo_playcount offers no way to change statistics, so this always fails with NOT_SUPPORTED. Change ratings with rating.set.

ParameterTypeRequiredDescription
pathstringYesPath of the track.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('playcount.set', { path: 'C:\\Music\\song.flac' });