DES311 #9: The Final Sprint

This is it, the final sprint, the last push. This week I have added in a music player and have begun my last round of bug fixing and optimization before submission.

My music player script stores a number of licenced music tracks in an array, and plays them in a shuffled order.

        while (true)
        {
            // Picks next track
            nextTrack = Random.Range(0, tracks.Length - 1);

            // Avoids the same track replaying
            if (nextTrack == currentTrack)
            {
                nextTrack += 1;
            }

            // Starts playing the next track
            audioSource.clip = tracks[nextTrack];
            audioSource.Play();
            currentTrack = nextTrack;
            trackName.text = tracks[currentTrack].name;

            // Waits until track is finished playing
            yield return new WaitWhile(() => audioSource.isPlaying);
        }

By naming each audio clip as the track title and artist separated by a dash then I can send the name of the currently playing trach to a text element in the UI. Also in the UI I’ve added a slider that controls the audio source volume. If I were adding more sound effects I would instead control the volume of a mixer where multiple audio sources would be sent. However due to the creative decision to avoid sound effects this was unnecessary.

What’s Next

The remainder of this sprint is going to be spent bug fixing and completing my portfolio submission for the module.