Forums de discussion

portlet:ResourceUrl and flash mp3 player

thumbnail
Marc de Frutos Murgadella, modifié il y a 14 années.

portlet:ResourceUrl and flash mp3 player

New Member Publications: 4 Date d'inscription: 05/01/10 Publications récentes
Hi everyone,

I have a portlet with a resourceUrl that successfully serves a dynamic mp3 file outside the Application Server's scope. I can download that mp3 and listen to it. Buut, now I'm trying to get that mp3 to work with an flash mp3 player.

The flash mp3 player works perfectly with a static file :


<object type="application/x-shockwave-flash" data="<%=request.getContextPath()%>/player2/player_mp3.swf" width="200" height="20">
	<param name="movie" value="<%=request.getContextPath()%>/player2/player_mp3.swf">
	<param name="FlashVars" value="mp3=<%=request.getContextPath()%>/staticAudioFile.mp3">
</object>	


But I can't seem to make it work together with the file served by the resourceUrl:


<portlet:resourceurl var="audioMp3Url">
	<portlet:param name="resourceName" value="RESOURCE_MP3_NAME"></portlet:param>
</portlet:resourceurl>

<a href="${audioMp3Url}">
	<liferay-ui:message key="mp3-file"></liferay-ui:message>
</a>


<object type="application/x-shockwave-flash" data="<%=request.getContextPath()%>/player2/player_mp3.swf" width="200" height="20">
	<param name="movie" value="<%=request.getContextPath()%>/player2/player_mp3.swf">
	<param name="FlashVars" value="mp3=${audioMp3Url}">
</object>		


I've set a couple of breakpoints inside the serveResource and I seem to be getting in with the link but not with the player.

Any suggestions ?
thumbnail
Tomas Polesovsky, modifié il y a 14 années.

RE: portlet:ResourceUrl and flash mp3 player

Liferay Master Publications: 676 Date d'inscription: 13/02/09 Publications récentes
Hi,

did you try to use FireBug or something similar to verify that flash requested the resource using correct address?

-- tom
thumbnail
Marc de Frutos Murgadella, modifié il y a 13 années.

RE: portlet:ResourceUrl and flash mp3 player

New Member Publications: 4 Date d'inscription: 05/01/10 Publications récentes
I eventually found out the answer on my own.

The problem is that Flash's Flashvars separates variables with an ampersand("&") and of course my resourceUrl was using someas well. The solution was escaping the url ...


<portlet:resourceurl var="audioMp3Url">
    <portlet:param name="resourceName" value="RESOURCE_MP3_NAME"></portlet:param>
</portlet:resourceurl>

<a href="${audioMp3Url}">
    <liferay-ui:message key="mp3-file"></liferay-ui:message>
</a>

&lt;%
    String audioMp3Url = pageContext.getAttribute("audioMp3Url");
    [color=#DC0000]String escapedURL = URLEncode.encode(audioMp3Url,"UTF-8");[/color]
%&gt;
<object type="application/x-shockwave-flash" data="<%=request.getContextPath()%>/player2/player_mp3.swf" width="200" height="20">
    <param name="movie" value="<%=request.getContextPath()%>/player2/player_mp3.swf">
    <param name="FlashVars" value="mp3=[color=#DC0000]<%=escapedURL %>[/color]">
</object>