Update RandomMusicPlayer sample for new RemoteControlClient APIs, also add media button support

Change-Id: Ia6ad08dd0ec1e67f1cffa2d6cfca2120ee0a96c7
This commit is contained in:
Roman Nurik
2011-09-30 18:02:10 -07:00
parent 8fbf284cc8
commit 5986e12034
61 changed files with 1075 additions and 523 deletions

View File

@@ -22,6 +22,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -71,7 +72,6 @@ public class MainActivity extends Activity implements OnClickListener {
mEjectButton.setOnClickListener(this);
}
@Override
public void onClick(View target) {
// Send the correct intent to the MusicService, according to the button that was clicked
if (target == mPlayButton)
@@ -119,4 +119,15 @@ public class MainActivity extends Activity implements OnClickListener {
alertBuilder.show();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_HEADSETHOOK:
startService(new Intent(MusicService.ACTION_TOGGLE_PLAYBACK));
return true;
}
return super.onKeyDown(keyCode, event);
}
}