Need help with my code - please assist.

Everything looks right with this code, so can anyone please critique it for me and tell me why it isn’t working?

-- BEGINNING OF MUSIC FUNCTIONALITY bgTune = audio.loadStream("music/backgroundMusic.mp3") audio.loop = -1 audio.channel = 1 audio.play( bgTune ) function bgMusic:tap (event) if audio.play(Tune) then audio.stop (bgTune) end end bgMusic:addeventListener ( "tap", bgMusic ) -- END OF MUSIC FUNCTIONALITY

Thanks in advance. :slight_smile:

Can you describe the problem you are having?

The code I posted previously does not work. I dont know why - I was hoping for someone who is knowledgable enough to tell me why it isn’t working. Thanks.  ;) 

Do you not get any sound?  Does it play once and not play again?  Are you getting any errors in your console log?  If you need help reading the console.log, read this:

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Just looking at the code, at one point you reference Tune which is never defined.  Also doing audio.channel and audio.loop doesn’t do anything. 

You might want to look through these tutorials:  http://coronalabs.com/resources/tutorials/images-audio-video-animation/

Look at the audio based sample apps.  Read the documentation for the audio.* API (http://docs.coronalabs.com/api/library/audio/index.html)

Rob

Oh. I didnt understand your first post. I get a blank screen (black), and the music plays. My display objects dont show up at all.

If I delete the code I posted here, then everything works perfectly. But I would really like to get the music working. I hope that helps explain my issue better. Thanks.

You can’t add a touch or tap handler to an audio object, only to a display object.

But did you see any thing in your logs?

Oh… Well that makes sense - I didnt even realize I had no display object for the sound… /facepalm  :o 

Thanks for bringing that to my attention. I did not see anything else in the log though other than what I posted here.

Can you describe the problem you are having?

The code I posted previously does not work. I dont know why - I was hoping for someone who is knowledgable enough to tell me why it isn’t working. Thanks.  ;) 

Do you not get any sound?  Does it play once and not play again?  Are you getting any errors in your console log?  If you need help reading the console.log, read this:

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Just looking at the code, at one point you reference Tune which is never defined.  Also doing audio.channel and audio.loop doesn’t do anything. 

You might want to look through these tutorials:  http://coronalabs.com/resources/tutorials/images-audio-video-animation/

Look at the audio based sample apps.  Read the documentation for the audio.* API (http://docs.coronalabs.com/api/library/audio/index.html)

Rob

Oh. I didnt understand your first post. I get a blank screen (black), and the music plays. My display objects dont show up at all.

If I delete the code I posted here, then everything works perfectly. But I would really like to get the music working. I hope that helps explain my issue better. Thanks.

You can’t add a touch or tap handler to an audio object, only to a display object.

But did you see any thing in your logs?

Oh… Well that makes sense - I didnt even realize I had no display object for the sound… /facepalm  :o 

Thanks for bringing that to my attention. I did not see anything else in the log though other than what I posted here.