Example usage for com.google.gwt.media.client Audio isSupported

List of usage examples for com.google.gwt.media.client Audio isSupported

Introduction

In this page you can find the example usage for com.google.gwt.media.client Audio isSupported.

Prototype

public static boolean isSupported() 

Source Link

Document

Runtime check for whether the audio element is supported in this browser.

Usage

From source file:com.allen_sauer.gwt.voices.client.Html5Sound.java

License:Apache License

/**
 * @param mimeType the requested MIME type and optional codec according to RFC 4281
 * @return the level of support for the provided MIME type
 *///  w w w .j  a  v  a2  s . co  m
public static MimeTypeSupport getMimeTypeSupport(String mimeType) {
    if (!Audio.isSupported()) {
        return MimeTypeSupport.MIME_TYPE_NOT_SUPPORTED;
    }
    String support = Audio.createIfSupported().getAudioElement().canPlayType(mimeType);
    assert support != null;
    if (AudioElement.CAN_PLAY_PROBABLY.equals(support)) {
        return MimeTypeSupport.MIME_TYPE_SUPPORT_READY;
    }
    if (AudioElement.CAN_PLAY_MAYBE.equals(support)) {
        return MimeTypeSupport.MIME_TYPE_SUPPORT_READY;
    }
    return MimeTypeSupport.MIME_TYPE_SUPPORT_UNKNOWN;
}

From source file:com.allen_sauer.gwt.voices.client.Html5Sound.java

License:Apache License

private void createAudioElement() {
    if (endedRegistration != null) {
        endedRegistration.removeHandler();
    }/*ww  w.  j a  v  a  2s . c o  m*/
    if (audio != null) {
        // TODO: remove, once DOM attachment no longer required to sink (bitless) events
        audio.removeFromParent();
    }
    assert Audio.isSupported();
    audio = Audio.createIfSupported();
    assert audio != null;
    AudioElement elem = audio.getAudioElement();
    assert elem != null;

    endedRegistration = audio.addEndedHandler(endedHandler);

    // TODO: remove, once DOM attachment no longer required to sink (bitless) events
    RootPanel.get().add(audio);

    if (isCrossOrigin()) {
        elem.setAttribute("crossOrigin", "anonymous");
    }
    elem.setSrc(getUrl());
}

From source file:com.google.gwt.sample.mobilewebapp.client.ui.SoundEffects.java

License:Apache License

/**
 * Get the singleton instance./*  w w w  .j a  v a2s  .  c om*/
 * 
 * @return the singleton instance
 */
public static SoundEffects get() {
    if (instance == null) {
        isSupported = Audio.isSupported();
        instance = new SoundEffects();
    }
    return instance;
}

From source file:es.deusto.weblab.client.experiments.logic.ui.LogicExperiment.java

License:Open Source License

private void processCommandSent(ResponseCommand responseCommand) {
    if (this.lastCommand instanceof GetCircuitCommand) {
        this.messages.stop();
        this.messages.setText("");
        final CircuitParser circuitParser = new CircuitParser();
        try {//ww  w  .j  a  v a 2s . c  om
            this.circuit = circuitParser.parseCircuit(responseCommand.getCommandString());
        } catch (final InvalidCircuitException e) {
            this.messages.setText("Invalid Circuit received: " + e.getMessage());
            return;
        }
        this.sendSolutionButton.setEnabled(false);
        this.updateCircuitGrid();
    } else if (this.lastCommand instanceof SolveCircuitCommand) {
        this.messages.stop();

        if (responseCommand.getCommandString().startsWith("FAIL")) {
            this.solving = false;

            if (Audio.isSupported()) {
                @SuppressWarnings("unused")
                final Audio audio = Audio.createIfSupported();

            }

            AudioManager.getInstance().playBest("snd/wrong");

            this.messages.setText(i18n.wrongOneGameOver(this.points));
            this.sendSolutionButton.setEnabled(false);
        } else if (responseCommand.getCommandString().startsWith("OK")) {
            this.points++;
            turnOnLight();
            this.messages.setText(i18n.wellDone1point());

            AudioManager.getInstance().playBest("snd/applause");

            final Timer sleepTimer = new Timer() {

                @Override
                public void run() {
                    LogicExperiment.this.sendCommand(new GetCircuitCommand());
                    turnOffLight();
                }

            };
            sleepTimer.schedule(2000);
        }

    } else {
        // TODO: Unknown command!
    }
}