romannurik/muzei — pull request #26 by ianhanniballake (2014-02-17 00:41:46+00:00)
Title: Show playing music artwork on Android 4.4+ devices

Use the RemoteController API introduced in Android 4.4 to show music artwork as your background when music is playing, resuming the selected source when music is paused/stopped.

This is off by default and must be enabled in the Advanced settings (this also provides users the chance to enable the system level permission that is required before we can receive music artwork).

MusicListenerService serves as the main entry point for music callbacks (specifically, play state and music artwork) and serves events for each. This class is started and controlled fully by the system, but its lifecycle can be assumed to always be started once permission is enabled for the user.

The music events are handled by the MusicAwareRealRenderController. This leaves the Demo and Real render controllers to ensure that they do not show music controls (as would be if we added this earlier in the hierarchy) and also helps better encapsulate the logic. Although due to the transparent nature of the detail mode, the MusicAwareRealRenderController also hides the music artwork in detail mode to ensure the user can view the current source artwork even if music is playing.