Discussion Forums  >  Uncategorized

Replies: 19    Views: 418

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

How to embedded audio into iOS app (NOT streaming)

Greetings fellow BT'ers I read a post by David, about how you can create a floder and drag it to your BT folder if you wanted to embed your own pics instead of relying on a stream like Flickr etc.. Is there ANYWAY we can do the same for audio? I.E. including a file such as .aiff to be looped in the app? I know this would bloat the filesize of the app, but does anyone know if this could possibly be done? Thanks! (Holds breath in reply!)
 
Parker @ buzztouch
buzztouch Evangelist
Profile
Posts: 1395
Reg: May 09, 2011
Pacific Grove, ...
24,500
like
08/08/11 11:18 PM (14 years ago)
As long as the file types are supported and properly formatted (bit rate, etc) I believe it shouldn't be a problem.
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/08/11 11:25 PM (14 years ago)
Any idea how I go about it Parker?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/09/11 01:32 AM (14 years ago)
Hi again.. Same was as the image files. File in Xcode (audio, images, video, html, pdf, etc) are all treated the same way. Once you add them to the project you can use them by entering the file names in the control panel. Technically speaking, it doesn't really matter where you add them in the project. You could get aways with adding images to the BT_Docs folder and audio to the BT_Images folder - Xcode doesn't care. We like to try to help folks stay organized but it's not important where the files are located as long as you add them to the Xcode project using the Add Files method. a) Make a folder of audio files on your computer. Drag this folder somewhere permanent on your machine. Like in the source-code folder you downloaded. May as well put this folder in the BT_Audio folder you downloaded. b) In Xcode you'll see this folder in RED. It's red becuase it's not been added to the Xcode project yet, it's simply in the directory on our computer. c) Add Existing Files in Xcode. Select the folder, it's added. This is exactly the same as dragging it into Xcode and adding it that way. Now that all the files are in the project you can use simple file names in the control panel instead of URL's
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/09/11 02:42 AM (14 years ago)
Outstanding David :) Next time you are in Australia... I'll shout ya! (That's Aussie for.. Your drinks are on me )
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/09/11 04:53 AM (14 years ago)
Pushing the friendship now..... Can the same be done with VIDEO files? as in .mp4 etc...
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/09/11 09:26 AM (14 years ago)
Yup. any files can be added as resources by dragging them into xcode or 'adding existing files'
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/09/11 06:13 PM (14 years ago)
Excellent! (in Arnie terminator voiceover)
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/09/11 09:44 PM (14 years ago)
Um Im stuck I created a new folder with some .aif files Then dragged them to the BT_Sound folder. What do I need to do to see them in XCode? Do I need to refresh anything?
 
Parker @ buzztouch
buzztouch Evangelist
Profile
Posts: 1395
Reg: May 09, 2011
Pacific Grove, ...
24,500
like
08/09/11 10:14 PM (14 years ago)
Drag it into the BT_Sound folder in the xcode project itself. In the dialog box that pops up make sure the Destination and Add to Targets boxes are selected. Hit Finish. You'll need to recompile (Run) your app in order to actually use them in the sim/device.
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/09/11 11:36 PM (14 years ago)
Thanks Parker Works great. Really appreciate the help! Cheers Terence
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/09/11 11:53 PM (14 years ago)
Last request... Now that I have my own audio tracks, is there a simple' way to tell the track to loop? Ive seen some answers on the forum but they are a bit daunting!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/10/11 02:15 AM (14 years ago)
Daunting - nahh, at this rate you'll be the pro in no time. Looping, sure. If you add them as background audio, like on a Custom URL or HTML screen you can set 0 for no loops, 1 for one loop, or -1 for continuous looping. The Streaming Audio screen doesn't seem to have this setting (not sure why) but you could set this on line 504 of BT_screen_audio.m (the streaming audio screen class) 504: [self.audioPlayer setNumberOfLoops:[self audioNumberOfLoops]]; turns into 504: [self.audioPlayer setNumberOfLoops:-1]; I'll see why the audio loop setting is missing from the control panel. There may be a reason I'm not aware of.
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/10/11 06:35 AM (14 years ago)
You DA man David - Thanks - Works perfectly ;-)
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/10/11 09:43 PM (14 years ago)
Last question (promise!) The app is coming along very nicely. Just wanted to ask if I could do the following: I have two audio tracks linked to 2 tabs. Can I tell one mp3 to loop (as I have per David's post above) but with the second audio NOT to loop? At the moment, all the audio files as looping regardless. Many thanks Tez
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/12/11 01:14 AM (14 years ago)
Last answer, promise. SOOO kidding. No worries at all. You can do this, but, you'll need to make some adjustments in the code. The problem is that you've told the audio player to loop (as you realize) but know you want it to loop for only some tracks. I would probably just write some simple if( my mp3 is this song don't loop) logic. Cryptic advise for sure but I think you get the idea. Write a little conditional check to see what file is being started, set the loop / no loop accordingly.
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/12/11 04:45 AM (14 years ago)
Thanks David. You hit the nail on the head. Now who do I pay to write the simple logic ?? (newbie)
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/12/11 10:35 PM (14 years ago)
Pick a charity. a) load the screen in your control panel that you DO NOT want to loop. Look at the address bar to get the BT_itemId, it's everything AFTER the BT_itemId= and before the next question mark in the address bar. This sample URL: http://www.buzztouch.com/account/cp_v15/screen_menuButtons.php?BT_itemId=8DA487CDB3BAEF07FD16B45&status=&searchInput=Nickname... has a BT_itemId of 8DA487CDB3BAEF07FD16B45 b) now, we can tell iOS to do something different if that screen is loading.. back in BT_screen_audio.m file, NSString *tmpScreenId = [self.screenData itemId]; if([tmpScreenId isEqualToString:@[your BT_itemId]){ [self.audioPlayer setNumberOfLoops:2]; }else{ [self.audioPlayer setNumberOfLoops:-1]; } Replace the [your BT_itemId] with the value of the screen you're working with, surround it with quotes, remove the brackets.
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/14/11 04:06 PM (14 years ago)
Ok, understanding most of this... I got my BT_itemid however where (or what line) do I cut and paste your code above into the BT_screen_audio.m file? And not sure how to surround it with quotes, remove the brackets Thanks guys :)
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/15/11 11:09 PM (14 years ago)
NSString *tmpScreenId = [self.screenData itemId]; if([tmpScreenId isEqualToString:@''XXXXXXX'']){ [self.audioPlayer setNumberOfLoops:2]; }else{ [self.audioPlayer setNumberOfLoops:-1]; } Look for the line in the BT_screen_audio.m file that sets the number of loops - paste this there. Enter your item Id where I entered all the X's.
 

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.