DingleNutZ
DingleNutZ

Reputation: 163

creating a service for playing audio in the background

I have searched, but can not find the answer I'm looking for. I want to create a service and be able to call a function to play an audio file. I have 5 different intents that will be using the service to play 5 different audio files (one each) and I have a stop button in each one. Whichever stop button is pressed I want it to stop all audio that has been called from the service.

Does any one have an example code which I can use? (Something close to what I'm looking for.)

Upvotes: 2

Views: 445

Answers (1)

Augusto
Augusto

Reputation: 29827

I'm building a media player to understand how Android works, and I have a service that queues audio files to play them. You can get the full source code from github.

The service is in /src/com/augusto/mymediaplayer/services

I'm not using Intens, but binding the service to the Activities that use it, but changing it to receive intents shouldn't be that hard. Just in case, this service runs ok on Android 1.6+.

I think that to change it to receive intents, you'll need to change onStart() and do a switch on the intent.

I know that this doesn't answer your question 100% but it's a place to start :).

Upvotes: 1

Related Questions