diff options
author | Mavridis Philippe <[email protected]> | 2023-05-31 19:05:11 +0300 |
---|---|---|
committer | Mavridis Philippe <[email protected]> | 2024-09-08 01:41:03 +0300 |
commit | d735cca679e3f90d562edbae153a65a893143b70 (patch) | |
tree | 5c3993a8ad6df6ce9e38daf79eab4643d57e10df | |
parent | a39d80d9a0a89908af5a3d8266c15bbee52fe3ad (diff) | |
download | kaffeine-d735cca679e3f90d562edbae153a65a893143b70.tar.gz kaffeine-d735cca679e3f90d562edbae153a65a893143b70.zip |
mpvpart: add idle state logo for consistency w/ other backends
Signed-off-by: Mavridis Philippe <[email protected]>
-rw-r--r-- | kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp | 39 | ||||
-rw-r--r-- | kaffeine/src/player-parts/libmpv-part/libmpv_part.h | 1 |
2 files changed, 27 insertions, 13 deletions
diff --git a/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp b/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp index 35efd80..137497b 100644 --- a/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp +++ b/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp @@ -34,6 +34,7 @@ #include <tdeparts/genericfactory.h> #include <tdeglobalsettings.h> #include <tdeio/netaccess.h> +#include <kstandarddirs.h> #include <tdemessagebox.h> #include <tdefiledialog.h> #include <tdeaction.h> @@ -79,6 +80,10 @@ MpvPart::MpvPart(TQWidget* parentWidget, const char* widgetName, TQObject* paren return; } + m_logoPath = locate( "data", "kaffeine/logo" ); + kdDebug() << "libmpvpart: Found logo animation: " << m_logoPath << endl; + + closeURL(); // displays logo emit setStatusBarText(i18n("Ready")); } @@ -311,24 +316,24 @@ bool MpvPart::openURL(const MRL& mrl) { bool MpvPart::closeURL() { if (!m_mpv) return false; - const char *args[] = {"playlist-remove", "current", nullptr}; - mpv_command_async(m_mpv, 0, args); + m_mrl.reset(); + if (!m_logoPath.isNull()) { + const char *logo_args[] = {"loadfile", m_logoPath.local8Bit(), nullptr }; + mpv_command_async(m_mpv, 0, logo_args); + slotPause(true); + } return true; } void MpvPart::slotPlay() { if (!m_mpv) return; - if (isPaused()) { - int value = 0; - mpv_set_property(m_mpv, "pause", MPV_FORMAT_FLAG, &value); - stateChanged(isStream() ? "playing_stream" : "playing_file"); - return; - } + kdDebug() << "m_playlist count: " << m_playlist.count() << endl; if (m_playlist.count() > 0) { emit setStatusBarText( i18n("Opening...") ); MRL curMRL = m_playlist[m_current]; + kdDebug() << "current: " << curMRL.url() << endl; const char *args[] = {"loadfile", curMRL.url().local8Bit(), nullptr}; mpv_command_async(m_mpv, 0, args); @@ -339,6 +344,10 @@ void MpvPart::slotPlay() { emit signalRequestCurrentTrack(); } + if (isPaused()) { + slotPause(false); + } + stateChanged(isStream() ? "playing_stream" : "playing_file"); } @@ -403,7 +412,7 @@ bool MpvPart::isSeekable() { } void MpvPart::resetTime() { - m_playtime->setText("0:00:00"); + m_playtime->setText("00:00:00"); m_position->setValue(0); } @@ -471,11 +480,15 @@ void MpvPart::slotNext() { } void MpvPart::slotStop() { - if (isPlaying()) { - const char *args[] = {"stop", nullptr}; - mpv_command_async(m_mpv, 0, args); - stateChanged("not_playing"); + if (!isPlaying()) { + return; } + + const char *stop_args[] = {"stop", nullptr}; + mpv_command(m_mpv, stop_args); + + closeURL(); + stateChanged("not_playing"); } void MpvPart::slotMute() { diff --git a/kaffeine/src/player-parts/libmpv-part/libmpv_part.h b/kaffeine/src/player-parts/libmpv-part/libmpv_part.h index 242c763..cc6f496 100644 --- a/kaffeine/src/player-parts/libmpv-part/libmpv_part.h +++ b/kaffeine/src/player-parts/libmpv-part/libmpv_part.h @@ -139,6 +139,7 @@ class MpvPart : public KaffeinePart TQLabel *m_recordFile; TQPopupMenu *m_context; TQPopupMenu *m_subs; + TQString m_logoPath; TQValueList<MRL> m_playlist; uint m_current; |