我有一个要在运行时播放的配乐作为主要主题:
App{
...............
Audio{
source: "../assets/Art Of Silence_V2.mp3"
autoPlay: true
loops : Audio.Infinite
}
.......
}
当应用程序在后台运行时,如何停止播放它?
答案 0 :(得分:0)
假设您的应用程序包含在Window
或ApplicationWindow
组件中
Window{
...............
Audio{
readonly property bool forground : Window.visibility !== Window.Minimized &&
Window.visibility !== Window.Hidden
source: "../assets/Art Of Silence_V2.mp3"
autoPlay: true
loops : Audio.Infinite
onForgroundChanged: { forground ? start() : stop() }
}
.......
}