Discussion Forums  >  Uncategorized

Replies: 2    Views: 206

Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
08/17/11 09:25 PM (14 years ago)

Android Audio embedding (NOT streaming) How to?

Me again - Searched the forums but cant find an answer. Is there a way in BT 1.4 to embed mp3 files directly into Eclipse (as opposed to streaming them via http)? Thanks gang :)
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/17/11 09:50 PM (14 years ago)
I found how to embed the audio by putting the mp3 in the res/raw folder of my project. But Im stuck on the rest. Where do I place this code - See below: MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1); mp.start(); And the tutorial also says remember that the MediaPlayer class consumes memory and needs to be reset and prepared before you can play the audio again To reset and prepare the MediaPlayer just call: mp.reset(); mp.prepare(); Where do I place that code? Thanks Tez
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/18/11 12:49 PM (14 years ago)
It's going to depend on when you want the audio to begin. Views in Android are called Activities and each activiy has a Lifecyle. Several methods are fired automaticaly by Android during this lifecycle. onCreate, onStart, onFinish, etc. This means you'll want to put your media player code in the Activity you're working with and fire it at a time that's appropriate.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.