Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 22, 2012, 02:31 AM   #1
Narendar Singh
macrumors member
 
Join Date: Jun 2012
Location: INDIA
Send a message via Skype™ to Narendar Singh
Sound is not playing on iOS 6 iPhone 5

The sound is not playing for

- iOS 6 iPhone 5
- iOS 5 iPhone 4

but working fine on iPad 2 and iPhone 3GS

Code:
- (void)playSound
{
    // read the sound file from resources and play it on successful scanning
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"scan_beep" ofType:@"wav"];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    AudioServicesCreateSystemSoundID((CFURLRef)fileURL, &systemSoundID);
    AudioServicesPlayAlertSound(systemSoundID);
}
What can be wrong here, same code is working for few device but not for all.

I call the above function when I scan the barcode in my sample app.
__________________
Finite Disappointment Vs Infinite Hope
Narendar Singh is offline   0 Reply With Quote
Old Dec 28, 2012, 02:11 PM   #2
CodeBreaker
macrumors 6502
 
Join Date: Nov 2010
Location: Sea of Tranquility
Quote:
Originally Posted by Narendar Singh View Post
The sound is not playing for

- iOS 6 iPhone 5
- iOS 5 iPhone 4

but working fine on iPad 2 and iPhone 3GS

Code:
- (void)playSound
{
    // read the sound file from resources and play it on successful scanning
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"scan_beep" ofType:@"wav"];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    AudioServicesCreateSystemSoundID((CFURLRef)fileURL, &systemSoundID);
    AudioServicesPlayAlertSound(systemSoundID);
}
What can be wrong here, same code is working for few device but not for all.

I call the above function when I scan the barcode in my sample app.
Do you by chance have an AVCaptureSession running with an audio input in it?
__________________
.
CodeBreaker is offline   0 Reply With Quote
Old Jan 8, 2013, 06:02 AM   #3
Narendar Singh
Thread Starter
macrumors member
 
Join Date: Jun 2012
Location: INDIA
Send a message via Skype™ to Narendar Singh
Quote:
Originally Posted by CodeBreaker View Post
Do you by chance have an AVCaptureSession running with an audio input in it?
I did not understand
__________________
Finite Disappointment Vs Infinite Hope
Narendar Singh is offline   0 Reply With Quote
Old Jan 8, 2013, 09:19 AM   #4
xArtx
macrumors 6502a
 
Join Date: Mar 2012
Quote:
Originally Posted by Narendar Singh View Post
I did not understand
This works for me:
Code:
       NSURL *path   = [[NSBundle mainBundle] URLForResource: @"scan_beep"
                                                    withExtension: @"wav"];
        self.soundFileURLRef = (__bridge CFURLRef) path;
        AudioServicesCreateSystemSoundID (
                                          soundFileURLRef,
                                          &beep
                                          );
Some png files weren't recognised across all devices because I didn't pay
attention to case. Is your sound file .wav or .WAV?
xArtx is offline   0 Reply With Quote
Old Jan 8, 2013, 10:22 AM   #5
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by xArtx View Post
Some png files weren't recognised across all devices...
png files?
__________________
dejo is online now   0 Reply With Quote
Old Jan 8, 2013, 11:26 AM   #6
xArtx
macrumors 6502a
 
Join Date: Mar 2012
Loading png (image) files from main bundle to a UIImage has on more
than one occasion, worked on one device/iOS and not another for me.
I had to change
Code:
UIImage *myImage = [UIImage imageNamed:@"Sun.png"];
to
Code:
UIImage *myImage = [UIImage imageNamed:@"Sun.PNG"];
to see the image on all three devices. The file name was "Sun.PNG".
xArtx is offline   0 Reply With Quote
Old Jan 8, 2013, 12:04 PM   #7
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
If you always pay attention to case, you don't need to worry about it.

Quote:
The iOS-Filesystem is case-sensitive, whereas the OSX-Filesystem the Simulator uses isn't.
http://stackoverflow.com/questions/4...imulator-and-d
__________________
dejo is online now   0 Reply With Quote
Old Jan 9, 2013, 12:35 AM   #8
Narendar Singh
Thread Starter
macrumors member
 
Join Date: Jun 2012
Location: INDIA
Send a message via Skype™ to Narendar Singh
Quote:
Originally Posted by xArtx View Post
Some png files weren't recognised across all devices because I didn't pay attention to case. Is your sound file .wav or .WAV?
Well my file is beep.wav and in code I am using ofTpye:@"wav"

Very strange, same code is running perfect in iPad 2, iPod Touch 4th Gen, iPhone 3GS but not in iPhone 4 and iPhone 5
__________________
Finite Disappointment Vs Infinite Hope
Narendar Singh is offline   0 Reply With Quote
Old Jan 14, 2013, 01:38 AM   #9
xArtx
macrumors 6502a
 
Join Date: Mar 2012
Try:

Code:
AudioServicesPlaySystemSound (systemSoundID);
rather than:

Code:
AudioServicesPlayAlertSound(systemSoundID);
Also, the rest of your code belongs in a function that is called only once at
program launch rather than loading the sound to memory every time you
play it.

EDIT,,
Also on the iPhone 4 & 5, try:

Code:
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
This should invoke a vibration on those devices, but does not rely on any sound file being loaded.

Last edited by xArtx; Jan 14, 2013 at 01:52 AM.
xArtx is offline   0 Reply With Quote
Old Jan 17, 2013, 03:30 AM   #10
Narendar Singh
Thread Starter
macrumors member
 
Join Date: Jun 2012
Location: INDIA
Send a message via Skype™ to Narendar Singh
Tried whatever you guys suggested !!

let me remind my issue, with following code I test my application on following devices:

- iPhone 5 iOS 6
- iPhone 4S iOS 6
- iPhone 4 iOS 5
- iPad 2 iOS 5
- iPhone 3GS not remember its iOS Version

Code:
- (void)playSound
{
    // read the sound file from resources and play it on successful scanning
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"scan_beep" ofType:@"wav"];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    AudioServicesCreateSystemSoundID((CFURLRef)fileURL, &systemSoundID);
    AudioServicesPlayAlertSound(systemSoundID);
}
Then I run my Application, sound works for iPhone 4S, iPad2 & iPhone 3GS but not for iPhone 5 & iPhone 4.
__________________
Finite Disappointment Vs Infinite Hope
Narendar Singh is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iOS 7.0.4 iPhone 4S Sound bug EliteAces iPhone Tips, Help and Troubleshooting 1 Dec 30, 2013 06:17 AM
iOS 7.0.4 - no sound on iPhone 4S Centralman iOS 7 1 Nov 21, 2013 12:13 AM
iphone 3gs not playing on docking station and in car since ios 6.1 DaytonaV2 iPhone Tips, Help and Troubleshooting 1 Feb 20, 2013 08:28 AM
No sound issue on iPhone 4s with iOS 6 dudulang iPhone 7 Jan 19, 2013 05:14 AM
iOS 6 / iPhone 5, Music only playing if Wifi and 3G is off Ichorus iPhone Tips, Help and Troubleshooting 0 Sep 25, 2012 11:55 AM

Forum Jump

All times are GMT -5. The time now is 10:22 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC