Version: 2022.3
LanguageEnglish
  • C#
Removed

WWW.oggVorbis

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete Obsolete msg.
Upgrade to GetAudioClip
public Object oggVorbis;

Description

Load an Ogg Vorbis file into the audio clip.

If the stream has not been downloaded completely, null will be returned. Use isDone or yield to see if the data is available.

Additional resources: AudioClip, AudioSource.

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { string path = "http://ia301106.us.archive.org/2/items/abird2005-02-10/abird2005-02-10t02.ogg";

IEnumerator Start() { // Start downloading using (var download = new WWW(path)) { // Wait for download to finish yield return download; // Create ogg vorbis file var clip = download.GetAudioClip(); // Play it if (clip != null) { GetComponent<AudioSource>().clip = clip; GetComponent<AudioSource>().Play(); } else // Handle error { Debug.Log("Ogg vorbis download failed. (Incorrect link?)"); } } } }