How can I show a MediaController
while playing audio file? I am creating an instance of MediaController
and calling its show()
method,
I copied the code above from user229487 verbatim but couldn't get it to work. Given I'm new to Android dev, I found out the hard way that you need to put an intent as well as a few other things. I also don't exactly understand how the intent will work with a user interface (again I'm new), but will work on it.
Few things for other noobs like me to get the code above to work (I at least got it to not crash now and play a song :) ):
Won't compile without this:
@Override
public int getAudioSessionId() {
return 0;
}
To set audio manually: (change line to:)
public static final String AUDIO_FILE_NAME = Environment.getExternalStorageDirectory()+"/MusicFolder/Song.mp3";
Setup intent
Add this line:
this.getIntent().putExtra(AUDIO_FILE_NAME,AUDIO_FILE_NAME);
Before this line:
audioFile = this.getIntent().getStringExtra(AUDIO_FILE_NAME);
Should compile and play song now.