开发者

Send music control keys from my app in android

Is there a simple way to tell the default media player to change track back or forward?

I want the ability to send commands to the system media player 开发者_如何学Python(Music) to change track back and forward from within my app.

Is there a simple way? Code examples or descriptive explanation please, I have not developed for Android before.

Update: Is it just the HTC Music that isn't part of the SDK or even the stock one? Either player would be fine if I could manage way to change tracks.

The HTC Lock screen has some method of changing tracks in the music player. Is it possible I could get hold of this and use it?

Baksmali?


I want the ability to send commands to the system media player (Music) to change track back and forward from within my app.

The Music application is not part of the Android SDK, so there are no documented and supported Intents for moving from track to track.

Sorry!


by ACTION_MEDIA_BUTTON using intent ?? http://developer.android.com/reference/android/content/Intent.html#ACTION_MEDIA_BUTTON

    Intent media_intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    media_intent.setPackage(DEFAULTPLAYER);
    synchronized (this) {
        media_intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, keycode));
        mContext.sendOrderedBroadcast(media_intent, null);

        media_intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, keycode));
        mContext.sendOrderedBroadcast(media_intent, null);
    }

however DEFAULTPLAYER needs to be assigned...

:S :S :S

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜