Discussion Forums  >  Uncategorized

Replies: 16    Views: 376

StepWiseMedia
Android Fan
Profile
Posts: 7
Reg: Jan 08, 2012
Savannah
70
01/10/12 12:05 AM (14 years ago)

Quick And Dirty Fix for Audio Screen (Android 1.5)

Here is a quick and dirty fix for resolving a localized (packaged) audio stream or sound in 1.5 (Android) via the BT_screen_audio.java file using Eclipse. 1) In Eclipse, import your packaged project from BT...in the resources folder (res) create a new folder called raw...this is where we store the audio... 2) Find the res folder in the Workspace (you may need to refresh the project) and drag and drop your audio file or sound file (preferably in .mp3 format) in the folder. 3) Open up the BT_screen_audio.java file in the main package (aka com.appname...etc) 4) Comment out the toast pop-up (//showAlert(Open Eclipse, Look at the BT_screen_audio.java file);) 5) Delete ALL the text below that line...yes...ALL THE TEXT 6) Create a MediaPlayer class (make sure to import, if Eclipse howls at you) by adding theses lines below the ones you just commented out: MediaPlayer mp = MediaPlayer.create(BT_screen_audio.this, R.raw.YOUR_FILE_NAME_HERE_WITHOUT_THE_MP3_EXTENSION ); mp.start(); 7) Add a closing brace } 8) Add another closing brace } ....for good measure Here is an example...the following app is signed and requires Google APIs 2.2 or higher https://s3.amazonaws.com/ronbucket.s3.amazonaws.com/auntbea.apk
 
StepWiseMedia
Android Fan
Profile
Posts: 7
Reg: Jan 08, 2012
Savannah
70
like
01/10/12 12:06 AM (14 years ago)
Whoops...sorry 2) Find the RAW folder in the Workspace (you may need to refresh the project) and drag and drop your audio file or sound file (preferably in .mp3 format) in the folder.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
01/10/12 01:02 AM (14 years ago)
Great post, thanks for sharing!
 
Lyle @SFNeNT
buzztouch Evangelist
Profile
Posts: 168
Reg: Apr 29, 2011
Chicago, IL
2,830
like
01/10/12 05:35 PM (14 years ago)
Thanks Alot!!!!
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
01/10/12 07:53 PM (14 years ago)
Hey StepWise, would you mind if I made this a modification to download (under your name)? This is amazing! David. buzztouchmods.com
 
StepWiseMedia
Android Fan
Profile
Posts: 7
Reg: Jan 08, 2012
Savannah
70
like
01/10/12 09:29 PM (14 years ago)
@David...it's really just creating an instance of MediaPlayer and setting it to start after calling a file...so yes, you can and no...no credit necessary. To make it work efficiently it should be further modded with onRelease(); onPause(); etc...etc..you could also point it at an url instead of a packaged file so that you could change the audio without having to recompile if you wanted to swap audio files
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
01/10/12 09:46 PM (14 years ago)
No problemo. I will look into your suggestions and post back here when I have found good results. Thanks a ton! David. buzztouchmods.com
 
BuzzOne
buzztouch Evangelist
Profile
Posts: 6
Reg: Sep 20, 2011
DC
3,110
like
01/11/12 11:47 AM (14 years ago)
@StepWiseMedia, have you been able to call the audio from the BT_config.txt file (json)? I have been video screens working but still can't get files to be called from raw folder using the BT_config.txt thanks!
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
02/01/12 04:56 AM (14 years ago)
@Step,@David BT, @David Mods Would i be able to stream the audio from my server versus putting all 60 audio files into the app. How would i do this?
 
XactWeb
Android Fan
Profile
Posts: 85
Reg: Jan 09, 2012
Bangor
850
like
02/15/12 09:32 AM (13 years ago)
Could you explain in more detail the actual importing of the media player class? I did the changes and eclipse is throwing errors up on me.
 
basdeninc
Aspiring developer
Profile
Posts: 16
Reg: Sep 18, 2011
atlanta
160
like
02/24/12 12:47 AM (13 years ago)
StepWise thanks a bunch. I'm stuck on something that may be simple. How do I make it so that I can open different files with different audio tabs/links in the app interface? Basically the way I understand this, of course I may be wrong in my understanding, this is hardwiring the audio.java to one file, so any other audio.java call from other links in the app may open this same file everytime but I want the user to have the option to open different files depending on the tab/link that they press. Do I need to make an audio2.java for file choice #2? If so, how do I make the number 2 audio link call audio2.java instead of audio.java? Thanks
 
mycamerashots
Android Fan
Profile
Posts: 5
Reg: Dec 10, 2011
location unknow...
50
like
02/26/12 01:15 AM (13 years ago)
Thanks StepWise.. I have one little issue. How do I stop the audio upon exiting the screen..it just keeps playing.
 
basdeninc
Aspiring developer
Profile
Posts: 16
Reg: Sep 18, 2011
atlanta
160
like
02/26/12 03:16 AM (13 years ago)
Got my last question figured out, it's amazing what you can solve when you read the commented code from the BT guys! However it lead me to a new issue ... when I select the second choice, the first choice keeps playing (overlaps and echos). How do I stop/destroy the first audio when I select the second audio or basically in the audio.java tell it at the beginning if audio/mediaPlayer is playing then stop it before I create the new media player?
 
StepWiseMedia
Android Fan
Profile
Posts: 7
Reg: Jan 08, 2012
Savannah
70
like
02/26/12 07:50 AM (13 years ago)
For the previous two posts , the code will look something like, depending on how you called the media player intent. public void onStop() { mp.stop(); } If your app is heavily focused on audio, with other activities, consider spawning a new thread for the media player...you could use the same snippet for onLowMemory, onPause etc...consider also this snippet which stops and releases the media player. public void onDestroy() { mp.stop(); mp.release(); }
 
basdeninc
Aspiring developer
Profile
Posts: 16
Reg: Sep 18, 2011
atlanta
160
like
02/28/12 11:56 PM (13 years ago)
I called the media player and followed your original instructions to the letter. I have tried these commands without success, I think I'm putting it in the wrong place. Unlike mycamerashots i don't want the music to stop when I leave the screen, I want it to stop only if the user chooses a different audio file. Where exactly do I need to place which stop command in the audio.java file, so that it checks for and stops any audio already playing before it starts any new audio selected by the user?
 
basdeninc
Aspiring developer
Profile
Posts: 16
Reg: Sep 18, 2011
atlanta
160
like
03/07/12 07:36 AM (13 years ago)
I thought i had solved my problem by selecting stop audio when screen changes in the streaming audio control panel but when i submitted the app to the amazon android here is what they sent me. Your recent submission is pending due to the following reason(s): Your app has failed a test case. Bug Description:When exiting the application by pressing the 'HOME' button of the device while the application is generating audio, the audio generated by the application continues to play in the background of the device. Steps to Reproduce: 1. Launch the application. 2. Select 'Audio' observe that the application is generating audio. 3. Press the 'HOME' button of the device and observe that the audio generated by the application continues to play. OS/Device(s)/Form Factor: Samsung i777 (Galaxy S 2) A 2.3.4 Your app has failed a test case. Bug Description:When a voice interrupt occurs while the application is generating audio, the audio continues to play during the interrupt. Steps to Reproduce: 1. Launch the application. 2. Select 'Audio' and observe that the application is generating audio. 3. Send a voice interrupt to the test device and accept the interrupt 4. Observe that the application continues to generate audio during the voice interrupt OS/Device(s)/Form Factor: Samsung i777 (Galaxy S 2) A 2.3.4 Please correct the issue(s) we found with your app submission. So now I think I have to make the audio stop when the app closes and when a phone call or some other sound is coming through ..... Any suggestions.
 
Annonymous
Profile
03/07/12 08:36 PM (13 years ago)
I thought i had solved my problem by selecting stop audio when screen changes in the streaming audio control panel but when i submitted the app to the amazon android here is what they sent me. Your recent submission is pending due to the following reason(s): Your app has failed a test case. Bug Description:When exiting the application by pressing the 'HOME' button of the device while the application is generating audio, the audio generated by the application continues to play in the background of the device. Steps to Reproduce: 1. Launch the application. 2. Select 'Audio' observe that the application is generating audio. 3. Press the 'HOME' button of the device and observe that the audio generated by the application continues to play. OS/Device(s)/Form Factor: Samsung i777 (Galaxy S 2) A 2.3.4 Your app has failed a test case. Bug Description:When a voice interrupt occurs while the application is generating audio, the audio continues to play during the interrupt. Steps to Reproduce: 1. Launch the application. 2. Select 'Audio' and observe that the application is generating audio. 3. Send a voice interrupt to the test device and accept the interrupt 4. Observe that the application continues to generate audio during the voice interrupt OS/Device(s)/Form Factor: Samsung i777 (Galaxy S 2) A 2.3.4 Please correct the issue(s) we found with your app submission. So now I think I have to make the audio stop when the app closes and when a phone call or some other sound is coming through ..... Any suggestions.
 

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.