Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Using AudioSource.Time

Discussion in 'Audio & Video' started by Soumikbhat, Dec 23, 2014.

  1. Soumikbhat

    Soumikbhat

    Joined:
    Nov 23, 2013
    Posts:
    110
    I'm clueless as to how to achieve this:

    Basically I've a 4min 10 sec long audio clip..however I want to play it from 34 seconds onwards...

    So basically from 0:34 is my start-point and 4:10 is my end point.

    Some suggested that AudioSource.Time is what I need....but the doc speaks no word as to how to achieve this...please give the syntax or some 'raw code' to solve this issue..thanks...
     
  2. Soumikbhat

    Soumikbhat

    Joined:
    Nov 23, 2013
    Posts:
    110
    An help...?
     
  3. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    What do you have currently? You should be able to go to 0:34 by just doing this:

    Code (csharp):
    1.  
    2. audioSource.time=34;
    3.  
     
  4. Soumikbhat

    Soumikbhat

    Joined:
    Nov 23, 2013
    Posts:
    110
    Thanks...and how do I set the end-time? Suppose say I want to pause at 4min - i.e 240 sec...how to specify that?
     
  5. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Something like
    Code (csharp):
    1.  
    2. if(audioSource.time>=240)
    3.     audioSource.Stop();
    4.  
    5.  
     
    Soumikbhat likes this.