/**
 * Copyright 2011 The PlayN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package playn.html;

import com.allen_sauer.gwt.voices.client.handler.PlaybackCompleteEvent;
import com.allen_sauer.gwt.voices.client.handler.SoundHandler;
import com.allen_sauer.gwt.voices.client.handler.SoundLoadStateChangeEvent;

import playn.core.AbstractSound;
import playn.core.Asserts;

class HtmlSound extends AbstractSound {

  private final com.allen_sauer.gwt.voices.client.Sound sound;

  private boolean playing;

  HtmlSound(com.allen_sauer.gwt.voices.client.Sound sound) {
    this.sound = sound;
    sound.addEventHandler(new SoundHandler() {
        @Override
      public void onSoundLoadStateChange(SoundLoadStateChangeEvent event) {
        switch (event.getLoadState()) {
          case LOAD_STATE_UNINITIALIZED:
          case LOAD_STATE_SUPPORTED_NOT_READY:
            // ignore
            break;
          case LOAD_STATE_SUPPORTED_AND_READY:
          case LOAD_STATE_SUPPORT_NOT_KNOWN:
          case LOAD_STATE_SUPPORTED_MAYBE_READY:
            onLoadComplete();
            break;
          case LOAD_STATE_NOT_SUPPORTED:
            onLoadError(new RuntimeException(event.getLoadStateAsString()));
            break;
          default:
            throw new RuntimeException("Unrecognized sound load state "
                + event.getLoadStateAsString());
        }
      }

      @Override
      public void onPlaybackComplete(PlaybackCompleteEvent event) {
        playing = false;
      }
    });
  }

  @Override
  public boolean play() {
    playing = true;
    return sound.play();
  }

  @Override
  public void stop() {
    sound.stop();
    playing = false;
  }

  @Override
  public void setLooping(boolean looping) {
    sound.setLooping(looping);
  }

  @Override
  public void setVolume(float volume) {
    Asserts.checkArgument(0f <= volume && volume <= 1f, "Must ensure 0f <= volume <= 1f");
    sound.setVolume((int) (volume * 100));
  }

  @Override
  public boolean isPlaying() {
    return playing;
  }

}
@@ -612,16 +612,581 @@
 .html;%0A%0A
+import static com.allen_sauer.gwt.voices.client.Sound.LoadState.LOAD_STATE_NOT_SUPPORTED;%0Aimport static com.allen_sauer.gwt.voices.client.Sound.LoadState.LOAD_STATE_SUPPORT_NOT_KNOWN;%0Aimport static com.allen_sauer.gwt.voices.client.Sound.LoadState.LOAD_STATE_SUPPORTED_AND_READY;%0Aimport static com.allen_sauer.gwt.voices.client.Sound.LoadState.LOAD_STATE_SUPPORTED_MAYBE_READY;%0Aimport static com.allen_sauer.gwt.voices.client.Sound.LoadState.LOAD_STATE_SUPPORTED_NOT_READY;%0Aimport static com.allen_sauer.gwt.voices.client.Sound.LoadState.LOAD_STATE_UNINITIALIZED;%0A%0A
 import c
@@ -1249,16 +1249,16 @@
 eEvent;%0A
-
 import c
@@ -1387,16 +1387,74 @@
 geEvent;
+%0Aimport com.allen_sauer.gwt.voices.client.Sound.LoadState;
 %0A%0Aimport
@@ -1879,36 +1879,77 @@
     
-switch (event.getLoadState()
+LoadState loadState = event.getLoadState();%0A        switch (loadState
 ) %7B%0A
@@ -2357,34 +2357,22 @@
 ion(
-event.getLoadStateAsString
+loadState.name
 ()))
@@ -2505,34 +2505,22 @@
   + 
-event.getLoadStateAsString
+loadState.name
 ());
@@ -3187,9 +3187,10 @@
 g;%0A  %7D%0A%0A
-
 %7D
+%0A

Fix HtmlSound compile errors