Commit 02ca3cb1 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsAudio): unload ring player when window is not visible

parent 933b441a
......@@ -68,6 +68,11 @@ SoundPlayer::SoundPlayer (QObject *parent) : QObject(parent) {
mInternalPlayer->setListener(mHandlers);
}
SoundPlayer::~SoundPlayer () {
mForceCloseTimer->stop();
mInternalPlayer->close();
}
// -----------------------------------------------------------------------------
void SoundPlayer::pause () {
......
......@@ -56,7 +56,7 @@ public:
Q_ENUM(PlaybackState);
SoundPlayer (QObject *parent = Q_NULLPTR);
~SoundPlayer () = default;
~SoundPlayer ();
Q_INVOKABLE void pause ();
Q_INVOKABLE void play ();
......
......@@ -74,7 +74,11 @@ TabContainer {
selectedFile: SettingsModel.ringPath
onAccepted: {
ringPlayer.stop()
var item = ringPlayer.item
if (item) {
item.stop()
}
SettingsModel.ringPath = selectedFile
}
......@@ -84,27 +88,33 @@ TabContainer {
leftMargin: SettingsAudioStyle.ringPlayer.leftMargin
}
enabled: ringPlayer.playbackState === SoundPlayer.PlayingState
enabled: {
var item = ringPlayer.item
return item && item.playbackState === SoundPlayer.PlayingState
}
icon: 'pause'
onClicked: {
var item = ringPlayer.item
if (!item) {
return
}
if (enabled) {
ringPlayer.stop()
item.stop()
} else {
ringPlayer.play()
item.play()
}
}
SoundPlayer {
Loader {
id: ringPlayer
source: SettingsModel.ringPath
}
Connections {
target: window
onClosing: ringPlayer.stop()
active: window.visible
sourceComponent: SoundPlayer {
source: SettingsModel.ringPath
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment