Skip to content

Commit

Permalink
small update to resource loading
Browse files Browse the repository at this point in the history
  • Loading branch information
finnkuusisto committed Feb 25, 2012
1 parent 2e22ce1 commit 287aa23
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/kuusisto/tinysound/TinySound.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public static void update(boolean fillNextBuffer) {
}

/**
* Load a Music by a resource name.
* Load a Music by a resource name. The resource must be on the classpath
* for this to work.
* @param name name of the Music resource
* @return Music resource as specified, null if not found/loaded
*/
Expand All @@ -236,6 +237,10 @@ public static Music loadMusic(String name) {
if (name == null) {
return null;
}
//check for correct naming
if (!name.startsWith("/")) {
name = "/" + name;
}
InputStream stream = TinySound.class.getResourceAsStream(name);
return TinySound.loadMusic(stream);
}
Expand Down Expand Up @@ -321,7 +326,8 @@ public static Music loadMusic(InputStream stream) {
}

/**
* Load a Sound by a resource name.
* Load a Sound by a resource name. The resource must be on the classpath
* for this to work.
* @param name name of the Sound resource
* @return Sound resource as specified, null if not found/loaded
*/
Expand All @@ -335,6 +341,10 @@ public static Sound loadSound(String name) {
if (name == null) {
return null;
}
//check for correct naming
if (!name.startsWith("/")) {
name = "/" + name;
}
InputStream stream = TinySound.class.getResourceAsStream(name);
return TinySound.loadSound(stream);

Expand Down

0 comments on commit 287aa23

Please sign in to comment.