Possible to play a section of AudioClip?

Just wondering if its possible to play part of an AudioClip, rather than splicing it up into smaller AudioClips?

For example, something like this (which isn’t working).

Thanks

    public IEnumerator PlaySectionOfClip(int audioID, float TimeFrom, float TimeTo)
    {
        if (!gameObject.audio.isPlaying)
        {
            if (audioID < SoundSelection.Length)
            {
                gameObject.audio.clip = SoundSelection[audioID];

                gameObject.audio.Play();

                gameObject.audio.time = TimeFrom;

                yield return new WaitForSeconds(TimeTo - TimeFrom);

                gameObject.audio.Stop();

                yield return null;

                //   StopAudio();                    
            }
        }
    }

You can directly set audiosource.time to start from a specific position in the audio track. If you have some sort of data holder for the start and length of the subtrack you should be able to do this easily :slight_smile:
Let us know how it goes!

EDIT:
Eugh didn’t read your code sample. Did you try setting the time before playing the clip?

Might be wroth trying some of the suggestions outlined here, Play Audio x amount into the clip - Questions & Answers - Unity Discussions

It seems audiosource.time is a 0-1 value.