Example usage for com.google.gwt.dom.client MediaElement CANNOT_PLAY

List of usage examples for com.google.gwt.dom.client MediaElement CANNOT_PLAY

Introduction

In this page you can find the example usage for com.google.gwt.dom.client MediaElement CANNOT_PLAY.

Prototype

String CANNOT_PLAY

To view the source code for com.google.gwt.dom.client MediaElement CANNOT_PLAY.

Click Source Link

Document

Constant returned from #canPlayType(String) .

Usage

From source file:annis.gui.widgets.gwt.client.ui.VMediaPlayerBase.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true)) {
        return;/*from   www  . ja  v  a  2  s .  c om*/
    }

    // Save reference to server connection object to be able to send
    // user interaction later
    this.gClient = client;

    // Save the client side identifier (paintable id) for the widget
    paintableId = uidl.getId();

    if (media == null) {
        VConsole.error("media not set!!!");
        return;
    }

    if (uidl.hasAttribute(SOURCE_URL)) {
        registerMetadataLoadedEvent(media);

        if (uidl.hasAttribute(MIME_TYPE)) {
            String mimeType = uidl.getStringAttribute(MIME_TYPE);
            VConsole.log(
                    "canPlayType for \"" + mimeType + "\"value is \"" + media.canPlayType(mimeType) + "\"");
            // check for correct mime type
            if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE)).equals(MediaElement.CANNOT_PLAY)) {
                VConsole.log("CANNOT PLAY!!!");

                gClient.updateVariable(paintableId, CANNOT_PLAY, true, true);
            } else if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE))
                    .equals(MediaElement.CAN_PLAY_MAYBE)) {
                gClient.updateVariable(paintableId, MIGHT_NOT_PLAY, true, true);
            }
        }
        media.setSrc(uidl.getStringAttribute(SOURCE_URL));
    }

    if (uidl.hasAttribute(PLAY)) {
        String[] time = uidl.getStringArrayAttribute(PLAY);
        if (time != null && time.length > 0) {
            if (time.length == 1) {
                try {
                    media.setCurrentTime(Double.parseDouble(time[0]));
                } catch (NumberFormatException ex) {
                    VConsole.error(ex);
                }
            } else if (time.length == 2) {
                try {
                    media.setCurrentTime(Double.parseDouble(time[0]));
                    setEndTimeOnce(media, Double.parseDouble(time[1]));
                } catch (NumberFormatException ex) {
                    VConsole.error(ex);
                }
            }
            media.play();
        }
    } else if (uidl.hasAttribute(PAUSE)) {
        media.pause();
    } else if (uidl.hasAttribute(STOP)) {
        media.pause();
        media.setSrc("");
    }
}