sounds are not being played in my iOS app? - iphone

I have an app that should play 3 distinct sounds and I define them as so in my ViewDidLoad:
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"2357_02" ofType:#"m4a"]], &addedSound);
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"2357_01" ofType:#"m4a"]], &updatedSound);
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"notifier_12" ofType:#"m4a"]], &notFoundSound);
And I cue them to play like so:
AudioServicesPlaySystemSound(addedSound);
They play in the simulator but not on the ipad? In my Build Phases under Copy Bundle Resources I see them listed so I assumed that they should make it as part of my app - what am I missing here?

I actually used the solution suggested by Tammenn on this question and it worked great for me:
Sound on simulator but not device

Related

No sound in iPhone simulator for XCode 4.6.3

I have tried several options (many of them referenced from this post on SO and elsewhere) to get music to play on the iPhone simulator, but so far none of it has worked. I have tried -
Unchecking, and then checking the box that says "Player user interface sound effects" in the Preferences > Sound option
Going to Audio Midi Set Up, and changing the sample rate to 44100
Ensuring that the output/input is both using the internal speakers
Make sure that I imported <AVFoundation/AVFoundation.h> and added the AVFoundation.framework to my linked frameworks.
Resetting iOS simulator using Reset Settings/Contents
Restarting XCode, as well as as the computer
I have the following code in viewDidLoad that is play the file gundam.mp3
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:#"gundam" ofType:#"mp3"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.numberOfLoops = 1;
player.volume = 0.9;
NSLog(#"The sound URL is %#", soundFileURL);
[player play];
The NSLog seems to be able to capture the file correctly: The sound URL is file://localhost/Users/zallanx/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/[...]/Missile%20Defender.app/gundam.mp3
I am unsure what I am doing incorrectly based on all the options I have tried, and would appreciate your help. Thanks!

Creating a sound in iOS

I am using the following that I pulled out of a tutorial to help me play a quick sound in my game, but I will be using this very often to play sounds. Should I be doing anything different? or is this a proper way to play a sound effect.
NSString *path = [[NSBundle mainBundle] pathForResource:#"Sound/Microwave_Bell_Ding" ofType:#"mp3"];
NSURL *pathURL = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((CFURLRef) pathURL, &soundID);
AudioServicesPlaySystemSound(soundID);
Thanks!
first,you can't play mp3 in this way.second,you can store soundID,when you play next time,just call AudioServicesPlaySystemSound(soundID);

Play video in iPhone using HTML5 and UIWebView

I am writing a small POC to play the video in iPhone app. I would like to do so in UIWebView with the help of HTML5. I dont want to use standard players like AVPlayer or MPMoviePlayerController.
Can someone throw some light on it?..
I am new to this HTML5 environment on iPhone. So, any help to start this POC would be appriciated.
I forget to add that i would like to play h264 live stream on server.
Thanks in advance.
Yes, you can do that:
NSString *bundleDirectory = [[NSBundle mainBundle] pathForResource:#"mov" ofType:nil];
NSString *filePath = [bundleDirectory stringByAppendingPathComponent:#"loopvideo.html"];
NSString *HTMLData = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[self.web loadHTMLString:HTMLData baseURL:[NSURL fileURLWithPath:bundleDirectory]];
In your HTML, you can embed the <video> tag and it should play.

Couldn't put a song into an app

Have already tried that out and failed
I put a .wav file into my app and it was fine. So I tried to put a .wav song file into the app. When runs, there's no sound coming out. ( the song is converted from .mp3 using iTunes)
Any ideas how can I fix this? Thanks in advance
one possible reason the sound file is too large. You have different kinds of audio player in iOS some of them can only play files that are really short (something like 1-3 sec). To fix that you have to choose another player like CoreAudio.
The second possible failure is the simulator. The simulator is not always doing the same, the device do. Try running on real device and check if it's working.
// EDIT: sample code:
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:#"mySound" ofType:#"mp3"];
NSURL *soundFileURL = [NSURL URLForString:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithContentsOfURL:soundFileURL];
[player play];
[player pause];

Stop sound in iPhone

SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle] pathForResource:#"static" ofType:#"caf"];
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
I have implemented above code in my application.
It works perfectly, but the problem is I don't know how to stop it.
i.e Sound is of 10 sec.
Before 10 sec. if user taps button, sound should be stopped? How can I do so?
Try AudioServicesDisposeSystemSoundID, it stops sounds immediately. You'll need to recreate the sound if you intend to use it again.
Use the following instruction for disposes of a system sound object and associated resources:
AudioServicesDisposeSystemSoundID(soundID);
I would suggest using the AVFoundation framework. Here is an amazing tutorial on how to play, pause, and stop sound using the AVAudioPlayer.