Package org.rometools.feed.module.mediarss.types

Examples of org.rometools.feed.module.mediarss.types.MediaContent


        ArrayList values = new ArrayList();
       
        try {
            for (int i = 0; (contents != null) && (i < contents.size()); i++) {
                Element content = (Element) contents.get(i);
                MediaContent mc = null;
               
                if (content.getAttributeValue("url") != null) {
                    try{
                        mc = new MediaContent(new UrlReference(
                                new URI(content.getAttributeValue("url"))));
                        mc.setPlayer(parsePlayer(content));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                } else {
                    mc = new MediaContent(parsePlayer(content));
                }
                if (mc != null) {
                    values.add(mc);
                    try{
                        mc.setAudioChannels((content.getAttributeValue("channels") == null)
                        ? null : new Integer(content.getAttributeValue("channels")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                    try{
                        mc.setBitrate((content.getAttributeValue("bitrate") == null)
                        ? null : new Float(content.getAttributeValue("bitrate")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                    try{
                        mc.setDuration((content.getAttributeValue("duration") == null)
                        ? null : new Long(content.getAttributeValue("duration")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }

                    mc.setMedium(content.getAttributeValue("medium"));

                    String expression = content.getAttributeValue("expression");
                   
                    if (expression != null) {
                        if (expression.equalsIgnoreCase("full")) {
                            mc.setExpression(Expression.FULL);
                        } else if (expression.equalsIgnoreCase("sample")) {
                            mc.setExpression(Expression.SAMPLE);
                        } else if (expression.equalsIgnoreCase("nonstop")) {
                            mc.setExpression(Expression.NONSTOP);
                        }
                    }
                   
                    try{
                        mc.setFileSize((content.getAttributeValue("fileSize") == null)
                        ? null : NumberParser.parseLong(content.getAttributeValue("fileSize")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                    try{
                        mc.setFramerate((content.getAttributeValue("framerate") == null)
                        ? null : NumberParser.parseFloat(content.getAttributeValue("framerate")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                    try {                 
                        mc.setHeight((content.getAttributeValue("height") == null)
                        ? null : NumberParser.parseInt(content.getAttributeValue("height")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                   
                    mc.setLanguage(content.getAttributeValue("lang"));
                    mc.setMetadata(parseMetadata(content));
                    try{
                        mc.setSamplingrate((content.getAttributeValue("samplingrate") == null)
                        ? null : NumberParser.parseFloat(content.getAttributeValue("samplingrate")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                   
                    mc.setType(content.getAttributeValue("type"));
                    try{
                        mc.setWidth((content.getAttributeValue("width") == null) ? null
                                : NumberParser.parseInt(content.getAttributeValue("width")));
                    } catch (Exception ex) {
                        LOG.log(Level.WARNING, "Exception parsing content tag.", ex);
                    }
                   
                    mc.setDefaultContent((content.getAttributeValue("isDefault") == null)
                    ? false
                            : Boolean.getBoolean(content.getAttributeValue(
                            "isDefault")));                 
                } else {
                  LOG.log(Level.WARNING, "Could not find MediaContent.");
View Full Code Here

TOP

Related Classes of org.rometools.feed.module.mediarss.types.MediaContent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.