如何添加永久媒体控件(如Apollo或Google音乐) [英] How can I add persistent media controls like Apollo or Google music

查看:59
本文介绍了如何添加永久媒体控件(如Apollo或Google音乐)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加音乐控件(例如播放/暂停,下一个和后退),并在应用程序的底部(如Google音乐应用程序中)显示缩略图和歌曲标题.
点击缩略图或标题时,我想调出歌曲的详细视图,包括搜索栏.
我想知道什么是最好的方法.我应该只在我的应用程序xml的底部添加相对布局,然后添加点击侦听器,还是可以使用MediaController类之类的方法简单地完成此操作?

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?

推荐答案

您应该使用片段来构建您的应用程序. Google已弃用了许多以前的API功能,而使用了片段,并正试图促使开发人员在新的应用程序中更多地使用它们.

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.

假设您正在创建媒体播放器,则应用程序主屏幕的歌曲列表部分将是一个片段中的ListView,底部控制器部分将是另一个片段,其中包含您想要的任何按钮和滑块.

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.

如何创建显示有关歌曲信息的详细屏幕的方式取决于您希望该屏幕的外观,但是最直接的方法是将专辑缩略图显示为控制器"片段中的ImageButton,然后创建一个新的Activity onClick.

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.

您可以在此处找到有关片段的信息 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆