summaryrefslogtreecommitdiffstats
path: root/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp')
-rw-r--r--kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp b/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp
index 2c0c1f2..65148b5 100644
--- a/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp
+++ b/kaffeine/src/player-parts/libmpv-part/libmpv_part.cpp
@@ -66,6 +66,7 @@ K_EXPORT_COMPONENT_FACTORY (libmpvpart, MpvPartFactory);
MpvPart::MpvPart(TQWidget* parentWidget, const char* widgetName, TQObject* parent, const char* name, const TQStringList& /*args*/)
: KaffeinePart(parent, name ? name : "MpvPart"),
+ m_mpv(nullptr),
m_current(0),
m_seeking(false),
m_seekpos(0),
@@ -430,6 +431,8 @@ void MpvPart::slotPlay() {
}
void MpvPart::slotPause(bool pause) {
+ if (!m_mpv) return;
+
int value = pause ? 1 : 0;
mpv_set_property(m_mpv, "pause", MPV_FORMAT_FLAG, &value);
stateChanged(pause ? "paused" : (isStream() ? "playing_stream" : "playing_file"));
@@ -528,6 +531,8 @@ void MpvPart::slotSetSeekingPos(int percent) {
}
uint MpvPart::volume() const {
+ if (!m_mpv) return 0;
+
int64_t value = 0;
mpv_get_property(m_mpv, "ao-volume", MPV_FORMAT_INT64, &value);
return value;
@@ -572,7 +577,7 @@ void MpvPart::slotNext() {
}
void MpvPart::slotStop() {
- if (!isPlaying()) {
+ if (!m_mpv || !isPlaying()) {
return;
}
@@ -584,11 +589,13 @@ void MpvPart::slotStop() {
}
void MpvPart::slotMute() {
+ if (!m_mpv) return;
int value = isMute() ? 0 : 1;
mpv_set_property(m_mpv, "ao-mute", MPV_FORMAT_FLAG, &value);
}
void MpvPart::slotReloadSubtitles() {
+ if (!m_mpv) return;
TQStringList subtitles = m_mrl.subtitleFiles();
int subId = m_mrl.currentSubtitle();
@@ -615,6 +622,8 @@ void MpvPart::slotToggleRecording() {
}
void MpvPart::startRecording() {
+ if (!m_mpv) return;
+
// Ensure we have an out file and start recording
if (m_recordFilePath.isEmpty()) {
slotSetRecordingFile();
@@ -630,6 +639,7 @@ void MpvPart::startRecording() {
}
void MpvPart::stopRecording() {
+ if (!m_mpv) return;
mpv_set_property_string(m_mpv, "stream-record", "");
m_recordAction->setChecked(false);
}
@@ -768,6 +778,8 @@ void MpvPart::hideContextMenu() {
mpv_free_node_contents(&result);
void MpvPart::slotShot() {
+ if (!m_mpv) return;
+
mpv_node result;
int w, h, stride;
char *format;