mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-22 06:08:07 +00:00
feat(ui/views/App/Settings/SettingsAudio): unload ring player when window is not visible
This commit is contained in:
parent
933b441a43
commit
02ca3cb191
3 changed files with 28 additions and 13 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue