Search Unity

Audio 2018.3 Cannot set the time samples for the partially downloaded audio clip

Discussion in 'Audio & Video' started by WereVarg, Jan 5, 2019.

  1. WereVarg

    WereVarg

    Joined:
    Apr 9, 2012
    Posts:
    18
    Before the 2018.3 released we lived happily with the following code:

    Code (CSharp):
    1. public IEnumerator Stream(string soundId)
    2.     {
    3.         ..
    4.         var www = new WWW(path);
    5.    
    6.         float downloadLimit = 0.05f;  
    7.         while (www.progress < downloadLimit)
    8.         {
    9.             ...
    10.             yield return new WaitForSeconds(0.1f);
    11.         }    
    12.         AudioClip myAudioClip = www.GetAudioClip(false, true, AudioType.MPEG);
    13.         DownloadContainer.audioClip = myAudioClip;  //setting audioclip and we can start Play or Rewind using clip.timeSamples
    14.         DownloadContainer.isDone = true;
    15.         yield return null;
    16.         while (www.progress < 1)
    17.         {
    18.             DownloadContainer.progress = www.progress;
    19.             yield return null;
    20.         }
    21.     }
    now we get the error if we try to change clip.timeSamples before the track is downloaded


    C:\buildslave\unity\build\Modules/Audio/Public/sound/SoundChannel.cpp(356) : Error executing result (Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format. )
    UnityEngine.AudioSource.Play()


    and now we have to block the Rewind possibility and get the AudioClip again after the download complete


    myAudioClip = www.GetAudioClip(false, true, AudioType.MPEG);
    DownloadTrackContainer.Result = myAudioClip;


    and now we are able to scroll through it.

    Any ideas?
     
    Last edited: Jan 11, 2019
  2. janusl

    janusl

    Unity Technologies

    Joined:
    Aug 8, 2018
    Posts:
    4
    Hi WereVarg,

    Just to understand your use case perfectly: Before 2018.3 you wanted to & were able to:
    1. download a clip partially
    2. seek the clip (.timeSamples)
    3. play it
    Without issues? Or do you just use seeking to rewind to the start?

    Regards, Janus
     
  3. WereVarg

    WereVarg

    Joined:
    Apr 9, 2012
    Posts:
    18
    Yes, exactly, we used seeking in both directions. Now we aren't able to set audioClip.timeSamples while it is marked as streamed: using true inside
    AudioClip myAudioClip = www.GetAudioClip(false, true, AudioType.MPEG);

    or setting DownloadHandlerAudioClip.stream = true; using WebRequest
     
  4. janusl

    janusl

    Unity Technologies

    Joined:
    Aug 8, 2018
    Posts:
    4
    Alright, can I get you to submit a bug report?
     
    WereVarg likes this.
  5. IndieGamesStudio

    IndieGamesStudio

    Joined:
    Sep 4, 2015
    Posts:
    2
    the same here it could be unity bug