From: <fg...@us...> - 2010-02-14 10:09:17
|
Revision: 1922 http://openutils.svn.sourceforge.net/openutils/?rev=1922&view=rev Author: fgiust Date: 2010-02-14 10:09:10 +0000 (Sun, 14 Feb 2010) Log Message: ----------- MEDIA-97 the media tag should use the player tag also for external videos - a bit of refactoring for making the player tag more generic Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/media.tag trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/player.tag trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/swfobject.tag trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_en.properties Modified: trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/media.tag =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/media.tag 2010-02-13 22:12:21 UTC (rev 1921) +++ trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/media.tag 2010-02-14 10:09:10 UTC (rev 1922) @@ -105,42 +105,28 @@ <![CDATA[ />]]> </c:if> </c:when> - <c:when test="${media.type eq 'video' or media.type eq 'audio' }"> - <media:player player="${player}" share="${share}" item="${item}" width="${width}" height="${height}" autoPlay="${autoPlay}" loop="${loop}" thumbnail="${thumbnail}" noPlayIcon="${noPlayIcon}" controlbar="${controlbar}" skin="${skin}"/> + <c:when test="${media.type eq 'video' or media.type eq 'audio' or media.type eq 'youtube' }"> + <c:set var="url" value="${media:url(mediaNode)}"/> + <c:choose> + <c:when test="${media.type eq 'youtube' and fn:startsWith(url, 'http://www.youtube')}"> + <!-- automatically extract preview image for youtube videos from url --> + <c:set var="preview">http://img.youtube.com/vi/${su:substringAfterLast(url, 'v=')}/0.jpg</c:set> + </c:when> + </c:choose> + <media:player url="${url}" + preview="${preview}" + player="${player}" + share="${share}" + item="${item}" + width="${width}" + height="${height}" + autoPlay="${autoPlay}" + loop="${loop}" + thumbnail="${thumbnail}" + noPlayIcon="${noPlayIcon}" + controlbar="${controlbar}" + skin="${skin}"/> </c:when> - <c:when test="${media.type eq 'youtube'}"> - <c:set var="url" value="${media:url(mediaNode)}" /> - <c:if test="${width eq 0 }"> - <c:set var="width" value="320" /> - </c:if> - <c:if test="${height eq 0}"> - <c:set var="height" value="240" /> - </c:if> - <c:set var="flashvars"> - <![CDATA[file=${media:url(mediaNode)}${controlBar}]]> - <c:choose> - <c:when test="${fn:indexOf(url, 'youtube') ge 0}"> - <c:set var="previewImage" value="${su:substringAfterLast(url, 'v=')}" /> - <![CDATA[&type=youtube&image=http://img.youtube.com/vi/${previewImage}/0.jpg]]> - </c:when> - <c:when test="${thumbnail}"> - <c:choose> - <c:when test="${width gt 0 and height gt 0}"> - <c:set var="previewres" value="${width}x${height}" /> - <![CDATA[&image=${pageContext.request.contextPath}${media:urlres(mediaNode, previewres)}]]> - </c:when> - <c:otherwise> - <![CDATA[&image=${pageContext.request.contextPath}${media:thumbnail(mediaNode)}]]> - </c:otherwise> - </c:choose> - </c:when> - </c:choose> - </c:set> - <c:set var="previewImage" value="${su:substringAfterLast(url, 'v=')}" /> - <c:if test="${!empty(url)}"> - <media:swfobject player="${player}" width="${width}" height="${height}" allowfullscreen="true" allowscriptaccess="always" wmode="opaque" flashvars="${flashvars}" /> - </c:if> - </c:when> </c:choose> </c:when> <c:otherwise> Modified: trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/player.tag =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/player.tag 2010-02-13 22:12:21 UTC (rev 1921) +++ trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/player.tag 2010-02-14 10:09:10 UTC (rev 1922) @@ -3,38 +3,33 @@ xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:media="http://net.sourceforge.openutils/mgnlMedia" xmlns:su="http://openutils.sf.net/openutils-stringutils"> <jsp:directive.tag description="Renders the audio or video player" pageEncoding="UTF-8" /> - <jsp:directive.attribute name="item" required="true" rtexprvalue="true" type="java.lang.Object" - description="media uuid or media content node " /> - <jsp:directive.attribute name="player" required="true" rtexprvalue="true" type="java.lang.String" - description="the swf file of the player (examples: player.swf (default), jwplayer4, jwplayer5, jwplayer5/player.swf, /.resources/media/players/jwplayer5/player.swf)" /> - <jsp:directive.attribute name="width" required="false" rtexprvalue="true" type="java.lang.Integer" - description="image or player width" /> - <jsp:directive.attribute name="height" required="false" rtexprvalue="true" type="java.lang.Integer" - description="image or player height" /> - <jsp:directive.attribute name="ignoreDim" required="false" rtexprvalue="true" type="java.lang.Boolean" - description="if true the img element will be rendered without width and height attributes " /> - <jsp:directive.attribute name="autoPlay" required="false" rtexprvalue="true" type="java.lang.Boolean" - description="auto starts the player without waiting for user play command" /> - <jsp:directive.attribute name="loop" required="false" rtexprvalue="true" type="java.lang.Boolean" - description="loop video or audio" /> - <jsp:directive.attribute name="noPlayIcon" required="false" rtexprvalue="true" type="java.lang.Boolean" - description="hide player icons" /> + <jsp:directive.attribute name="url" required="true" rtexprvalue="true" type="java.lang.String" description="Url for the flv that will be loaded by the player" /> + <jsp:directive.attribute name="preview" required="false" rtexprvalue="true" type="java.lang.String" description="Preview image url" /> + <jsp:directive.attribute name="item" required="true" rtexprvalue="true" type="java.lang.Object" description="media uuid or media content node " /> + <jsp:directive.attribute name="player" required="true" rtexprvalue="true" type="java.lang.String" description="the swf file of the player (examples: player.swf (default), jwplayer4, jwplayer5, jwplayer5/player.swf, /.resources/media/players/jwplayer5/player.swf)" /> + <jsp:directive.attribute name="width" required="false" rtexprvalue="true" type="java.lang.Integer" description="image or player width" /> + <jsp:directive.attribute name="height" required="false" rtexprvalue="true" type="java.lang.Integer" description="image or player height" /> + <jsp:directive.attribute name="ignoreDim" required="false" rtexprvalue="true" type="java.lang.Boolean" description="if true the img element will be rendered without width and height attributes " /> + <jsp:directive.attribute name="autoPlay" required="false" rtexprvalue="true" type="java.lang.Boolean" description="auto starts the player without waiting for user play command" /> + <jsp:directive.attribute name="loop" required="false" rtexprvalue="true" type="java.lang.Boolean" description="loop video or audio" /> + <jsp:directive.attribute name="noPlayIcon" required="false" rtexprvalue="true" type="java.lang.Boolean" description="hide player icons" /> <jsp:directive.attribute name="skin" required="false" rtexprvalue="true" description="set player skin" /> - <jsp:directive.attribute name="thumbnail" required="false" rtexprvalue="true" type="java.lang.Boolean" - description="if set to true the preview of the player shows the thumbnail image" /> - <jsp:directive.attribute name="controlbar" required="false" rtexprvalue="true" type="java.lang.String" - description="defines controlbar position. Possible values are: 'none' (for hiding), 'over', 'bottom', 'top'. If not set, this value will be 'bottom' by default." /> - <jsp:directive.attribute name="share" required="false" rtexprvalue="true" type="java.lang.Boolean" - description="if set to true the pluging share-1 is showen" /> + <jsp:directive.attribute name="thumbnail" required="false" rtexprvalue="true" type="java.lang.Boolean" description="if set to true the preview of the player shows the thumbnail image" /> + <jsp:directive.attribute name="controlbar" required="false" rtexprvalue="true" type="java.lang.String" description="defines controlbar position. Possible values are: 'none' (for hiding), 'over', 'bottom', 'top'. If not set, this value will be 'bottom' by default." /> + <jsp:directive.attribute name="share" required="false" rtexprvalue="true" type="java.lang.Boolean" description="Adds the share features to the player (copy page url and embed code)" /> + <!-- end attributes --> <c:set value="${media:node(item)}" var="mediaNode" /> <c:if test="${empty controlbar}"> <c:set var="controlbar" value="bottom" /> </c:if> + <!-- end defaults --> + + <c:set var="baseUrl" scope="request"> <jsp:text>${pageContext.request.scheme}://${pageContext.request.serverName}</jsp:text> <c:if test="${(pageContext.request.scheme eq 'http' and pageContext.request.serverPort != 80)}">:${pageContext.request.serverPort}</c:if> + <jsp:text>${pageContext.request.contextPath}</jsp:text> </c:set> - <c:set var="url" value="${media:url(mediaNode)}" /> <c:if test="${width eq 0 }"> <c:set var="width" value="${media:width(mediaNode)}" /> </c:if> @@ -56,52 +51,60 @@ <c:if test="${previewheight gt 20 and (controlbar eq 'bottom' or controlbar eq 'top')}"> <c:set var="previewheight" value="${previewheight - 20}" /> </c:if> + <c:if test="${thumbnail and empty preview}"> + <c:choose> + <c:when test="${previewwidth gt 0 and previewheight gt 0}"> + <c:set var="previewres" value="${previewwidth}x${previewheight}" /> + <c:set var="preview" value="${pageContext.request.contextPath}${media:urlres(mediaNode, previewres)}"/> + </c:when> + <c:otherwise> + <c:set var="preview" value="${pageContext.request.contextPath}${media:thumbnail(mediaNode)}"/> + </c:otherwise> + </c:choose> + </c:if> <c:if test="${!empty(url)}"> - <c:if test="${su:endsWith(fn:toLowerCase(url), '.flv') or su:endsWith(fn:toLowerCase(url), '.mp3')}"> - <c:set var="flashvars"> - <![CDATA[file=${pageContext.request.contextPath}${url}]]> - <c:if test="${!empty controlbar}"> - <![CDATA[&controlbar=${controlbar}]]> - </c:if> - <c:if test="${autoPlay}"> - <![CDATA[&autostart=true]]> - </c:if> - <c:if test="${loop}"> - <![CDATA[&repeat=always]]> - </c:if> - <c:if test="${noPlayIcon}"> - <![CDATA[&icons=false]]> - </c:if> - <c:if test="${not empty skin}"> - <![CDATA[&skin=${skin}]]> - </c:if> - <c:if test="${thumbnail}"> - <c:choose> - <c:when test="${previewwidth gt 0 and previewheight gt 0}"> - <c:set var="previewres" value="${previewwidth}x${previewheight}" /> - <![CDATA[&image=${pageContext.request.contextPath}${media:urlres(mediaNode, previewres)}]]> - </c:when> - <c:otherwise> - <![CDATA[&image=${pageContext.request.contextPath}${media:thumbnail(mediaNode)}]]> - </c:otherwise> - </c:choose> - </c:if> - <c:if test="${share}"> - <c:set var="sharinglink">${baseUrl}${pageContext.request.contextPath}${actpage.handle}.html</c:set> - <c:set var="sharingcode"> - <embed src="${baseUrl}${pageContext.request.contextPath}/.resources/media/players/player.swf" - flashvars="file=${baseUrl}${pageContext.request.contextPath}${url}" width="${width}" height="${height}" /> - </c:set> - <![CDATA[&plugins=sharing-1]]> - <![CDATA[&sharing.link=${sharinglink}]]> - <![CDATA[&sharing.code=${fn:escapeXml(sharingcode)}]]> - </c:if> - </c:set> - <media:swfobject player="${player}" width="${width}" height="${height}" allowfullscreen="true" - allowscriptaccess="always" wmode="opaque" flashvars="${flashvars}" /> - </c:if> - <c:if test="${su:endsWith(fn:toLowerCase(url), 'swf')}"> - <media:swfobject player="${pageContext.request.contextPath}${url}" width="${width}" height="${height}" /> - </c:if> + <c:choose> + <c:when test="${su:endsWith(fn:toLowerCase(url), 'swf')}"> + <media:swfobject player="${pageContext.request.contextPath}${url}" width="${width}" height="${height}" /> + </c:when> + <c:otherwise> + <c:set var="flashvars"> + <![CDATA[file=${fn:startsWith(url, 'http')? '' : pageContext.request.contextPath}${url}]]> + <c:if test="${fn:startsWith(url, 'http://www.youtube')}"> + <![CDATA[&type=youtube]]> + </c:if> + <c:if test="${!empty controlbar}"> + <![CDATA[&controlbar=${controlbar}]]> + </c:if> + <c:if test="${autoPlay}"> + <![CDATA[&autostart=true]]> + </c:if> + <c:if test="${loop}"> + <![CDATA[&repeat=always]]> + </c:if> + <c:if test="${noPlayIcon}"> + <![CDATA[&icons=false]]> + </c:if> + <c:if test="${not empty skin}"> + <![CDATA[&skin=${skin}]]> + </c:if> + <c:if test="${thumbnail and !empty preview}"> + <![CDATA[&image=${preview}]]> + </c:if> + <c:if test="${share}"> + <c:set var="sharinglink">${baseUrl}${actpage.handle}.html</c:set> + <c:set var="sharingcode"> + <embed src="${baseUrl}/.resources/media/players/player.swf" + flashvars="file=${fn:startsWith(url, 'http')? '' : baseUrl}${url}" width="${width}" height="${height}" /> + </c:set> + <![CDATA[&plugins=sharing-1]]> + <![CDATA[&sharing.link=${sharinglink}]]> + <![CDATA[&sharing.code=${fn:escapeXml(sharingcode)}]]> + </c:if> + </c:set> + <media:swfobject player="${player}" width="${width}" height="${height}" allowfullscreen="true" + allowscriptaccess="always" wmode="opaque" flashvars="${flashvars}" /> + </c:otherwise> + </c:choose> </c:if> </jsp:root> \ No newline at end of file Modified: trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/swfobject.tag =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/swfobject.tag 2010-02-13 22:12:21 UTC (rev 1921) +++ trunk/openutils-mgnlmedia/src/main/resources/META-INF/tags/media/swfobject.tag 2010-02-14 10:09:10 UTC (rev 1922) @@ -2,14 +2,15 @@ xmlns:cms="cms-taglib" xmlns:cmsfn="http://www.magnolia.info/tlds/cmsfn-taglib.tld" xmlns:cmsu="cms-util-taglib" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:media="http://net.sourceforge.openutils/mgnlMedia" xmlns:su="http://openutils.sf.net/openutils-stringutils"> - <jsp:directive.tag description="" pageEncoding="UTF-8" /> - <jsp:directive.attribute name="player" required="true" rtexprvalue="true" type="java.lang.String" - description="the swf file of the player (examples: player.swf (default), jwplayer4, jwplayer5, jwplayer5/player.swf, /.resources/media/players/jwplayer5/player.swf)" /> - <jsp:directive.attribute name="width" required="false" rtexprvalue="true" type="java.lang.Integer" - description="flash content width" /> - <jsp:directive.attribute name="height" required="false" rtexprvalue="true" type="java.lang.Integer" - description="flash content height" /> + <jsp:directive.tag pageEncoding="UTF-8" description="Renders the flash-content and the javascript for replacing it" /> + <jsp:directive.attribute name="player" required="true" rtexprvalue="true" type="java.lang.String" description="the swf file of the player (examples: player.swf (default), jwplayer4, jwplayer5, jwplayer5/player.swf, /.resources/media/players/jwplayer5/player.swf)" /> + <jsp:directive.attribute name="width" required="false" rtexprvalue="true" type="java.lang.Integer" description="flash content width" /> + <jsp:directive.attribute name="height" required="false" rtexprvalue="true" type="java.lang.Integer" description="flash content height" /> <jsp:directive.tag dynamic-attributes="attrs" /> + <!-- end attributes --> + + + <c:set var="debug" value="${false}"/><!-- set to true to print out the generated javascript on page --> <c:set var="previewId" value="preview-${su:randomAlphanumeric(6)}" /> <div id="${previewId}" class="preview"><!-- --> </div> @@ -47,4 +48,23 @@ swfobject.write('${previewId}'); }]]> </script> + <c:if test="${debug}"> + <pre> + <![CDATA[ + var swfobject = new SWFObject('${playerPath}','player','${width}','${height}','9','#ffffff');]]> + <c:forEach var="attr" items="${attrs}"> + <c:if test="${!empty attr.value}"> + <![CDATA[ + swfobject.addParam('${attr.key}','${attr.value}');]]> + </c:if> + </c:forEach> + <![CDATA[ + var version = deconcept.SWFObjectUtil.getPlayerVersion(); + if (!(version["major"] == 0 || version["major"] < 9)) { + swfobject.write('${previewId}'); + }]]> + </pre> + </c:if> + + </jsp:root> \ No newline at end of file Modified: trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_en.properties =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_en.properties 2010-02-13 22:12:21 UTC (rev 1921) +++ trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/lang/messages_en.properties 2010-02-14 10:09:10 UTC (rev 1922) @@ -26,7 +26,7 @@ media.dialogs.tabDocument.label=Document media.dialogs.tabDocument.document.label=File -media.dialogs.tabVideo.videoUrl.label=External video url +media.dialogs.tabVideo.videoUrl.label=External video url (flv absolute url or youtube url) media.dialogs.tabTitle.label=Title This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |