/// <summary>Sends the request off. Callbacks such as onreadystatechange will be triggered.</summary> public void send() { if (readyState_ == 0) { // Act like it just opened: readyState = 1; } // Do we have a file protocol handler available? FileProtocol fileProtocol = location.Handler; if (fileProtocol == null) { return; } // Some protocols enforce a particular content type. string fileType = fileProtocol.ContentType(location); // Some file formats internally cache. // This means we can entirely avoid hitting the protocol system. // Get the format for the type: Contents = AudioFormats.GetInstance(fileType); // Did it internally cache? if (Contents.InternallyCached(location, this)) { // Yes it did! return; } fileProtocol.OnGetAudio(this); }
/// <summary>Gets a format by the given file type. Note: These are global!</summary> /// <param name="type">The name of the format, e.g. "ogg".</param> /// <returns>An AudioFormat if found; unrecognised handler otherwise.</returns> public static AudioFormat Get(string type) { if (Formats == null) { // Load the formats now! Modular.AssemblyScanner.FindAllSubTypesNow(typeof(AudioFormat), delegate(Type t){ // Add it as format: AudioFormats.Add(t); } ); } if (type == null) { type = ""; } AudioFormat result = null; if (!Formats.TryGetValue(type.ToLower(), out result)) { // Get the unrecognised handler: Formats.TryGetValue(UnrecognisedImageHandler, out result); } return(result); }
/// <summary>Assign the given clip to this package.</summary> public void AssignClip(AudioClip clip) { // Get the contents as an ogg block: OggFormat ogg = Contents as OggFormat; if (ogg == null) { // Clear the package: Clear(); // Get the audio format: Contents = AudioFormats.GetInstance("ogg"); // Update ogg var: ogg = Contents as OggFormat; } // Apply the clip: ogg.Clip = clip; }