Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKelvin Atawura
Front End Web Development Techdegree Student 19,022 PointsAdding sound to the Crystal Ball App
I managed to get my crystal ball animation working but thought it would be so much better if the animation had a sound to go with. Managed to download this wav file from the internet but how do l get it to play and stop when my animation start and finish respectively. Any ideas? codes? :)
Kelvin Atawura
Front End Web Development Techdegree Student 19,022 Points@Jonathan thanks for the advice. It's my first time of doing forums so haven't got no idea what and can't write
5 Answers
Amit Bijlani
Treehouse Guest TeacherThe Octave sound library is the easiest way for you to add sounds to the crystal ball project. Or you can play your own custom sound: http://stackoverflow.com/questions/9791491/best-way-to-play-simple-sound-effect-in-ios
Kelvin Atawura
Front End Web Development Techdegree Student 19,022 Points@Amit thank you very much. What codes and properties would I need to set and syntgesize for the sound to play on my application? Please
Amit Bijlani
Treehouse Guest Teacherhackey james The code is there in the links I provided above. Not sure if that's what you are asking.
Kelvin Atawura
Front End Web Development Techdegree Student 19,022 Points@Amit sorry I didn't look into the link. Thanks
Shankar Narayan
9,099 Points@Amit, my app is ready, animation done, sound files added, no errors, but sound doesn't play!
@implementation KGViewController { SystemSoundID soundEffect; }
-
(void)viewDidLoad { [super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"crystal_ball" ofType:@"mp3"]; NSURL *soundURL = [NSURL fileURLWithPath : path]; AudioServicesCreateSystemSoundID((CFURLRef) CFBridgingRetain(soundURL), &soundEffect);
Michele Wong
4,643 PointsMy sound doesn't play too! App ready, animation done, sound files added and no errors during runtime. The sound plays on the iPhone simulator on my back but not on my iPhone. Thanks for the help!
Shankar Narayan
9,099 Points@Michele, so i closed my laptop and went to sleep and came this morning and tried again, it worked! Well thats all i know for now!
Anthony Ho
10,228 Pointsit worked with
AudioServicesPlayAlertSound(soundEffect)
Jonathan Musso
3,760 PointsJonathan Musso
3,760 PointsUnfortunately I have not worked through this problem yet. One suggestion for Forum practices though, please refrain from using full capital titles. ;)