Media Session Compat not showing Lockscreen controls on Pre-Lollipop

前端 未结 3 1414
一个人的身影
一个人的身影 2021-01-30 07:14

I\'m using MediaSessionCompat from AppCompat Support Library Revision 22. And on Lollipop I\'m getting notification & also the background of lockscreen is the a

3条回答
  •  长发绾君心
    2021-01-30 07:49

    Finally I figured a solution for this. Thanks to @ianhanniballake & @user1549672

    1. Add Audio Focus as suggested by @ianhanniballake
    2. Add Music Intent BroadcastReceiver can be found if searched on Google & also on Official Android Docs
    3. Write the setupMediaSession() given in my question above
    4. VERY IMPORTANT Mention the Flags properly
    5. Write MediaSessionCallbacks also available above
    6. VERY IMPORTANT Update the MediaSession on MediaPlayer#onPause(), MediaPlayer#onStart() & finally when new song is played (also includes next & previous played) mentioned by @user1549672
    7. Release the MediaSession object in onDestory()

    Well that's all, most of the material (code) is available above. This question took couple of months to solve, finally it's done.

提交回复
热议问题