Forum rules - please read before posting.

Shuffle tracks/playlist in Music Storage

I'd like to switch from Master Audio to AC's Music Storage completely, because it'd be awesome if AC would manage all my audio. However, a shuffle or randomize next track feature is essential in my opinion. 
For instance, I have loads of tracks for background music in my project, and I need to shuffle them.

Please consider adding shuffle to the Music Storage.

Comments

  • If you're dealing with a small number of tracks, this can be done with a Variable: Check random number Action followed by a series of Sound: Play music Actions.

    A custom Action can be written to do this quite easily, however - see the wiki page here: http://adventure-creator.wikia.com/wiki/Shuffling_music_tracks

  • Thanks for both suggestions!
  • Hello guys... I wanna do the same thing and I might sound silly but I can't manage it to work...
    Basically I'd like to shuffle my tracks in loop forever. I thought it was pretty easy, but I can't make it works.
    I tried both methods, but I get "Stack Overflow" error if I loop the shuffle part to itself.
    What I'd like is to shuffle between few tracks, pick one, playing it, once it's done shuffle again and play another and so on forever...
    If I click "Loop?" on the custom Action from the wikia, it just loops the one it randomly picked, not the whole "storage".
    If I do the same with standard "Play Sound" I can manage because I simply click "wait until finish" and therefore avoid the "Stack Overflow".
    Isn't there a way to have the "wait until finish" on the Play Music action? Or the custom ShuffleMusic?

  • edited February 2019

    The StackOverflow error will occur because you're running the Action multiple times each frame.

    I've updated the wiki script with the option to wait until the track completes.

  • Ok... I've used the new script, but it's not working... It gives me again the "Stack Overflow" problem and automatically remove the "Wait until finish?" tick from my Action. Should I combine it with "loop?" or something? If I chose "queue" and "wait until finish" it crashes Unity!

  • edited February 2019

    Don't use it with loop, otherwise it'll go on forever.

    I fixed an issue with it after posting - you may have gotten the old one.

    Make sure that:

    private bool willWaitComplete;
    

    is instead:

    public bool willWaitComplete;
    

    If you still have trouble, post a shot of your Action's configuration.

  • Thanks! Working now!

  • Resurrecting this thread - Using the up to date script from the wiki, what do I need to do to make a continual loop of shuffled tracks from a pool of (say) 4 play, continually across scenes?

    The custom action from the wiki when set to loop plays one, randomly chosen, track infinitely. Not setting loop plays one track at random once.

    Am I missing something obvious with this one?

  • My current workaround is to use an actionlist:run to trigger a looping action that shuffles a song, waits until it's finished and then doubles back on itself. This is ok, but I'm still rather confused as to whether I was using the custom action wrong or just trying to get behaviour it doesn't do!

  • edited November 24

    The Action can only run one track for each instance of it being run - if called once, it'll only play one track.

    If you uncheck Loop? and check Wait until finish?, though, you can have the Action wait until the randomly-chosen track has played all the way through. You can then re-route the Action to run itself again.

    For this to run continuously, and not interrupt gameplay, use this in an ActionList asset that has When running set to Run In Background and Can survive scene changes? checked.

  • Thanks Chris! That's what I've got set up now, and it's (fingers crossed) working fine right now.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.