You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by drobson <dr...@gammatelecom.com> on 2010/06/17 18:26:19 UTC

Integration of Jplayer and Wicket

Hi,

Im trying to integrate Jplayer and wicket to allow me to create a MP3
playing component in wicket. But I seem to be running into a problems with
the way I access MP3 files. The HTML and Javascript  generated by wicket at
runtime seems to be right but I get a Javascript error "Not allowed to load
local resource". If I simply take the generated code and create a html file
from it the MP3 file plays and I get no JS error. 

Your help would be much appreciated. 

Java/Wicket
----------------

public class DisplayMP3 extends WebPage
{
	public DisplayMP3()
	{
		
	}
	
	
	@Override
	public void renderHead(HtmlHeaderContainer container) 
	{
		final ResourceReference jPlayer2 =
		      new ResourceReference(DisplayMP3.class,"jquery.min.js");
		
		final ResourceReference jPlayer =
		      new ResourceReference(DisplayMP3.class,"jquery.jplayer.min.js");
		
	
		
		container.getHeaderResponse().renderJavascriptReference(jPlayer2); 
		container.getHeaderResponse().renderJavascriptReference(jPlayer); 
		
		String js = "$(document).ready(function(){$(\"#jpId\").jPlayer({ ready:
function () { " +
				"this.element.jPlayer(\"setFile\", \"C:/Documents and
Settings/drobson/My
Documents/workspace/OrangeTest/context/WEB-INF/music/Honeytrap.mp3\");
this.play();}})});";		
		
        container.getHeaderResponse().renderJavascript(js, null);
        
	}
	
}

HTML
-------------

<html>
<wicket:head>
</wicket:head>
<body>
  <div id="jpId"></div>
</body>
</html>


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Integration-of-Jplayer-and-Wicket-tp2259121p2259121.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Re: Integration of Jplayer and Wicket

Posted by drobson <dr...@gammatelecom.com>.
I've been able to get the player working by putting the MP3 on the classpath.
Its is now available from the address
http://localhost/MyApp/resources/com.gamma.tele.OrangeMP3.DisplayMP3/HoneyTrap.mp3
but the problem with this is i want to be able to access MP3s without having
to add them to the classpath. Possibly have the program pickup MP3 whenever
they are added to a music folder. 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Integration-of-Jplayer-and-Wicket-tp2259121p2259908.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Re: Integration of Jplayer and Wicket

Posted by Steve Mactaggart <st...@whitesquaresoft.com>.
It would need to be served from the server and not accessed locally.

If you look at the source of the HTML when generated from the server version
and it has a Local path, then the browser won't access that file as it is
outside the security sandbox.  If the server can read the file from disk
then it can stream it down to the browser and it should play.

There might be a way to change the security settings in the browser, but in
any case this is problem with wicket.

On Fri, Jun 18, 2010 at 6:18 PM, drobson <dr...@gammatelecom.com> wrote:

>
> How do I allow the server to pick it up. Is there a certain method to do
> this
> securely?
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Integration-of-Jplayer-and-Wicket-tp2259121p2259859.html
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>

Re: Integration of Jplayer and Wicket

Posted by drobson <dr...@gammatelecom.com>.
How do I allow the server to pick it up. Is there a certain method to do this
securely?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Integration-of-Jplayer-and-Wicket-tp2259121p2259859.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Re: Integration of Jplayer and Wicket

Posted by Jeremy Thomerson <je...@wickettraining.com>.
I don't know, but I suspect it's a security issue.  If you save your HTML to
a plain file on the file system, then it is a local resource, and it can
access other local files.  But, coming from a webserver, it is not allowed
to play local files.

Just a guess.

On Thu, Jun 17, 2010 at 11:26 AM, drobson <dr...@gammatelecom.com> wrote:

>
> Hi,
>
> Im trying to integrate Jplayer and wicket to allow me to create a MP3
> playing component in wicket. But I seem to be running into a problems with
> the way I access MP3 files. The HTML and Javascript  generated by wicket at
> runtime seems to be right but I get a Javascript error "Not allowed to load
> local resource". If I simply take the generated code and create a html file
> from it the MP3 file plays and I get no JS error.
>
> Your help would be much appreciated.
>
> Java/Wicket
> ----------------
>
> public class DisplayMP3 extends WebPage
> {
>        public DisplayMP3()
>        {
>
>        }
>
>
>        @Override
>        public void renderHead(HtmlHeaderContainer container)
>        {
>                final ResourceReference jPlayer2 =
>                      new
> ResourceReference(DisplayMP3.class,"jquery.min.js");
>
>                final ResourceReference jPlayer =
>                      new
> ResourceReference(DisplayMP3.class,"jquery.jplayer.min.js");
>
>
>
>
>  container.getHeaderResponse().renderJavascriptReference(jPlayer2);
>
>  container.getHeaderResponse().renderJavascriptReference(jPlayer);
>
>                String js =
> "$(document).ready(function(){$(\"#jpId\").jPlayer({ ready:
> function () { " +
>                                "this.element.jPlayer(\"setFile\",
> \"C:/Documents and
> Settings/drobson/My
> Documents/workspace/OrangeTest/context/WEB-INF/music/Honeytrap.mp3\");
> this.play();}})});";
>
>        container.getHeaderResponse().renderJavascript(js, null);
>
>        }
>
> }
>
> HTML
> -------------
>
> <html>
> <wicket:head>
> </wicket:head>
> <body>
>  <div id="jpId"></div>
> </body>
> </html>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Integration-of-Jplayer-and-Wicket-tp2259121p2259121.html
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>



-- 
Jeremy Thomerson
http://www.wickettraining.com