GWT: removeAttribute did not work?

advertisements

I am trying to change / remove my video which is in my start.html

    <video id="video" preload="auto" autoplay="true" loop="loop"
    muted="muted" volume="0">
<source
            src="clip0012.mp4" type="video/mp4">
</video>

I am calling this :

    Element elem = DOM.getElementById("video_background");
    elem.getFirstChildElement().removeAttribute("src");
elem.getFirstChildElement().setAttribute("src", "clip0022.mp4");

i get no error etc. the video clip0012 is still shown , but why?


Try this one (See comments for more information in code):

java:

    //Get old Video Element
    Element oldVideoElement=RootPanel.get("video").getElement();

    //Create a new Video Element
    VideoElement newVideoElement=Document.get().createVideoElement();
    newVideoElement.setId("video");
    newVideoElement.setPreload("auto");
    newVideoElement.setAttribute("autoplay","true");
    newVideoElement.setAttribute("loop","loop");
    newVideoElement.setAttribute("muted","muted");
    newVideoElement.setAttribute("volume","0");

    //Create a new Source Element
    SourceElement sourceElement = Document.get().createSourceElement();
    sourceElement.setSrc("movie.mp4");
    sourceElement.setType("video/mp4");

    //Append new source Element in new video Element
    newVideoElement.appendChild(sourceElement);

    //Append new video element in video div
    RootPanel.get("videoDiv").getElement().appendChild(newVideoElement);

    //remove old video element from its parent
    oldVideoElement.removeFromParent();

html:

<div id="videoDiv">
    <video id="video" preload="auto" autoplay="true" loop="loop"
        muted="muted" volume="0">
        <source src="clip0012.mp4" type="video/mp4">
    </video>
</div>