I’m still having trouble with programming the tossing music. This is a replacement for the beeping, which has had mixed reviews from users. Some people really hate the beeping, especially when in public. Some people like it. So, I wanted to add an option for tossing music instead of beeping.
There are three options for the music to play in Jagimo: play a specific song, play a random song, play the default Jagimo tossing music (some silent film stuff, like in the demo video). If it is playing from the users’s library, it uses MPMusicPlayerController. If it’s the default music (a sound file embedded in the app) then it uses AVAudioPlayer. Sounds simple enough right?
The problem is that these two ways of playing music are handled differently by the iPhone. For example, MPMusicPlayerController will ignore the iPhone’s silent switch because it is playing through the iPod. This is not good for Jagimo, because we don’t want people’s phones to start playing music unexpectedly when they catch a jagimo. So I have to check for the device’s silent switch mode before playing. But what if they turn the silent switch on or off while the music is playing? Well, to account for this I have to check the state of the silent switch every second as the timer ticks away. The same goes for the volume by the way.
Furthermore, if the user is already listening to music, I don’t want Jagimo to play its music instead of the user’s. So I need to check the state of the iPod before starting the music. Add to this the options of turning sound off completely and setting the volume dynamically and you have a bit of code that ends up being a little more complex than I’d hoped. I still expect to be able to release tossing music soon, but it’s on the back burner for now.