Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android embed default audio player in app/activity

I would like to know if it is possible to embed the default audio player into one of my activities. Or at least be able to embed the section that has the play/pause button and the audio track seek bar.

The reason I would like to embed it rather than open it in a new intent (like this:

Intent audioActivity = new Intent(Intent.ACTION_VIEW);
audioActivity.setDataAndType(Uri.parse(getAudioURL()), "audio/*");
startActivity(audioActivity);

)

is that I want the users to be able to read some content within the current activity while listening to the audio. I have been able to use a progress bar which updates based on the progress in the audio track, but this does not look good and i would rather have the look and feel of the default audio player. I know the default video/audio players are not documented very well but if this is at all possible I would like to know. Thanks!

like image 464
aveyD Avatar asked Jul 17 '26 14:07

aveyD


2 Answers

Hi, I would like to know if it is possible to embed the default audio player into one of my activities.

No, sorry.

First, there is no such thing as "the default audio player" as a single entity. Each device has its own "default audio player".

Second, even if there were a single universal "default audio player", there is no way in Android to embed some other application's UI into your own.

Or at least be able to embed the section that has the play/pause button and the audio track seek bar.

No, sorry. See above.

like image 114
CommonsWare Avatar answered Jul 19 '26 04:07

CommonsWare


I think what you're looking for is MediaController. This answer has a good example of how to use this, though I'm not sure if it is possible to have the controls displaying all the time (they disappear after 3 seconds in the example):

How can I show a MediaController while playing audio in Android?

There's another discussion of it here:

How to implement an audio player for Android using MediaPlayer And MediaController?

like image 24
Dillon Kearns Avatar answered Jul 19 '26 02:07

Dillon Kearns



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!