public long play (float volume) {\r
if (streamIds.size == 8) streamIds.pop();\r
int streamId = soundPool.play(soundId, volume, volume, 1, 0, 1);\r
+ //standardise error code with other backends\r
+ if (streamId == 0)\r
+ return -1;\r
streamIds.add(streamId);\r
return streamId;\r
}\r
public long loop (float volume) {\r
if (streamIds.size == 8) streamIds.pop();\r
int streamId = soundPool.play(soundId, volume, volume, 1, -1, 1);\r
+ //standardise error code with other backends\r
+ if (streamId == 0)\r
+ return -1;\r
streamIds.add(streamId);\r
return streamId;\r
}\r
leftVolume *= (1 - Math.abs(pan));\r
}\r
int streamId = soundPool.play(soundId, leftVolume, rightVolume, 1, 0, pitch);\r
+ //standardise error code with other backends\r
+ if (streamId == 0)\r
+ return -1;\r
streamIds.add(streamId);\r
return streamId;\r
}\r
leftVolume *= (1 - Math.abs(pan));\r
}\r
int streamId = soundPool.play(soundId, leftVolume, rightVolume, 1, -1, pitch);\r
+ //standardise error code with other backends\r
+ if (streamId == 0)\r
+ return -1;\r
streamIds.add(streamId);\r
return streamId;\r
}\r
* @author badlogicgames@gmail.com */\r
public interface Sound extends Disposable {\r
/** Plays the sound. If the sound is already playing, it will be played again, concurrently.\r
- * @return the id of the sound instance. */\r
+ * @return the id of the sound instance if successful, or -1 on failure. */\r
public long play ();\r
\r
/** Plays the sound. If the sound is already playing, it will be played again, concurrently.\r
* @param volume the volume in the range [0,1]\r
- * @return the id of the sound instance */\r
+ * @return the id of the sound instance if successful, or -1 on failure. */\r
public long play (float volume);\r
\r
/** Plays the sound. If the sound is already playing, it will be played again, concurrently.\r
* @param volume the volume in the range [0,1]\r
* @param pitch the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0\r
* @param pan panning in the range -1 (full right) to 1 (full left). 0 is center position.\r
- * @return the id of the sound instance */\r
+ * @return the id of the sound instance if successful, or -1 on failure. */\r
public long play (float volume, float pitch, float pan);\r
\r
/** Plays the sound, looping. If the sound is already playing, it will be played again, concurrently.\r
- * @return the id of the sound instance */\r
+ * @return the id of the sound instance if successful, or -1 on failure. */\r
public long loop ();\r
\r
/** Plays the sound, looping. If the sound is already playing, it will be played again, concurrently. You need to stop the sound\r
* via a call to {@link #stop(long)} using the returned id.\r
* @param volume the volume in the range [0, 1]\r
- * @return the id of the sound instance */\r
+ * @return the id of the sound instance if successful, or -1 on failure. */\r
public long loop (float volume);\r
\r
/** Plays the sound, looping. If the sound is already playing, it will be played again, concurrently. You need to stop the sound\r
* @param volume the volume in the range [0,1]\r
* @param pitch the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0\r
* @param pan panning in the range -1 (full right) to 1 (full left). 0 is center position.\r
- * @return the id of the sound instance */\r
+ * @return the id of the sound instance if successful, or -1 on failure. */\r
public long loop (float volume, float pitch, float pan);\r
\r
/** Stops playing all instances of this sound. */\r