private String _getTypeForSource()

in myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/media/AbstractMediaRenderer.java [196:225]


    private String _getTypeForSource(MediaInfo mediaInfo)
    {
        String contentType = mediaInfo.getContentType();
        String codec = mediaInfo.getCodec();

        boolean contentTypeDefined = contentType != null && contentType.length() > 0;
        boolean codecDefined = codec != null && codec.length() > 0;

        // if codec is set, then contentType should be set too!
        if (codecDefined && !contentTypeDefined)
            // WIKI: add a wiki and ref it here
            throw new FacesException(
                    "'codec' is defined but 'contentType' is not. If 'codec' is defined, 'contentType' has to be defined too.");

        String retVal = null;
        if (contentTypeDefined)
        {
            StringBuilder builder = new StringBuilder();
            builder.append(contentType);
            // aliok: I tried <video> <source> with no codec on browser, and no problem experienced.
            if (codecDefined)
            {
                builder.append("; codec='").append(codec).append("'");
            }

            retVal = builder.toString();
        }

        return retVal;
    }