Search in sources :

Example 1 with SmilDocumentImpl

use of org.thoughtcrime.securesms.dom.smil.SmilDocumentImpl in project Signal-Android by WhisperSystems.

the class SmilUtil method createSmilDocument.

private static SMILDocument createSmilDocument(PduBody body) {
    Log.w(TAG, "Creating SMIL document from PduBody.");
    SMILDocument document = new SmilDocumentImpl();
    SMILElement smilElement = (SMILElement) document.createElement("smil");
    document.appendChild(smilElement);
    SMILElement headElement = (SMILElement) document.createElement("head");
    smilElement.appendChild(headElement);
    SMILLayoutElement layoutElement = (SMILLayoutElement) document.createElement("layout");
    headElement.appendChild(layoutElement);
    SMILRootLayoutElement rootLayoutElement = (SMILRootLayoutElement) document.createElement("root-layout");
    rootLayoutElement.setWidth(ROOT_WIDTH);
    rootLayoutElement.setHeight(ROOT_HEIGHT);
    layoutElement.appendChild(rootLayoutElement);
    SMILElement bodyElement = (SMILElement) document.createElement("body");
    smilElement.appendChild(bodyElement);
    SMILParElement par = (SMILParElement) document.createElement("par");
    bodyElement.appendChild(par);
    for (int i = 0; i < body.getPartsNum(); i++) {
        PduPart part = body.getPart(i);
        SMILRegionElement regionElement = getRegion(document, part);
        SMILMediaElement mediaElement = getMediaElement(document, part);
        if (regionElement != null) {
            ((SMILRegionMediaElement) mediaElement).setRegion(regionElement);
            layoutElement.appendChild(regionElement);
        }
        par.appendChild(mediaElement);
    }
    return document;
}
Also used : SMILMediaElement(org.w3c.dom.smil.SMILMediaElement) SMILDocument(org.w3c.dom.smil.SMILDocument) SmilDocumentImpl(org.thoughtcrime.securesms.dom.smil.SmilDocumentImpl) SMILRootLayoutElement(org.w3c.dom.smil.SMILRootLayoutElement) SMILLayoutElement(org.w3c.dom.smil.SMILLayoutElement) SMILParElement(org.w3c.dom.smil.SMILParElement) PduPart(ws.com.google.android.mms.pdu.PduPart) SMILElement(org.w3c.dom.smil.SMILElement) SMILRegionElement(org.w3c.dom.smil.SMILRegionElement) SMILRegionMediaElement(org.w3c.dom.smil.SMILRegionMediaElement)

Aggregations

SmilDocumentImpl (org.thoughtcrime.securesms.dom.smil.SmilDocumentImpl)1 SMILDocument (org.w3c.dom.smil.SMILDocument)1 SMILElement (org.w3c.dom.smil.SMILElement)1 SMILLayoutElement (org.w3c.dom.smil.SMILLayoutElement)1 SMILMediaElement (org.w3c.dom.smil.SMILMediaElement)1 SMILParElement (org.w3c.dom.smil.SMILParElement)1 SMILRegionElement (org.w3c.dom.smil.SMILRegionElement)1 SMILRegionMediaElement (org.w3c.dom.smil.SMILRegionMediaElement)1 SMILRootLayoutElement (org.w3c.dom.smil.SMILRootLayoutElement)1 PduPart (ws.com.google.android.mms.pdu.PduPart)1