How can I add persistent media controls like Apollo or Google music

孤街醉人 提交于 2019-12-12 21:46:46

问题


I would like to add music controls such as play/pause, next, and back as well as show a thumbnail and song title to the bottom of an application like in the Google music app.

When the thumbnail or title is tapped on, I want to bring up a detailed view of song, including a seek bar.

I am wondering what the best approach for this would be. Should I just add a relative layout the the bottom of my apps xml, and add on click listeners, or can this be accomplished simply with something like the MediaController class?

回答1:


You should use fragments to build your app. Google has deprecated a number of previous API features in favor of fragments, and is trying to move developers towards using them more in new applications.

Assuming you're creating a media player, the song list portion of your app's main screen will be a ListView within a fragment, and the bottom controller portion will be another fragment containing whatever buttons and sliders you'd like to have.

How you create a detailed screen showing information about the song depends on what you want that screen to look like, but the most straightforward way to do so would be to display the album thumbnail as an ImageButton within your "controller" fragment and create a new Activity onClick.

You can find information about fragments here and a tutorial on building an audio player for Android here.



来源:https://stackoverflow.com/questions/18154401/how-can-i-add-persistent-media-controls-like-apollo-or-google-music

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!