SHARE
TWEET

Untitled

lcfr822 Jul 15th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Panels.AUD;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.Networking;
  6.  
  7. public class AudioPlaybackWrapper : AudioDownloadWrapper
  8. {
  9.     public AudioType audioType = AudioType.OGGVORBIS;
  10.  
  11.     public void TriggerDownload(string url, AUD_Panel localAudPanel)
  12.     {
  13.         if (url.Contains(".ogg")) { audioType = AudioType.OGGVORBIS; }
  14.         else if (url.Contains(".wav")) { audioType = AudioType.WAV; }
  15.         MediaUrl = url;
  16.         AudPanel = localAudPanel;
  17.     }
  18.  
  19.     protected override IEnumerator StartLoadMedia()
  20.     {
  21.         yield return LoadMediaFromUrl(MediaUrl, AudPanel);
  22.     }
  23.  
  24.     private IEnumerator LoadMediaFromUrl(string url, AUD_Panel audPanel)
  25.     {
  26.         var handler = new DownloadHandlerAudioClip(url, audioType);
  27.         yield return ExecuteRequest(url, handler);
  28.         if(handler.audioClip.length > 0)
  29.         {
  30.             Debug.LogWarning("GREAT SUCCESS! URL: " + url);
  31.             audPanel.clipUrl = url;
  32.             audPanel.audAudio.audioClip = handler.audioClip;
  33.         }
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top