mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-26 06:03:20 -05:00
[jsonapi] queue/track responses incl type/bitrate/samplerate/channels
This commit is contained in:
parent
e2d62a62a4
commit
f194145b8e
@ -1977,6 +1977,10 @@ curl --include \
|
||||
| path | string | Path |
|
||||
| uri | string | Resource identifier |
|
||||
| artwork_url | string | *(optional)* [Artwork url](#artwork-urls) |
|
||||
| type | string | file (codec) type (ie mp3/flac/...) |
|
||||
| bitrate | string | file bitrate (ie 192/128/...) |
|
||||
| samplerate | string | file sample rate (ie 44100/48000/...) |
|
||||
| channel | string | file channel (ie mono/stereo/xx ch)) |
|
||||
|
||||
|
||||
### `playlist` object
|
||||
|
@ -231,6 +231,11 @@ track_to_json(struct db_media_file_info *dbmfi)
|
||||
safe_json_add_time_from_string(item, "date_released", dbmfi->date_released, false);
|
||||
safe_json_add_int_from_string(item, "seek_ms", dbmfi->seek);
|
||||
|
||||
safe_json_add_string(item, "type", dbmfi->type);
|
||||
safe_json_add_int_from_string(item, "samplerate", dbmfi->samplerate);
|
||||
safe_json_add_int_from_string(item, "bitrate", dbmfi->bitrate);
|
||||
safe_json_add_int_from_string(item, "channels", dbmfi->channels);
|
||||
|
||||
ret = safe_atoi32(dbmfi->media_kind, &intval);
|
||||
if (ret == 0)
|
||||
safe_json_add_string(item, "media_kind", db_media_kind_label(intval));
|
||||
@ -1656,6 +1661,8 @@ queue_item_to_json(struct db_queue_item *queue_item, char shuffle)
|
||||
json_object *item;
|
||||
char uri[100];
|
||||
char artwork_url[100];
|
||||
char chbuf[6];
|
||||
const char *ch;
|
||||
int ret;
|
||||
|
||||
item = json_object_new_object();
|
||||
@ -1713,6 +1720,19 @@ queue_item_to_json(struct db_queue_item *queue_item, char shuffle)
|
||||
json_object_object_add(item, "artwork_url", json_object_new_string(artwork_url));
|
||||
}
|
||||
|
||||
safe_json_add_string(item, "type", queue_item->type);
|
||||
json_object_object_add(item, "bitrate", json_object_new_int(queue_item->bitrate));
|
||||
json_object_object_add(item, "samplerate", json_object_new_int(queue_item->samplerate));
|
||||
switch (queue_item->channels)
|
||||
{
|
||||
case 1: ch = "mono"; break;
|
||||
case 2: ch = "stereo"; break;
|
||||
default:
|
||||
snprintf(chbuf, sizeof(chbuf), "%d ch", queue_item->channels);
|
||||
ch = chbuf;
|
||||
}
|
||||
safe_json_add_string(item, "channels", ch);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user