mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-28 03:36:20 +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);
|
mInternalPlayer->setListener(mHandlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundPlayer::~SoundPlayer () {
|
||||||
|
mForceCloseTimer->stop();
|
||||||
|
mInternalPlayer->close();
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void SoundPlayer::pause () {
|
void SoundPlayer::pause () {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
Q_ENUM(PlaybackState);
|
Q_ENUM(PlaybackState);
|
||||||
|
|
||||||
SoundPlayer (QObject *parent = Q_NULLPTR);
|
SoundPlayer (QObject *parent = Q_NULLPTR);
|
||||||
~SoundPlayer () = default;
|
~SoundPlayer ();
|
||||||
|
|
||||||
Q_INVOKABLE void pause ();
|
Q_INVOKABLE void pause ();
|
||||||
Q_INVOKABLE void play ();
|
Q_INVOKABLE void play ();
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,11 @@ TabContainer {
|
||||||
selectedFile: SettingsModel.ringPath
|
selectedFile: SettingsModel.ringPath
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
ringPlayer.stop()
|
var item = ringPlayer.item
|
||||||
|
if (item) {
|
||||||
|
item.stop()
|
||||||
|
}
|
||||||
|
|
||||||
SettingsModel.ringPath = selectedFile
|
SettingsModel.ringPath = selectedFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,27 +88,33 @@ TabContainer {
|
||||||
leftMargin: SettingsAudioStyle.ringPlayer.leftMargin
|
leftMargin: SettingsAudioStyle.ringPlayer.leftMargin
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled: ringPlayer.playbackState === SoundPlayer.PlayingState
|
enabled: {
|
||||||
|
var item = ringPlayer.item
|
||||||
|
return item && item.playbackState === SoundPlayer.PlayingState
|
||||||
|
}
|
||||||
|
|
||||||
icon: 'pause'
|
icon: 'pause'
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
var item = ringPlayer.item
|
||||||
|
if (!item) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
ringPlayer.stop()
|
item.stop()
|
||||||
} else {
|
} else {
|
||||||
ringPlayer.play()
|
item.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundPlayer {
|
Loader {
|
||||||
id: ringPlayer
|
id: ringPlayer
|
||||||
|
|
||||||
|
active: window.visible
|
||||||
|
sourceComponent: SoundPlayer {
|
||||||
source: SettingsModel.ringPath
|
source: SettingsModel.ringPath
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: window
|
|
||||||
|
|
||||||
onClosing: ringPlayer.stop()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue