playing music files but not in draw function - amended help question

AMENDED QUERY -

so after the help below I’ve got the AAC files in a M4a wrapper (an AAC in the right format) and its coming in through dropbox and saved in my documents now.

I’m looking to trigger the code for music. I usually trigger things in the draw function but as the reference states - don’t continuously call it in draw but instead start, stop or change it.

So I’m wondering where I should put it if its not in draw.

Will it go in set up and then I use an event to change the file it plays?

Thanks,
Major

ORIGINAL QUERY:

Hi, so I’m exploring the new music playing features of codea 2.0. I have a dropbox account and I email files, or save them to my dropbox yet when I go into drop box on my iPad they are there, but the files and folders aren’t showing up on the dropbox option in codea. I must be missing something simple.

Any help greatly appreciated !

@Majormorgan Only files with a .png extension show on the iPad. Hopefully a future release will show files with any extension. As you already know, you can read the files, you just can’t see them.

Make sure the assets are in your /Dropbox/Apps/Codea/ folder, and when in Codea in the Dropbox assetpack, press “sync.”

@dave1707 In Codea 2.0, any supported image/music/sound file will appear in the asset browser. What do you mean, only .png?

@SkyTheCoder I’m talking about the Dropbox or Documents folders. I think those only display .png files for now.

hi thanks guys I managed to find the folder now. It does sync and see 6 files, but won’t display them. I have them as AAC files. should they be something else? Thanks

@Majormorgan I’m not sure if AAC files are supported. Could you try .mp3?

@dave1707 I am sure that the Documents/Dropbox assetpacks display files other than .png. If you want to see it for yourself, I can send you a screenshot, or a program than downloads and installs .mp3 and .wav files.

@SkyTheCoder I believe you. I never tried to save .mp3 or .wav files to those folders. I have .txt files there and those don’t show up.

@dave1707 Currently only file types used by Codea are shown (images, sounds, music), and nothing else.

@SkyTheCoder I think all file types should show and hopefully in a future release they will.

You can use iTunes on your computer/mac to convert sound files

Hi, thanks. I thought AAC was the format supported for sound in codea. Any idea which formats I should use? MP3, wav or m4a? Or something else. Ideally compressed so not wav

I think wav & ma4 work for music but I’m not sure about sound

mp3 and m4a files are music, and wav is sound. I think there’s one other sound type supported, but I can’t remember it.

Thanks Sky, I’ve amended my original query as I now can see the m4a files.

Now what I need to do is trigger the music but not in an endless draw way.

any ideas anyone?

thanks,
major

One solution would be to create a variable in setup, say

playmusic=0

Then in draw() to call the music command once

if playmusic==0 then
    --play the music command
    playmusic=1
end

Thanks @west

Sorry I should have thought of that before as I’m using variables in that way to change animation states.

I can then use another variable to change which track the music is during different parts of the game or even set playmusic back to 0 to then run a track change then set music back to 1 again.

thanks,
Major

maybe something like (i’m on my pc so haven’t tested this)

function draw()
    if music.name==nil then
         music("name")
    end
    -- draw stuff
end