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).


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


                gameObject.audio.time = TimeFrom;

                yield return new WaitForSeconds(TimeTo - TimeFrom);


                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!

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.