In my activity i have:
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
service.playSong(MEDIA_PATH);
}
});
and this is in Service:
void playSong(String file) {
try {
mp.reset();
System.out.println(file+songs.get(currentPosition));
mp.setDataSource(file+ songs.get(currentPosition));
mp.prepare();
mp.start();
mp.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer arg0) {
nextSong();
}
});
} catch (IOException e) {
Log.e(getString(R.string.app_name), e.getMessage());
}
}
As you see from the code above in my activity when i click the button play I am passing the path into the service in order to play music but it is crashing What is wrong?