'loops: Audio.Infinite' and 'loops: MediaPlayer.Infinite' stops playing if phone suspends or app goes to the background
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
media-hub (Ubuntu) |
In Progress
|
Undecided
|
Jim Hodapp | ||
media-hub (Ubuntu RTM) |
Triaged
|
Undecided
|
Jim Hodapp |
Bug Description
I'm using the following:
Audio {
id: playAudio
autoLoad: true
autoPlay: true
loops: Audio.Infinite
source: "./file.mp3"
}
and the file plays fine and will loop. However, if the phone suspends (either by pressing the power button or letting it suspend on its own), however the file won't loop until the phone is unsuspended and the application brought to the foreground. The same happens if the app goes to the background.
I also tried:
MediaPlayer {
id: playAudio
autoLoad: true
autoPlay: true
loops: MediaPlayer.
source: "./file.mp3"
}
but same problem. Watching the log output from ~/cache/upstart/... I can see that when the file finishes, a status change is sent, but when the phone suspends, it stops sending status changes.
I tried looking at onStatusChanged, like this:
MediaPlayer {
id: playAudio
autoLoad: true
autoPlay: true
loops: MediaPlayer.
source: "./file.mp3" onStatusChanged: {
if (status === MediaPlayer.
}
}
}
but it didn't seem to work. Also, setting 'loops' to a number, eg, 'loops: 10' doesn't work either (it stops once the phone suspends).
Looping is essential for the app I am writing (a white noise relaxation/sleep aid app).
I'm guessing this is happening because of application lifecycle. However, we always said that while apps can't have background services, we would write system services that would act on app's behalf. media-hub is that service for sound apps and it isn't working as well as it could with these types of apps. AIUI, music-app has a lifecycle exception, but I think we could be a lot smarter about things to improve the situation for app developers. Eg:
* allow looping by all apps for the foreground app if the device suspends if the device is connected to power
* if we had that, then we could allow looping by apps that are in the background
* music-app currently has a lifecycle exception, which is limiting. Unconditionally allowing looping while on power improves things a lot, but if we are really worried about background playing, put it in the user's control. Have a trust-store prompt if the device is on battery and wants to loop a long time, then cache the result. Eg "You are on battery power but the white noise app wants to loop indefinitely. Allow it to do so?".
summary: |
- 'loops: Audio.Infinite' only plays once if phone suspends + 'loops: Audio.Infinite' and 'loops: MediaPlayer.Infinite' only plays + once if phone suspends |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
summary: |
- 'loops: Audio.Infinite' and 'loops: MediaPlayer.Infinite' only plays - once if phone suspends + 'loops: Audio.Infinite' and 'loops: MediaPlayer.Infinite' stops playing + if phone suspends |
description: | updated |
summary: |
'loops: Audio.Infinite' and 'loops: MediaPlayer.Infinite' stops playing - if phone suspends + if phone suspends or app goes to the background |
description: | updated |
Changed in media-hub (Ubuntu): | |
status: | New → In Progress |
assignee: | nobody → Jim Hodapp (jhodapp) |
Changed in media-hub (Ubuntu RTM): | |
assignee: | nobody → Jim Hodapp (jhodapp) |
status: | New → Triaged |