How To Make a Soundboard App (Star Wars theme) – Ep 03 Play Sounds

[ad_1]
Build a Custom Star Wars Soundboard App
Lesson 3
In this series, I’ll show you guys how to build a soundboard app that you can customize with whatever sounds you want!

In this lesson, add AVFoundation framework and set up our AVAudioPlayer objects to play our Star Wars sounds! We also hook up a tap handler method to the buttons on the Storyboard so that it plays the sounds when tapped.

Related links:

Xcode project, source code and video download:

Star Wars sound files

Warning:
It’s going to be a little challenging for those who are completely new to iPhone app development so I recommend that you watch my “How To Make An iPhone App With No Programming Experience” series of videos first. That playlist is 17 lessons long but it’ll give you the foundation and explain the terminology and object oriented programming concepts that I’m going to be using in the building of this Shopping App.

That playlist can be found on my site here:

For more tutorials on how to build iPhone apps, make sure you subscribe and visit my site where you’ll find a community of like minded learners! Learning something new is always more fun with other people!

Youtube:
Website:

CodeWithChris is dedicated to teaching beginners and non-programmers all about building iOS apps. On the site, you’ll find a ton of free resources and tutorials to aid you on your journey to learn iOS development. Many people have successfully picked up Swift, Objective-C, Xcode and app building from my course and materials!

Intro & Outro music
“Heartbreaker” by Jahzzar (


Posted

in

by

Tags:

Comments

26 responses to “How To Make a Soundboard App (Star Wars theme) – Ep 03 Play Sounds”

  1. Martel Storm Avatar

    Damn that's disappointing to find out this doesn't work.

  2. De Schurk Avatar

    Very nice, got everything working, great tutorial. The only thing is when you press a sound button and another sound is still playing they are mixed together. How do you set a sound to auto stop playing when you press another sound button?

  3. Levi Bravenoer Avatar

    idid al you showed in the video but when in run it i press the button and then it shows me :

    Thread 1: breakpoint 1.1

    In the last line (let audioPlayer = audioPlayers [sender.tag])

    how can I fix this

  4. aurora cormier niehaus Avatar

    Here's what I put because the NSURL wasn't working :
    let url = URL(fileURLWithPath: Bundle.main.path(forResource: sound, ofType: "wav")!)
    and the sounds are playing perfectly

  5. aurora cormier niehaus Avatar

    thank you so much for the tutorial. It's working like a charm.
    Does anyone have any idea on how to add a pause button to stop the sounds before they're over?

  6. Sidharth Sudhir Avatar

    Hey Chris. When are you planning on updating this tutorial. Thanks for the videos.

  7. Max Schellenberg Avatar

    Yeah I'm having trouble too!

  8. Idea Films Avatar

    how do you make the audio loop>?

  9. Bhavik Daya Avatar

    For those of you using Swift 3.0, this is what I did to make NSURL work:

    let url = NSURL(fileURLWithPath: Bundle.main.path(forResource: sound, ofType: "wav")!);
    let audioPlayer = try AVAudioPlayer(contentsOf: url as URL);

  10. Owen Bowers Avatar

    It says thread 1 esc bad instruction for the NSURL is there any way to fix it.

  11. Creighton Gaming Avatar

    Mine was the same as his and mine never worked

  12. Vincent Jacobs Avatar

    Not working with NSURL anymore, do you have a solution?

  13. Juan Tobón Avatar

    Nice video Chris, just a quick update:

    This is the actual "Bundle" code for Xcode 3:

    let url = NSURL(fileURLWithPath: Bundle.main.path(forResource: sound, ofType: "wav")!)

    let audioPlayer = try AVAudioPlayer(contentsOf: url as URL)

  14. Estelle Gabbie Avatar

    Can someone help? I have an error saying "Expected declaration"
    HELP ME PLEASE

  15. Dylan Winn-Brown Avatar

    anyone got any suggestions for implementing a pause button that would globally stop all sounds playing?
    Thanks

  16. Pocket Man Avatar

    So fucking boring, get to the point

  17. Mel Smith Avatar

    hey Chris would you be interested on starting a new social media with me? 🙂 I will be start the UI/UX as soon as I get my new mac

  18. Oscar Frizzi Avatar

    It gives me an error in "let url = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(sound, ofType: "wav")!)" line:
    fatal error: unexpectedly found nil while unwrapping an Optional value
    (lldb)
    I can't solve it!!!
    Could someone help me?

  19. Karthik Boss Avatar

    soundFilenames gives me "unresolved identifier" please help me with what to do!

  20. Tavuh Avatar

    When I try to drag the action to create a method the blue bar does not show up, does anyone have a fix for this issue? And no im not on vnc

  21. BBGaming2 Avatar

    Can somebody help? I dont get the part with the "skewerd" and how you get it to throw.
    And how do you get it to autocomplete the AVAudioPlayer(contentsOfURL: NSURL) and the other things. Thanks so far! hope you reply

  22. Mateo Spak Jenbergsen Avatar

    Why do i get a EXC_BAD_INSTRUCTION error with: let url = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(sound, ofType: "wav")! )

    ????????please help?????

  23. Dominique Charlebois Avatar

    How would I make it so when I tap another button, the first sound stops playing??? Even if the sound isn't finished playing ??? Thanks. PLEASE REPLY !!

  24. ger piq Avatar

    I get stuck when I get to the "do/catch" bit. It doesn't recognise 'catch' – ie. it isn't purple. Just black and I get an error "Braced block of statements in an unused closure". Is this because you're using the beta version of Xcode and I'm not?

  25. Gary Winthorp Avatar

    I am making a thing like this button I only have 1 button and 1 sound would I do anther in different?

  26. Brandon Correia Avatar

    can u pls make a how to code a social network without parse

Leave a Reply

Your email address will not be published. Required fields are marked *