Skip to content

How the service works in MPDroid

Avuton Olrich edited this page Nov 30, 2015 · 4 revisions

This list pertains to the git reflected the day of editing this page.

Table of Contents

How the notification works

  • With persistent notification off:
    • Notification checkbox disabled
      • Notification should never appear or be enabled unless by user intervention.
    • User enables notification checkbox in the main menu.
      • If server state is playing or paused, notification should appear with current notification information.
      • If/when not playing notification will stay visible for 5 minutes to await user input.
        • After this time, notification will disable itself, main menu checkbox will go back to unchecked.
        • Exception to parent: Notification will close and disable itself immediately if the playlist queue is empty or if disconnected (see below), as non-notification user intervention will be required at that time.
  • With persistent notification on:
    • Notification checkbox invisible and does not appear in the main menu.
      • If server state is playing or paused, notification should appear with current notification information.
      • If not playing notification should be hidden.
        • If/when the server state changes to not playing, the notification will stay visible for 5 minutes to await user input. This time can vary if the device is in a sleep mode (to save battery power), if woken it will hide soon after the display has been turned on.
          • After this time the notification will hide.
        • Exception to parent: Notification will hide itself immediately if the playlist queue is empty or if disconnected (see below), as non-notification user intervention will be required at that time.
  • If notification close box on the notification is tapped:
    • Notification will immediately disable itself. Notification checkbox will appear on main menu, disabled.
    • The lock screen widget will be disabled.
    • The streaming service will immediately disable itself.
    • If persistent notification is enabled:
      • Persistent notification mode is disabled and overridden until:
        • MPDroid is killed (typically after reboot or application manager gives up the memory of the app) and restarted.
        • User manually reenables the notification through the notification checkbox, at which point the notification will return to persistent enabled and override disabled.

How streaming works

  • Streaming checkbox disabled:
    • Streaming should never occur.
  • Enable streaming mode by user intervention at checkbox:
    • Notification checkbox will not be visible on main menu if playing or preparing for play.
    • If not playing, streaming will not occur.
      • If close box is hit on notification box, the streaming service will be disabled
      • Streaming server will be active for 5 minutes, after that the server will disable itself and the checkbox will return to unchecked. This time can vary if the device is in a sleep mode (to save battery power).
    • If playing:
      • Notification mode is on and persistent, depending on server and streaming state.
      • Notification close checkbox will not appear.
      • Streaming will be stopped when server state is not playing.
      • Streaming will be disabled if headphones are pulled from the plug or if the server status state is stopped.
      • After streaming mode is disabled, notification will return to pre-streaming state.
        • Exception to parent: Notification will hide itself immediately if the playlist queue is empty or if disconnected (see below), as non-notification user intervention will be required at that time. It will re-enable after stream start.
    • Disable streaming mode by user intervention at checkbox:
      • Notification will return to pre-streaming state.
      • Streaming will immediately cease.

How the lock screen widget and background work

  • Begin streaming or notification mode
    • Lock screen widget and background will be enabled any time MPDroid has audio focus, including when we are ducking audio focus.
    • During streaming we should ALWAYS have audio focus, unless user switching has occurred.
    • During notification we request audio focus, but it would not be respectful of other audio programs if we required it; we ask for audio focus passively and will not be aggressive about it.

Notes about killing MPDroid

  • If the notification or streaming are active and MPDroid (the main process) is killed, the service will respawn and continue doing what it was doing.

Notes about user switching

  • Due to limitations in Android's non-root SDK the service cannot control what happens when a user switches, this is probably why SDK 20 supports a native music notification which we will probably use as soon as it's implemented.
  • Bad things that could occur:
    • Streaming mode might kill itself or otherwise lose audio focus.
    • Lock screen widget may appear, disappear or appear in other users. We have little to no control over this.

Troubleshooting Streaming

First, a little background, all streaming is done through the MediaPlayer Android interface.

  • First place to start would be to check that a prior version worked, best to check against MPDroid 1.06, versions afterward use a completely different implementation. If that works, but a recent version does not, continue. Do not skip this step, this mitigates most problems with various ROMs with buggy MediaPlayer implementations.
  • Double check your host settings.
  • Unfortunately, with all versions of 1.07, a bug exists requiring swipe to kill to reconnect. If you have swiped to kill, and it's still not functioning, continue.
  • Start streaming and wait for a toast message to popup. It should occur within 60 seconds. That should give you a broad idea of the scope of the problem, and maybe how you can fix it yourself.
Otherwise, the device is most likely throwing an error of some sort of error to the Android logs. There are many guides Google to help, such as this.