Home > front end >  play sound in xylophone project
play sound in xylophone project

Time:02-06

I try to make a Xylophone. I added my Sound file by dragging the file into my XCode project and i made sure 'Copy items if needed' is checked. I wrote the code. I connected 7 buttons to the keyPressed function. I set the names of the sound files and the names of the buttons to be the same. When I run the code and press any key, it gives this error and no sound is playing. I'm sure the sound files are also included because when I click on show in Finder, the audio files are in the project. I don't know what I did wrong.

After you drag and target them, you should see like this in the inspector when you click each of the sounds:

If you wont change the button style plain to default it wont work whatever you carefully drag the sounds into XCode. I know it's stupid but it should be like this. Otherwise when you run the project and click on any button it would give an error like that:

  •  Tags:  
  • Related