Playing MP3 file from SD card in background of Android app - android

I have got some code which displays a listview of audio files in SD card and plays them. But when I move to other screens, it automatically stops. I want it to be able to play the files while using the other functions of the app.

use AsyncTask ( or any sub-class in that constructor chain ) and as well consider Service but best case is to do AsyncTask and remember you have to start the thread yourself- just like is says in the docs for that

If you want your media to play in the background even when your application is not onscreen—that is, you want it to continue playing while the user is interacting with other applications—then you must start a Service and control the MediaPlayer instance from there.
Please refer this link its nice example for Android Music Player.

Related

How to get currently plaing audio file info in background (The audio may be playing by any app) in android

I'm going to make one app, in this the partial requirement is like this: get the currently playing audio name using service. I tried but I'm unable to find the exact way, here is my finding. How to get all the audio file using mediastore
There is no way to know what file another app may be playing.

How to make a self phone call which plays mp3 when answered?

I'm trying to make an an android app whereby if the user answers the phone call the mp3 file will start and the voice of the call will be the mp3 file.
Meaning when the app is triggered, it'll make a phone call to itself and when you answer it, the mp3 file will act as the voice behind the phone call.
I know how to make a simple phone call app, but I can't get it to call itself nor making the mp3 file play as the voice from the other side of the phone. Any guides on how to perform this?
A similar question about having a phone call itself was answered here, and says that this is not possible (which makes sense). As recommended there as well, your best bet is to probably use MediaPlayer to play the MP3 file to the user, and make the application look like a phone app if it really needs to be like a call.

Caching and Playing video

The requirement is to list a Videos thumbnails and on clicking it should play related video into Application. i am able to play url where video is located using Video View. But now i want to implement this thing in a better ways like Watsapp and instagram. If anybody have a good experience in this reference please share with me. I want to play around caching video and playing videos from cache without buffering (Video view is showing buffering bar and very slow in performance user have to wait a lot for starting a Video). Any kind of help will be appreciated. thanks.
I did it own my own. It's very simple to implement What i do is to download the video with async task along with a progressing seek bar. Once it's downloaded i'll save it in a Folder in my sdcard. We should create a Folder named as Application name so easy to identify and also always available videos with out opening application as well and next time however when i want to watch video again in my application it just check weather it is available in sdcard if yes then play immediately if not then download it. I am happy.

Intent to call playlist editing of Android's default Music app

I'm writing a music app, and want to ask if there's a standard to edit playlist.
Though each manufacture customizes its own default Music app, is there an intent to call up most of them?
If so I guess it will have action EDIT, but I don't know how to write the Data and Type.
Thanks!
The short answer is
No
The long answer is, It might be possible if you create and edit you own playlists in the app and it saves it to the directory for the music application (say /sdcard/music/playlist) then forcing the mediascanner to rescan, which should repopulate the media database.
On editing a playlist, everyone accepts M3U which is literally a text file.
But again the problem is that not all music players will check that directory at runtime (but most music apps use the media directory created by media scanner so this shouldn't be a issue)

How to list all media in Android?

I'm building a specialized media player for android and need a way to select a song from the device. I like how the builtin music player groups everything by artist/album, is that something I would have to write or is there something I can just plug in to get that functionality for free?
What is the easiest way to list music files on the phone with some basic grouping by the idtag info?
Use the MediaStore content provider.
You'll probably just have to write a method that scans the entire phone (or at least the music directory), for all of the media files that the phone can handle, and then store that data in a database yourself (using a content provider).
Either way though, you can find the source for the android Music app here:
https://android.googlesource.com/platform/packages/apps/Music

Categories

Resources