Introduce MediaManager

Currently, this is only to pause playback of other media when something new starts playing.
In the future, it will also be used for other things, like call ringing, etc.
This commit is contained in:
Tobias Fella
2024-02-18 21:34:15 +01:00
parent b27bec3e16
commit d99fae333a
5 changed files with 78 additions and 1 deletions

View File

@@ -105,6 +105,7 @@ ColumnLayout {
icon.name: "media-playback-start"
onClicked: {
audio.source = root.fileTransferInfo.localPath;
MediaManager.startPlayback();
audio.play();
}
}
@@ -123,6 +124,15 @@ ColumnLayout {
}
]
Connections {
target: MediaManager
function onPlaybackStarted() {
if (audio.playbackState === MediaPlayer.PlayingState) {
audio.pause();
}
}
}
RowLayout {
QQC2.ToolButton {
id: playButton

View File

@@ -118,7 +118,10 @@ Video {
PropertyChanges {
target: playButton
icon.name: "media-playback-start"
onClicked: root.play()
onClicked: {
MediaManager.startPlayback();
root.play();
}
}
},
State {
@@ -136,6 +139,15 @@ Video {
}
]
Connections {
target: MediaManager
function onPlaybackStarted() {
if (root.playbackState === MediaPlayer.PlayingState) {
root.pause();
}
}
}
Image {
id: mediaThumbnail
anchors.fill: parent
@@ -350,6 +362,7 @@ Video {
if (root.playbackState == MediaPlayer.PlayingState) {
root.pause();
} else {
MediaManager.startPlayback();
root.play();
}
} else {
@@ -375,6 +388,7 @@ Video {
function playSavedFile() {
root.stop();
MediaManager.startPlayback();
root.play();
}
}