Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-07-2011, 03:12 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
SteveJames is on a distinguished road
Unhappy Problems with no sound on device! simulator ok!

Hi everyone, I am new to this so please bear with me.

I have made a simple soundboard app, with a mainview and a flipside. The sounds are on the mainview, all works fine in the simulator, but when I download app to my device, everything except the sounds work!?

Here is the code for sound I am using :


- (IBAction)playSound: (id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"laughing", CFSTR("caf"), NULL);
if (soundFileURLRef) {
CFStringRef url = CFURLGetString(soundFileURLRef);
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}


I have placed this code in the mainviewcontroller.m

The code I used in mainviewcontroller.h was : - (IBAction)playSound: (id)sender;

As I said before, it all works fine in the simulator but not on the device! Can anybody help me please??

SteveJames

If anyone can help, I can always show you guys more code if this helps?

Last edited by SteveJames; 02-07-2011 at 03:15 PM.
SteveJames is offline   Reply With Quote
Old 02-07-2011, 03:19 PM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 66
dcool is on a distinguished road
Default

did you turn the volume on or unmute?
dcool is offline   Reply With Quote
Old 02-07-2011, 03:22 PM   #3 (permalink)
Registered Member
 
Chobie's Avatar
 
Join Date: Feb 2011
Location: UK
Posts: 115
Chobie is on a distinguished road
Default

Quote:
Originally Posted by SteveJames View Post
Hi everyone, I am new to this so please bear with me.

I have made a simple soundboard app, with a mainview and a flipside. The sounds are on the mainview, all works fine in the simulator, but when I download app to my device, everything except the sounds work!?

Here is the code for sound I am using :


- (IBAction)playSound: (id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"laughing", CFSTR("caf"), NULL);
if (soundFileURLRef) {
CFStringRef url = CFURLGetString(soundFileURLRef);
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}


I have placed this code in the mainviewcontroller.m

The code I used in mainviewcontroller.h was : - (IBAction)playSound: (id)sender;

As I said before, it all works fine in the simulator but not on the device! Can anybody help me please??

SteveJames

If anyone can help, I can always show you guys more code if this helps?
Could be a lot of things, a quick checklist than I remember a colleague telling me about:

1. Preallocate the sound before you use it. Apparently you shouldn't initialize the sound right before you use it as the devices are slower than the Mac running the simulator.

2. File types. Is it .wav .aiff .caf?

3. Frequency/size/length/coding can all play a part as well.

Let me know if that helps.
__________________
Chobie is offline   Reply With Quote
Old 02-07-2011, 03:30 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
SteveJames is on a distinguished road
Default Hi

Quote:
Originally Posted by Chobie View Post
Could be a lot of things, a quick checklist than I remember a colleague telling me about:

1. Preallocate the sound before you use it. Apparently you shouldn't initialize the sound right before you use it as the devices are slower than the Mac running the simulator.

2. File types. Is it .wav .aiff .caf?

3. Frequency/size/length/coding can all play a part as well.

Let me know if that helps.

Hi there, I have tried .wav .aiff and .caf,
The lengths of the sounds are only 3-4 seconds each, what do you mean by pre-allocate?
SteveJames is offline   Reply With Quote
Old 02-07-2011, 03:31 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
SteveJames is on a distinguished road
Default Hi

Quote:
Originally Posted by dcool View Post
did you turn the volume on or unmute?
where is this done? do you literally mean, is my phone on mute? or have I seriously overlooked something very simple?

Thanks

Steve
SteveJames is offline   Reply With Quote
Old 02-07-2011, 03:33 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

could it be the same problem ppl have with images? having the file in the project point to a location on the mac, but then it never gets copied to device? how did u add it to ur project?
kapps11 is offline   Reply With Quote
Old 02-07-2011, 03:39 PM   #7 (permalink)
Registered Member
 
Chobie's Avatar
 
Join Date: Feb 2011
Location: UK
Posts: 115
Chobie is on a distinguished road
Default

Quote:
Originally Posted by SteveJames View Post
Hi there, I have tried .wav .aiff and .caf,
The lengths of the sounds are only 3-4 seconds each, what do you mean by pre-allocate?
Try moving the AudioServicesCreateSystemSoundID to viewDidLoad. So when you call play system sound later it has fully processed the audio file by then. I believe this is what he meant by pre-allocate.

The only other thing I could think of is to make sure the filename is the correct case as I believe the device is case sensitive?
__________________

Last edited by Chobie; 02-07-2011 at 03:41 PM.
Chobie is offline   Reply With Quote
Old 02-07-2011, 03:41 PM   #8 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
SteveJames is on a distinguished road
Default Hey

Quote:
Originally Posted by kapps11 View Post
could it be the same problem ppl have with images? having the file in the project point to a location on the mac, but then it never gets copied to device? how did u add it to ur project?

I dragged the sound file from my desktop into the app folder, then opened the app folder and dragged the sound file into my project. Is that the correct way of adding a sound? I have also added sound files by right clicking (cntrl + Click) on the project name - add files - existing files and located the sound file that way .

Any good?

Thanks guys
SteveJames is offline   Reply With Quote
Old 02-07-2011, 03:46 PM   #9 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
SteveJames is on a distinguished road
Default Chobie

Quote:
Originally Posted by Chobie View Post
Try moving the AudioServicesCreateSystemSoundID to viewDidLoad. So when you call play system sound later it has fully processed the audio file by then. I believe this is what he meant by pre-allocate.

The only other thing I could think of is to make sure the filename is the correct case as I believe the device is case sensitive?

Hi there, please bear with me, when you say move the AudioServicesCreateSystemSoundID to ViewDidLoad, do you mean type in ViewDidLoad to replace AudioServicesCreateSystemSoundId?

Sorry if Im being a dumbass?

SteveJames
SteveJames is offline   Reply With Quote
Old 02-07-2011, 03:53 PM   #10 (permalink)
Registered Member
 
Chobie's Avatar
 
Join Date: Feb 2011
Location: UK
Posts: 115
Chobie is on a distinguished road
Default

Quote:
Originally Posted by SteveJames View Post
Hi there, please bear with me, when you say move the AudioServicesCreateSystemSoundID to ViewDidLoad, do you mean type in ViewDidLoad to replace AudioServicesCreateSystemSoundId?

Sorry if Im being a dumbass?

SteveJames
I am recommending you first call AudioServicesCreateSystemSoundId in the method viewDidLoad.

Then later on in your method you can call AudioServicesPlaySystemSound making sure you pass it the correct soundID you created in viewDidLoad. Does that makes sense?

Of course I cannot guarantee that this would solve the problem though.
__________________
Chobie is offline   Reply With Quote
Old 02-07-2011, 04:02 PM   #11 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
SteveJames is on a distinguished road
Default hey

Quote:
Originally Posted by Chobie View Post
I am recommending you first call AudioServicesCreateSystemSoundId in the method viewDidLoad.

Then later on in your method you can call AudioServicesPlaySystemSound making sure you pass it the correct soundID you created in viewDidLoad. Does that makes sense?

Of course I cannot guarantee that this would solve the problem though.

No Im so sorry, it doesnt make sense to me.. can you type the code how it should look?
SteveJames is offline   Reply With Quote
Old 02-07-2011, 05:11 PM   #12 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

It's pretty tough to viewDidLoad in a forum post. If you look in your documentation for "View Controller Programming Guide for iOS", the section on Custom ViewControllers explains what code goes in what method, including viewDidLoad. Have a look and let us know what you come up with.
JasonR is offline   Reply With Quote
Old 02-08-2011, 02:45 PM   #13 (permalink)
Registered Member
 
Chobie's Avatar
 
Join Date: Feb 2011
Location: UK
Posts: 115
Chobie is on a distinguished road
Default

Yeah and also remember to check the filename as it is case sensitive.
__________________
Chobie is offline   Reply With Quote
Reply

Bookmarks

Tags
device sound, no sound, simulator, sound

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 365
14 members and 351 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0