Skip to content

Commit

Permalink
remove PlayOneShot example.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Feb 18, 2024
1 parent 35a6122 commit 378ae26
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions Assets/uLipSync/Samples/12. WebGL/Runtime/RuntimeAudioClipPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,25 @@ public class RuntimeAudioClipPlayer : MonoBehaviour

public void Play()
{
StartCoroutine(DownloadAndPlay(false));
StartCoroutine(DownloadAndPlay());
}

public void PlayOneShot()
{
StartCoroutine(DownloadAndPlay(true));
}

IEnumerator DownloadAndPlay(bool oneshot)
IEnumerator DownloadAndPlay()
{
var source = GetComponent<AudioSource>();
if (!source) yield return null;

var url = inputField.text;
var type = AudioType.WAV;
using (var www = UnityWebRequestMultimedia.GetAudioClip(url, type))
{
yield return www.SendWebRequest();
var clip = DownloadHandlerAudioClip.GetContent(www);
clip.name = inputField.text;
source.timeSamples = 0;
if (oneshot)
{
source.PlayOneShot(clip);
}
else
{
source.loop = false;
source.clip = clip;
source.Play();
}
}
using var www = UnityWebRequestMultimedia.GetAudioClip(url, type);
yield return www.SendWebRequest();

var clip = DownloadHandlerAudioClip.GetContent(www);
clip.name = inputField.text;

source.loop = false;
source.clip = clip;
source.Play();
}
}

Expand Down

0 comments on commit 378ae26

Please sign in to comment.