|
|
|
@ -67,7 +67,8 @@ MpvPart::MpvPart(TQWidget* parentWidget, const char* widgetName, TQObject* paren
|
|
|
|
|
m_recordFilePath(),
|
|
|
|
|
m_context(nullptr),
|
|
|
|
|
m_error(nullptr),
|
|
|
|
|
m_criticalError(nullptr)
|
|
|
|
|
m_criticalError(nullptr),
|
|
|
|
|
m_playtimeMode(CurrentTime)
|
|
|
|
|
{
|
|
|
|
|
// Create an instance of this class
|
|
|
|
|
setInstance(MpvPartFactory::instance());
|
|
|
|
@ -162,10 +163,12 @@ void MpvPart::initActions()
|
|
|
|
|
posAction->setAutoSized(true);
|
|
|
|
|
|
|
|
|
|
m_playtime = new TQPushButton(0);
|
|
|
|
|
TQToolTip::add(m_playtime, i18n("Press to change playtime display mode."));
|
|
|
|
|
TQFontMetrics met(TDEGlobalSettings::generalFont());
|
|
|
|
|
m_playtime->setFixedWidth(met.width("-88:88:88") + 6);
|
|
|
|
|
m_playtime->setFixedWidth(met.width(" -88:88:88 "));
|
|
|
|
|
m_playtime->setSizePolicy(TQSizePolicy (TQSizePolicy::Fixed, TQSizePolicy::Fixed));
|
|
|
|
|
m_playtime->setFocusPolicy(TQ_NoFocus);
|
|
|
|
|
connect(m_playtime, SIGNAL(pressed()), this, SLOT(slotTogglePlaytimeMode()));
|
|
|
|
|
new KWidgetAction(m_playtime, i18n("Playtime"), 0, 0, 0, actionCollection(), "player_playtime");
|
|
|
|
|
|
|
|
|
|
/*** Volume toolbar ***/
|
|
|
|
@ -201,13 +204,43 @@ void MpvPart::slotViewLog() {
|
|
|
|
|
logViewer->exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotTogglePlaytimeMode() {
|
|
|
|
|
++m_playtimeMode;
|
|
|
|
|
if (m_playtimeMode == PLAYTIME_MODE_LAST) {
|
|
|
|
|
m_playtimeMode = CurrentTime;
|
|
|
|
|
}
|
|
|
|
|
updatePlaytime(m_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::updatePlaytime(TQTime time) {
|
|
|
|
|
TQString label;
|
|
|
|
|
switch (m_playtimeMode) {
|
|
|
|
|
case CurrentTime: {
|
|
|
|
|
label = time.toString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case RemainingTime: {
|
|
|
|
|
TQTime duration = m_mrl.length();
|
|
|
|
|
int h = duration.hour() - time.hour();
|
|
|
|
|
int m = duration.minute() - time.minute();
|
|
|
|
|
int s = duration.second() - time.second();
|
|
|
|
|
label = TQString("-%1:%2:%3").arg(TQString::number(h).rightJustify(2, '0'),
|
|
|
|
|
TQString::number(m).rightJustify(2, '0'),
|
|
|
|
|
TQString::number(s).rightJustify(2, '0'));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_playtime->setText(label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Custom events dispatched from mpv event thread are handled here
|
|
|
|
|
void MpvPart::customEvent(TQCustomEvent *event) {
|
|
|
|
|
if (event->type() == MPVPART_EVENT_PROPERTY_CHANGE) {
|
|
|
|
|
MpvPropertyChangeEvent *pe = (MpvPropertyChangeEvent *)event;
|
|
|
|
|
if (pe->property() == "time-pos" && pe->format() == MPV_FORMAT_DOUBLE) {
|
|
|
|
|
m_time = pe->toTime();
|
|
|
|
|
m_playtime->setText(m_time.toString());
|
|
|
|
|
updatePlaytime(m_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (pe->property() == "percent-pos" && pe->format() == MPV_FORMAT_DOUBLE) {
|
|
|
|
@ -218,10 +251,9 @@ void MpvPart::customEvent(TQCustomEvent *event) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (pe->property() == "duration" && pe->format() == MPV_FORMAT_DOUBLE) {
|
|
|
|
|
MRL mrl = m_playlist[m_current];
|
|
|
|
|
TQTime length = TQTime().addMSecs(pe->toDouble() * 1000);
|
|
|
|
|
if (!length.isNull()) {
|
|
|
|
|
mrl.setLength(length);
|
|
|
|
|
m_mrl.setLength(length);
|
|
|
|
|
emit signalNewMeta(m_mrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|