Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MythMusic: Provide play time components to templates #793

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions mythplugins/mythmusic/mythmusic/musiccommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ void MusicCommon::changeSpeed(bool up)
else
gPlayer->decSpeed();
showSpeed(true);
updatePlaylistStats(); // update trackspeed and map for templates
}
}

Expand Down Expand Up @@ -1066,10 +1067,8 @@ void MusicCommon::stop(void)
{
gPlayer->stop();

QString time_string = getTimeString(m_maxTime, 0s);

if (m_timeText)
m_timeText->SetText(time_string);
m_timeText->SetText(getTimeString(m_maxTime, 0s));
if (m_infoText)
m_infoText->Reset();
}
Expand Down Expand Up @@ -2119,6 +2118,9 @@ void MusicCommon::updatePlaylistStats(void)
else if (playlistName == "stream_playlist")
playlistName = tr("Stream Playlist");
map["playlistname"] = playlistName;
map["playedtime"] = getTimeString(m_currentTime, 0s); // v34 - parts
map["totaltime"] = getTimeString(m_maxTime, 0s);
map["trackspeed"] = getTimeString(-1s, 0s);
}
else
{
Expand All @@ -2129,6 +2131,9 @@ void MusicCommon::updatePlaylistStats(void)
map["playlistplayedtime"] = "";
map["playlisttotaltime"] = "";
map["playlistname"] = "";
map["playedtime"] = ""; // v34 - parts for track templates
map["totaltime"] = "";
map["trackspeed"] = "";
}

SetTextFromMap(map);
Expand All @@ -2139,16 +2144,22 @@ void MusicCommon::updatePlaylistStats(void)

QString MusicCommon::getTimeString(std::chrono::seconds exTime, std::chrono::seconds maxTime)
{
if (maxTime <= 0ms)
if (exTime > -1s && maxTime <= 0s)
return MythDate::formatTime(exTime,
(exTime >= 1h) ? "H:mm:ss" : "mm:ss");

QString fmt = (maxTime >= 1h) ? "H:mm:ss" : "mm:ss";
QString out = MythDate::formatTime(exTime, fmt)
+ " / " + MythDate::formatTime(maxTime, fmt);
float speed = gPlayer->getSpeed();
if (lroundf(speed * 100.0F) != 100.0F) // v34 - show altered speed
out += QString(", %1").arg(speed);
float speed = gPlayer->getSpeed(); // v34 - show altered speed
QString speedstr = "";
if (lroundf(speed * 100.0F) != 100.0F)
{
speedstr = QString("%1").arg(speed);
out += ", " + speedstr + "X";
}
if (exTime <= -1s)
return speedstr;
return out;
}

Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/musiccommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MPLUGIN_PUBLIC MusicCommon : public MythScreenType
void updateShuffleMode(bool updateUIList = false);

void changeVolume(bool up) const;
static void changeSpeed(bool up);
void changeSpeed(bool up);
void toggleMute(void) const;
static void toggleUpmix(void);
static void showVolume(void);
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/theme/default-wide/music-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@
</textarea>

<textarea name="playlisttime" from="basetextarea">
<area>300,0,300,30</area>
<area>300,0,400,30</area>
<font>basesmall</font>
<align>left,top</align>
</textarea>
Expand Down Expand Up @@ -913,7 +913,7 @@
</textarea>

<textarea name="time" from="basetextarea">
<area>1020,15,235,34</area>
<area>1020,15,245,34</area>
<align>right</align>
<font>basesmall</font>
</textarea>
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/theme/default-wide/music-ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1281,8 +1281,8 @@
</textarea>

<textarea name="time" from="basetextarea">
<area>385,125,185,25</area>
<align>right</align>
<area>375,125,285,25</area>
<align>left</align>
</textarea>

<imagetype name="coverart">
Expand Down
8 changes: 6 additions & 2 deletions mythtv/themes/MythCenter-wide/music-ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,10 @@
<window name="miniplayer">
<area>-1,5,590,190</area>

<textarea name="channel"> <!--radio stream?-->
<area>0,0,0,0</area> <!--hidden-->
</textarea>

<imagetype name="track_info_background">
<filename>miniplayer_background.png</filename>
<area>10,10,569,170</area>
Expand Down Expand Up @@ -1063,8 +1067,8 @@
<area>170,125,250,25</area>
</textarea>

<textarea name="time" from="basetextarea">
<area>385,125,185,25</area>
<textarea name="time" from="basetextarea" depends="!channel">
<area>285,125,285,25</area>
<align>right</align>
</textarea>

Expand Down