** Description changed:

  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.
+ 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.Infinite
          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.Infinite
  
          source: "./file.mp3"        onStatusChanged: {
              console.log("status changed: " + status)
              if (status === MediaPlayer.EndOfMedia) {
                  seek(0)
                  play()
              }
          }
      }
  
  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?".

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1389477

Title:
  'loops: Audio.Infinite' and 'loops: MediaPlayer.Infinite' stops
  playing if phone suspends or app goes to the background

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/media-hub/+bug/1389477/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to