|
|
|
@ -64,6 +64,7 @@ MpvPart::MpvPart(TQWidget* parentWidget, const char* widgetName, TQObject* paren
|
|
|
|
|
: KaffeinePart(parent, name ? name : "MpvPart"),
|
|
|
|
|
m_current(0),
|
|
|
|
|
m_seeking(false),
|
|
|
|
|
m_seekpos(0),
|
|
|
|
|
m_recordFilePath(),
|
|
|
|
|
m_context(nullptr),
|
|
|
|
|
m_error(nullptr),
|
|
|
|
@ -151,7 +152,7 @@ void MpvPart::initActions()
|
|
|
|
|
|
|
|
|
|
/*** Position toolbar ***/
|
|
|
|
|
// Important: we have a max of 1000 instead of 100 for better precision; multiply/divide your percentages by 10
|
|
|
|
|
m_position = new TQSlider(0, 1000, 10, 0, TQt::Horizontal, 0);
|
|
|
|
|
m_position = new TQSlider(0, 100, 10, 0, TQt::Horizontal, 0);
|
|
|
|
|
TQToolTip::add(m_position, i18n("Position"));
|
|
|
|
|
m_position->setTracking(false);
|
|
|
|
|
m_position->setFocusPolicy(TQ_NoFocus);
|
|
|
|
@ -245,8 +246,7 @@ void MpvPart::customEvent(TQCustomEvent *event) {
|
|
|
|
|
|
|
|
|
|
else if (pe->property() == "percent-pos" && pe->format() == MPV_FORMAT_DOUBLE) {
|
|
|
|
|
if (!m_seeking) {
|
|
|
|
|
m_percent = pe->toDouble();
|
|
|
|
|
m_position->setValue(m_percent * 10);
|
|
|
|
|
m_position->setValue(pe->toDouble());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -262,6 +262,11 @@ void MpvPart::customEvent(TQCustomEvent *event) {
|
|
|
|
|
else if (event->type() == MPVPART_EVENT_EOF) {
|
|
|
|
|
resetTime();
|
|
|
|
|
|
|
|
|
|
if (!m_mrl.isEmpty()) {
|
|
|
|
|
closeURL();
|
|
|
|
|
stateChanged("not_playing");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MpvEOFEvent *eofe = (MpvEOFEvent *)event;
|
|
|
|
|
if (eofe->reason() == MPV_END_FILE_REASON_ERROR) {
|
|
|
|
|
KMessageBox::detailedError(nullptr, i18n("Cannot play file."), eofe->error());
|
|
|
|
@ -485,6 +490,7 @@ void MpvPart::resetTime() {
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotStartSeeking() {
|
|
|
|
|
if (!isSeekable()) {
|
|
|
|
|
kdWarning() << "current file not seekable!" << endl;
|
|
|
|
|
emit setStatusBarText( i18n("Cannot seek current file!") );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -493,13 +499,26 @@ void MpvPart::slotStartSeeking() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotStopSeeking() {
|
|
|
|
|
slotSetPosition(m_percent);
|
|
|
|
|
if (!m_seeking) return;
|
|
|
|
|
|
|
|
|
|
slotSetPosition(m_seekpos);
|
|
|
|
|
slotPause(false);
|
|
|
|
|
m_seeking = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotSetSeekingPos(int pos) {
|
|
|
|
|
m_percent = (uint)pos / 10;
|
|
|
|
|
void MpvPart::slotSetSeekingPos(int percent) {
|
|
|
|
|
if (!m_seeking) return;
|
|
|
|
|
|
|
|
|
|
// Compute current position and update playtime indicator
|
|
|
|
|
TQTime duration = m_mrl.length();
|
|
|
|
|
uint secs = (duration.hour() * 60 * 60) +
|
|
|
|
|
(duration.minute() * 60) +
|
|
|
|
|
duration.second();
|
|
|
|
|
|
|
|
|
|
m_seekpos = secs * percent / 100;
|
|
|
|
|
|
|
|
|
|
TQTime pos; pos = pos.addSecs(m_seekpos);
|
|
|
|
|
updatePlaytime(pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint MpvPart::volume() const {
|
|
|
|
@ -509,7 +528,7 @@ uint MpvPart::volume() const {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint MpvPart::position() const {
|
|
|
|
|
return m_percent;
|
|
|
|
|
return m_position->value();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotSetVolume(uint volume) {
|
|
|
|
@ -519,11 +538,11 @@ void MpvPart::slotSetVolume(uint volume) {
|
|
|
|
|
mpv_set_property(m_mpv, "ao-volume", MPV_FORMAT_INT64, &value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotSetPosition(uint position) {
|
|
|
|
|
void MpvPart::slotSetPosition(uint secs) {
|
|
|
|
|
if (!m_mpv) return;
|
|
|
|
|
|
|
|
|
|
int64_t value = (int64_t)position;
|
|
|
|
|
mpv_set_property(m_mpv, "percent-pos", MPV_FORMAT_INT64, &value);
|
|
|
|
|
int64_t value = (int64_t)secs;
|
|
|
|
|
mpv_set_property(m_mpv, "time-pos", MPV_FORMAT_INT64, &value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotPrevious() {
|
|
|
|
|