Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
Added audio clip loader
Browse files Browse the repository at this point in the history
  • Loading branch information
craftersmine committed Mar 2, 2019
1 parent 71e41ef commit 8a84c21
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion craftersmine.EtherEngine.Content/ContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,33 @@ public Animation LoadAnimation(string id)
}
else throw new ContentManagerException("Package does not contains object with this id \"" + id + "\"!");
}

/// <summary>
/// Loads audio clip from content package with specified ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public AudioClip LoadAudioClip(string id)
{
if (Contains(id))
{
ContentObject cObj = objects[id];
if (cObj.Type == ContentType.AudioClip)
{
string path = Path.Combine(ContentPath, id + ".etx");
try
{
return AudioClip.FromFile(path);
}
catch (Exception ex)
{
throw new ContentManagerException("Unable to load object with this id \"" + id + "\" as audio clip! " + ex.Message);
}
}
else throw new ContentManagerException("Object with this id \"" + id + "\" is not an audio clip!");
}
else throw new ContentManagerException("Package does not contains object with this id \"" + id + "\"!");
}
}

/// <summary>
Expand Down Expand Up @@ -198,6 +225,10 @@ public enum ContentType
/// <summary>
/// Animation
/// </summary>
Animation = 200
Animation = 200,
/// <summary>
/// Audio clip
/// </summary>
AudioClip = 300
}
}

0 comments on commit 8a84c21

Please sign in to comment.