Reputation: 530
I want to know, how to run a song in a service, I also want to use .aidl file to expose clients the interface.
Upvotes: 0
Views: 12341
Reputation: 109257
Sound basic for Android..
I recommended you for go through this tutorial MusicDroid - Audio Player Part.
There are three parts of these tutorial. Its nicely describe for how to implement Audio player for android using service and AIDL.
Also look at this android developer tutorial Media Playback.
I think this will help you a lot..!
Upvotes: 2
Reputation: 2963
I assume you know how to create a service, I did something before similar
import android.media.MediaPlayer;
private MediaPlayer mMediaPlayer;
private void play() {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(getSongUrl());
mMediaPlayer.prepare();
mMediaPlayer.start();
}
when interact with UI, send Intent from the UI to the service so that you can do let pause:
mMediaPlayer.pause();
or seek to certain time:
mMediaPlayer.seekTo((int) (to * mMediaPlayer.getDuration()));
and remember make sure call the release()
Please check the class here: http://developer.android.com/reference/android/media/MediaPlayer.html
Upvotes: 1