[原]Android 音乐播放器源码分析1
manifest看到入口为MusicBrowserActivity.java
public class MusicBrowserActivity extends Activity
implements MusicUtils.Defs
实现了接口MusicUtils.Defs ,实际上它只不过是一系列的常量
public class MusicUtils { private static final String TAG = "MusicUtils"; public interface Defs { public final static int OPEN_URL = 0; public final static int ADD_TO_PLAYLIST = 1; public final static int USE_AS_RINGTONE = 2; public final static int PLAYLIST_SELECTED = 3;。。。
String shuf = getIntent().getStringExtra("autoshuffle"); if ("true".equals(shuf)) { mToken = MusicUtils.bindToService(this, autoshuffle); }
if (icicle != null) { mCurrentAlbumId = icicle.getString("selectedalbum"); mCurrentAlbumName = icicle.getString("selectedalbumname"); mCurrentArtistId = icicle.getString("selectedartist"); mCurrentArtistName = icicle.getString("selectedartistname"); }
IntentFilter f = new IntentFilter(); f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED); f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); f.addAction(Intent.ACTION_MEDIA_UNMOUNTED); f.addDataScheme("file"); registerReceiver(mScanListener, f);
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_vertical" ><!-- 当没有音乐的时候显示--> <include layout="@layout/sd_error" /><!-- 这里用一系列textView定义了artisttab albumtab songtab playlisttab 及 下方的nowplayingtab上内容的显示及点击状态等--> <include layout="@layout/buttonbar" /> <ExpandableListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:textSize="18sp" android:drawSelectorOnTop="false" android:fastScrollEnabled="true" android:indicatorLeft="8dip" android:indicatorRight="52dip" /><!-- 下方当前播放音乐的布局--> <include layout="@layout/nowplaying" /></LinearLayout>