Search in sources :

Example 11 with SMILElement

use of org.w3c.dom.smil.SMILElement in project Signal-Android by WhisperSystems.

the class SmilDocumentImpl method getBody.

public SMILElement getBody() {
    Node rootElement = getDocumentElement();
    Node headElement = getHead();
    Node bodyElement = headElement.getNextSibling();
    if (bodyElement == null || !(bodyElement instanceof SMILElement)) {
        // The body doesn't exist. Create a new one.
        bodyElement = createElement("body");
        rootElement.appendChild(bodyElement);
    }
    // Initialize the real sequential time container, which is body.
    mSeqTimeContainer = new ElementSequentialTimeContainerImpl((SMILElement) bodyElement) {

        public NodeList getTimeChildren() {
            return getBody().getElementsByTagName("par");
        }

        public boolean beginElement() {
            Event startEvent = createEvent("Event");
            startEvent.initEvent(SMIL_DOCUMENT_START_EVENT, false, false);
            dispatchEvent(startEvent);
            return true;
        }

        public boolean endElement() {
            Event endEvent = createEvent("Event");
            endEvent.initEvent(SMIL_DOCUMENT_END_EVENT, false, false);
            dispatchEvent(endEvent);
            return true;
        }

        public void pauseElement() {
        // TODO Auto-generated method stub
        }

        public void resumeElement() {
        // TODO Auto-generated method stub
        }

        public void seekElement(float seekTo) {
        // TODO Auto-generated method stub
        }

        ElementTime getParentElementTime() {
            return null;
        }
    };
    return (SMILElement) bodyElement;
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) DocumentEvent(org.w3c.dom.events.DocumentEvent) Event(org.w3c.dom.events.Event) SMILElement(org.w3c.dom.smil.SMILElement) ElementTime(org.w3c.dom.smil.ElementTime)

Example 12 with SMILElement

use of org.w3c.dom.smil.SMILElement in project Signal-Android by WhisperSystems.

the class SmilXmlSerializer method writeElement.

private static void writeElement(Writer writer, Element element) throws IOException {
    writer.write('<');
    writer.write(element.getTagName());
    if (element.hasAttributes()) {
        NamedNodeMap attributes = element.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
            Attr attribute = (Attr) attributes.item(i);
            writer.write(" " + attribute.getName());
            writer.write("=\"" + attribute.getValue() + "\"");
        }
    }
    // FIXME: Might throw ClassCastException
    SMILElement childElement = (SMILElement) element.getFirstChild();
    if (childElement != null) {
        writer.write('>');
        do {
            writeElement(writer, childElement);
            childElement = (SMILElement) childElement.getNextSibling();
        } while (childElement != null);
        writer.write("</");
        writer.write(element.getTagName());
        writer.write('>');
    } else {
        writer.write("/>");
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) SMILElement(org.w3c.dom.smil.SMILElement) Attr(org.w3c.dom.Attr)

Example 13 with SMILElement

use of org.w3c.dom.smil.SMILElement in project qksms by moezbhatti.

the class SmilHelper method createSmilDocument.

public static SMILDocument createSmilDocument(PduBody pb) {
    SMILDocument document = new SmilDocumentImpl();
    // Create root element.
    SMILElement smil = (SMILElement) document.createElement("smil");
    smil.setAttribute("xmlns", "http://www.w3.org/2001/SMIL20/Language");
    document.appendChild(smil);
    // Create <head> and <layout> element.
    SMILElement head = (SMILElement) document.createElement("head");
    smil.appendChild(head);
    SMILLayoutElement layout = (SMILLayoutElement) document.createElement("layout");
    head.appendChild(layout);
    // Create <body> element and add a empty <par>.
    SMILElement body = (SMILElement) document.createElement("body");
    smil.appendChild(body);
    SMILParElement par = addPar(document);
    // Create media objects for the parts in PDU.
    int partsNum = pb.getPartsNum();
    if (partsNum == 0) {
        return document;
    }
    boolean hasText = false;
    boolean hasMedia = false;
    for (int i = 0; i < partsNum; i++) {
        // Create new <par> element.
        if ((par == null) || (hasMedia && hasText)) {
            par = addPar(document);
            hasText = false;
            hasMedia = false;
        }
        PduPart part = pb.getPart(i);
        String contentType = new String(part.getContentType());
        if (contentType.equals(ContentType.TEXT_PLAIN) || contentType.equalsIgnoreCase(ContentType.APP_WAP_XHTML) || contentType.equals(ContentType.TEXT_HTML)) {
            SMILMediaElement textElement = createMediaElement(ELEMENT_TAG_TEXT, document, part.generateLocation());
            par.appendChild(textElement);
            hasText = true;
        } else if (ContentType.isImageType(contentType)) {
            SMILMediaElement imageElement = createMediaElement(ELEMENT_TAG_IMAGE, document, part.generateLocation());
            par.appendChild(imageElement);
            hasMedia = true;
        } else if (ContentType.isVideoType(contentType)) {
            SMILMediaElement videoElement = createMediaElement(ELEMENT_TAG_VIDEO, document, part.generateLocation());
            par.appendChild(videoElement);
            hasMedia = true;
        } else if (ContentType.isAudioType(contentType)) {
            SMILMediaElement audioElement = createMediaElement(ELEMENT_TAG_AUDIO, document, part.generateLocation());
            par.appendChild(audioElement);
            hasMedia = true;
        } else if (contentType.equals(ContentType.TEXT_VCARD)) {
            SMILMediaElement textElement = createMediaElement(ELEMENT_TAG_VCARD, document, part.generateLocation());
            par.appendChild(textElement);
            hasMedia = true;
        } else {
            Log.e("creating_smil_document", "unknown mimetype");
        }
    }
    return document;
}
Also used : SMILMediaElement(org.w3c.dom.smil.SMILMediaElement) SMILDocument(org.w3c.dom.smil.SMILDocument) SmilDocumentImpl(com.android.mms.dom.smil.SmilDocumentImpl) SMILLayoutElement(org.w3c.dom.smil.SMILLayoutElement) SMILParElement(org.w3c.dom.smil.SMILParElement) PduPart(com.google.android.mms.pdu_alt.PduPart) SMILElement(org.w3c.dom.smil.SMILElement)

Example 14 with SMILElement

use of org.w3c.dom.smil.SMILElement in project qksms by moezbhatti.

the class SmilDocumentImpl method getBody.

public SMILElement getBody() {
    Node rootElement = getDocumentElement();
    Node headElement = getHead();
    Node bodyElement = headElement.getNextSibling();
    if (bodyElement == null || !(bodyElement instanceof SMILElement)) {
        // The body doesn't exist. Create a new one.
        bodyElement = createElement("body");
        rootElement.appendChild(bodyElement);
    }
    // Initialize the real sequential time container, which is body.
    mSeqTimeContainer = new ElementSequentialTimeContainerImpl((SMILElement) bodyElement) {

        public NodeList getTimeChildren() {
            return getBody().getElementsByTagName("par");
        }

        public boolean beginElement() {
            Event startEvent = createEvent("Event");
            startEvent.initEvent(SMIL_DOCUMENT_START_EVENT, false, false);
            dispatchEvent(startEvent);
            return true;
        }

        public boolean endElement() {
            Event endEvent = createEvent("Event");
            endEvent.initEvent(SMIL_DOCUMENT_END_EVENT, false, false);
            dispatchEvent(endEvent);
            return true;
        }

        public void pauseElement() {
        // TODO Auto-generated method stub
        }

        public void resumeElement() {
        // TODO Auto-generated method stub
        }

        public void seekElement(float seekTo) {
        // TODO Auto-generated method stub
        }

        ElementTime getParentElementTime() {
            return null;
        }
    };
    return (SMILElement) bodyElement;
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) DocumentEvent(org.w3c.dom.events.DocumentEvent) Event(org.w3c.dom.events.Event) SMILElement(org.w3c.dom.smil.SMILElement) ElementTime(org.w3c.dom.smil.ElementTime)

Example 15 with SMILElement

use of org.w3c.dom.smil.SMILElement in project qksms by moezbhatti.

the class SmilDocumentImpl method getHead.

/*
     * SMILElement Interface
     */
public SMILElement getHead() {
    Node rootElement = getDocumentElement();
    Node headElement = rootElement.getFirstChild();
    if (headElement == null || !(headElement instanceof SMILElement)) {
        // The head doesn't exist. Create a new one.
        headElement = createElement("head");
        rootElement.appendChild(headElement);
    }
    return (SMILElement) headElement;
}
Also used : Node(org.w3c.dom.Node) SMILElement(org.w3c.dom.smil.SMILElement)

Aggregations

SMILElement (org.w3c.dom.smil.SMILElement)23 Node (org.w3c.dom.Node)11 SMILDocument (org.w3c.dom.smil.SMILDocument)9 SMILParElement (org.w3c.dom.smil.SMILParElement)9 NodeList (org.w3c.dom.NodeList)8 SMILLayoutElement (org.w3c.dom.smil.SMILLayoutElement)8 SMILMediaElement (org.w3c.dom.smil.SMILMediaElement)8 SmilDocumentImpl (com.android.mms.dom.smil.SmilDocumentImpl)5 ArrayList (java.util.ArrayList)5 NamedNodeMap (org.w3c.dom.NamedNodeMap)5 SMILRegionElement (org.w3c.dom.smil.SMILRegionElement)5 SMILRootLayoutElement (org.w3c.dom.smil.SMILRootLayoutElement)5 Attr (org.w3c.dom.Attr)3 DocumentEvent (org.w3c.dom.events.DocumentEvent)3 Event (org.w3c.dom.events.Event)3 ElementTime (org.w3c.dom.smil.ElementTime)3 SMILRegionMediaElement (org.w3c.dom.smil.SMILRegionMediaElement)3 DrmManagerClient (android.drm.DrmManagerClient)2 AttrImpl (com.android.mms.dom.AttrImpl)2 PduPart (com.google.android.mms.pdu_alt.PduPart)2