|
|
|
@ -121,12 +121,14 @@ bool MpvPart::initMpv() {
|
|
|
|
|
|
|
|
|
|
void MpvPart::initActions()
|
|
|
|
|
{
|
|
|
|
|
/** Playback controls ***/
|
|
|
|
|
new TDEAction(i18n("Play"), "media-playback-start", 0, this, SLOT(slotPlay()), actionCollection(), "player_play");
|
|
|
|
|
new TDEAction(i18n("Pause"), "media-playback-pause", Key_Space, this, SLOT(slotTogglePause()), actionCollection(), "player_pause");
|
|
|
|
|
new TDEAction(i18n("Stop"), "media-playback-stop", Key_Backspace, this, SLOT(slotStop()), actionCollection(), "player_stop");
|
|
|
|
|
new TDEAction(i18n("&Previous"), "media-skip-backward", Key_PageUp, this, SLOT(slotPrevious()), actionCollection(), "player_previous");
|
|
|
|
|
new TDEAction(i18n("&Next"), "media-skip-forward", Key_PageDown, this, SLOT(slotNext()), actionCollection(), "player_next");
|
|
|
|
|
|
|
|
|
|
/*** 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);
|
|
|
|
|
TQToolTip::add(m_position, i18n("Position"));
|
|
|
|
@ -146,6 +148,13 @@ void MpvPart::initActions()
|
|
|
|
|
m_playtime->setFocusPolicy(TQ_NoFocus);
|
|
|
|
|
new KWidgetAction(m_playtime, i18n("Playtime"), 0, 0, 0, actionCollection(), "player_playtime");
|
|
|
|
|
|
|
|
|
|
/*** Volume toolbar ***/
|
|
|
|
|
new TDEAction(i18n("&Mute"), "player_mute", Key_U, this, SLOT(slotMute()), actionCollection(), "player_mute");
|
|
|
|
|
|
|
|
|
|
m_volume = new TQSlider(0, 100, 10, 100, TQt::Horizontal, 0);
|
|
|
|
|
connect(m_volume, SIGNAL(sliderMoved(int)), this, SLOT(slotSetVolume(int)));
|
|
|
|
|
KWidgetAction *volAction = new KWidgetAction(m_volume, i18n("Volume"), 0, 0, 0, actionCollection(), "player_volume");
|
|
|
|
|
|
|
|
|
|
resetTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -328,6 +337,16 @@ bool MpvPart::isPaused() {
|
|
|
|
|
return (bool)result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MpvPart::isMute() {
|
|
|
|
|
if (!m_mpv) return false;
|
|
|
|
|
|
|
|
|
|
int result;
|
|
|
|
|
if (mpv_get_property(m_mpv, "ao-mute", MPV_FORMAT_FLAG, &result) < 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return (bool)result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::resetTime() {
|
|
|
|
|
m_playtime->setText("0:00:00");
|
|
|
|
|
m_position->setValue(0);
|
|
|
|
@ -349,15 +368,20 @@ void MpvPart::slotSetSeekingPos(int pos) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint MpvPart::volume() const {
|
|
|
|
|
return 0;
|
|
|
|
|
int64_t value = 0;
|
|
|
|
|
mpv_get_property(m_mpv, "ao-volume", MPV_FORMAT_INT64, &value);
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint MpvPart::position() const {
|
|
|
|
|
return m_percent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotSetVolume(uint) {
|
|
|
|
|
void MpvPart::slotSetVolume(uint volume) {
|
|
|
|
|
if (!m_mpv) return;
|
|
|
|
|
|
|
|
|
|
int64_t value = (int64_t)volume;
|
|
|
|
|
mpv_set_property(m_mpv, "ao-volume", MPV_FORMAT_INT64, &value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotSetPosition(uint position) {
|
|
|
|
@ -395,7 +419,8 @@ void MpvPart::slotStop() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpvPart::slotMute() {
|
|
|
|
|
|
|
|
|
|
int value = isMute() ? 0 : 1;
|
|
|
|
|
mpv_set_property(m_mpv, "ao-mute", MPV_FORMAT_FLAG, &value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "libmpv_part.moc"
|