From 54ca879739ca49ca628ad6db379d3485cb018d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 20 Nov 2009 15:16:13 +0000 Subject: [PATCH] * Also write the bitrate as attribute. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34157 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/MainWin.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 8aa3354534..571202f653 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -1849,6 +1849,8 @@ MainWin::_SetFileAttributes() if (node.InitCheck()) return; + // write duration + attr_info info; status_t status = node.GetAttrInfo("Audio:Length", &info); if (status != B_OK || info.size == 0) { @@ -1860,6 +1862,21 @@ MainWin::_SetFileAttributes() node.WriteAttr("Audio:Length", B_STRING_TYPE, 0, text, strlen(text) + 1); } + + // write bitrate + + status = node.GetAttrInfo("Audio:Bitrate", &info); + if (status != B_OK || info.size == 0) { + media_format format; + if (fController->GetEncodedAudioFormat(&format) == B_OK + && format.type == B_MEDIA_ENCODED_AUDIO) { + int32 bitrate = (int32)(format.u.encoded_audio.bit_rate / 1000); + char text[256]; + snprintf(text, sizeof(text), "%ld kbit", bitrate); + node.WriteAttr("Audio:Bitrate", B_STRING_TYPE, 0, text, + strlen(text) + 1); + } + } } }