Discussion Forums  >  Audio, Video, Playing, Recording

Replies: 20    Views: 960

JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
12/12/12 03:29 PM (11 years ago)

.mp3 and .wav files in xcode [SOLVED]

Hi All, Does anyone know the limitations for .mp3 & .wav files in xcode? i ask because ive tried to assign a .mp3 file to a button but no sound comes out when i use the simulator, i then tried a .wav file and it worked but ive also tried other .wav files and some don't work.not sure why some files don't work any additional info will help. Thankyou!
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
12/12/12 03:44 PM (11 years ago)
Hi @JouJou, Mp3 should work. Did you drag the sound to the folder? Music coming from a link? LA
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 03:52 PM (11 years ago)
yes i dragged the .mp3 file into xcode. I've done the same thing with other sounds but some don't work, not sure if there's a certain bit rate the files need to be set to?
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 04:10 PM (11 years ago)
yes i dragged the .mp3 file into xcode. I've done the same thing with other sounds but some don't work, not sure if there's a certain bit rate the files need to be set to?
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 04:18 PM (11 years ago)
yes i dragged the .mp3 file into xcode. I've done the same thing with other sounds but some don't work, not sure if there's a certain bit rate the files need to be set to?
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/12/12 04:25 PM (11 years ago)
Hi JouJou, Don't have the exact answer but it could indeed be related by the bit rate but also check the filenames. Don't use spaces in the name of the file. Just a tip and maybe a help. Best Regards, Danny
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 04:47 PM (11 years ago)
yea I've typed the exact name copied the file name and pasted it in. i may have to compare the bit rate to the one that works. ill let you know how i got, in the mean time im still open to suggestions :)
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/12/12 04:49 PM (11 years ago)
Hi JouJou, Can you give the name or url of a file that doesn't work? Best Regards, Danny
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 05:49 PM (11 years ago)
Ill need your email as the file i got is from a hunting forum, you would need to sign up to download the file.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/12/12 05:51 PM (11 years ago)
Hi JouJou, I just want to see the name of the file. You can email me at info at bt-addons dot com Best Regards, Danny
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/12/12 05:53 PM (11 years ago)
Thinking about this: are you using the direct sound from that website? If you first have to sign up to hear/play the sound then that could be the problem...protected by the login... Best Regards, Danny
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 06:05 PM (11 years ago)
no ive signed up to the website and you can download the .wav file directly on to the HD. i then drag the .wav file into xcode
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/12/12 06:07 PM (11 years ago)
OK but what's the exact name of that file....or maybe put it on dropbox so more people can shed a light on it... Best Regards, Danny
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/12/12 06:24 PM (11 years ago)
This is how ive set it up in Xcode: The file name is AntlerRabbit.wav ViewController.h: #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <AudioToolbox/AudioToolbox.h> @interface ViewController :UIViewController -(IBAction)AntlerRabbit; @end ViewController.m: #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(IBAction)AntlerRabbit { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"AntlerRabbit", CFSTR("wav"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/12/12 06:26 PM (11 years ago)
I'm lost!! Anyone else? Best Regards, Danny
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
12/13/12 07:26 AM (11 years ago)
Does it matter that the file is capitalized in two places? LA
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
12/13/12 09:01 AM (11 years ago)
I've never had luck using uncompressed .wav format on my phones. I'm a big lossless audio freak (give me .flac or give me death - and make it gapless too while you're at it!!). Why use .wav? It's uncomporessed audio with a full header info. Have you looked at the sample rate of the file? Why not compress that down to a standard .mp3 format yourself you know iOS likes? like a v0 256k? You'll save space and then you can properly tag/encode the file and you'll know for sure no DRM has been tacked onto the file as well...
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/13/12 01:15 PM (11 years ago)
@ LA, it shouldn't matter. @ ATRAIN53, Thanks, ill take your advice. I'll let you know how i go. Cheers, J
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
12/13/12 02:13 PM (11 years ago)
no prob- SUPER is a great free open source audio converter I use on occasion- http://www.erightsoft.com/SUPER.html I'm a big fan of dbpoweramp too, but that's not free.
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/13/12 08:40 PM (11 years ago)
The answer was here: https://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html" target="_blank" rel="nofollow">http://https://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html The reason why no sound was playing in the simulator is because when you use, AudioServicesPlaySystemSound the sound needs to be a maximum of 30 seconds in length. The sound i was using was just a bit above it. If anyone knows how to use a sounds file more than 30 seconds please post the code would be much appreciated.
 
JouJou
Aspiring developer
Profile
Posts: 20
Reg: Dec 01, 2012
Sydney, Austral...
3,450
like
12/13/12 08:40 PM (11 years ago)
 

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.