[PATCH] Info about video and audio format

Forum to talk about the development of SMPlayer (code, patches...).

[PATCH] Info about video and audio format

Postby capt.d. » Mon May 23, 2016 12:24 pm

Aloha

I've add a video and audio format in the status bar, right behind the video resolution.
For skin gui:
Code: Select all
--- src/mediabarpanel.cpp 2016-05-22 18:17:37.000000000 +0200
+++ mediabarpanel.cpp 2016-05-24 12:38:37.000000000 +0200
@@ -124,13 +124,18 @@ void MediaBarPanel::updateMediaInfo()
 {
     //QString s = QString("%1 (%2x%3)").arg(core->mdat.displayName()).arg(core->mdat.video_width).arg(core->mdat.video_height);
     mediaPanel->setMediaLabelText(core->mdat.displayName());
-
+   QString s = QString(""); 
     if ((core->mdat.video_width != 0) && (core->mdat.video_height != 0)) {
-        QString s = QString("%1x%2").arg(core->mdat.video_width).arg(core->mdat.video_height);
-        mediaPanel->setResolutionLabelText(s);
-    } else {
-        mediaPanel->setResolutionLabelText(" ");
-    }
+     s.append(tr("%1x%2 %3 fps", "width + height + fps").arg(core->mdat.video_width).arg(core->mdat.video_height).arg(core->mdat.video_fps));
+    }
+   if (!core->mdat.novideo){
+     s.append(" ").append(core->mdat.video_format).append(" / ").append(core->mdat.audio_format);
+   }
+   else {
+     s.append(" ").append(core->mdat.audio_codec).append(" ").append(tr("%1 kHz").arg(core->mdat.audio_rate / 1000)).append(" / ").append(tr("%1 kbps").arg(core->mdat.audio_bitrate / 1000));
+   }
+   
+   mediaPanel->setResolutionLabelText(s);
 }

 void MediaBarPanel::displayMessage(QString status, int time)

and for default gui:
Code: Select all
--- src/defaultgui.cpp  2016-05-22 19:30:42.000000000 +0200
+++ defaultgui.cpp  2016-05-24 12:39:14.000000000 +0200
@@ -599,11 +599,17 @@ void DefaultGui::displayABSection(int se
 }

 void DefaultGui::displayVideoInfo(int width, int height, double fps) {
+ QString s = QString("");
  if ((width != 0) && (height != 0)) {
-   video_info_display->setText(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
+   s.append(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
+ }
+ if (!core->mdat.novideo) {
+     s.append(" ").append(core->mdat.video_format).append("/").append(core->mdat.audio_format);
  } else {
-   video_info_display->setText(" ");
+    s.append(" ").append(core->mdat.audio_codec).append(" ").append(tr("%1 kHz").arg(core->mdat.audio_rate / 1000)).append(" / ").append(tr("%1 kbps").arg(core->mdat.audio_bitrate / 1000));
  }
+
+ video_info_display->setText(s);
 }

 void DefaultGui::updateWidgets() {


Edit:
I've forgotten to mention, patch is for version 16.1
And I see now, that rvm was faster ;)
http://forum.smplayer.info/viewtopic.php?f=2&t=8417#p15510

Edit 2:
It looks ugly with audio only files, so I've added condition and formatting.

---
Live long and prosper.
capt.d.
capt.d.
 
Posts: 9
Joined: Sun Dec 08, 2013 7:02 pm

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest