diff --git a/README_JSON_API.md b/README_JSON_API.md index ca633229..1f06e3d0 100644 --- a/README_JSON_API.md +++ b/README_JSON_API.md @@ -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 diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index 9c3ad537..32b10c0e 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -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; }