Yet another blog about WPF, Surface, SL, MVVM, NUI....

2011

2010

2009

2008

Tag - Netbeans

Entries feed - Comments feed

 

You could use the JavaFX Media Component.... Yes but where is it ?

8 December 2008

Have you been trying all the wonderful demo on on the JavaFX web site ? Yes ? Me too !

You can try the "Simple Video Player" for example :

Simple Video Player sample

It's great but when I tried to reproduce the video player i meet a little problem.

It tells "You could use the JavaFX Media Component, a prefabricated video player in the com.sun.fxmediacomponent package."... But where is it ? I Just cannot find it on the web...

You then have two solutions:

  1. Download the source code and use the jar file present in the lib folder,
  2. Reproduce this package by your own implementations...

I really prefere the second solutions and I will make a little How-To in a future posts to tell you how to do...

++

 

Deploy a JavaFX app as an applet with the Java Deployement Toolkit... (Updated twice)

Yesterday I tried to write my first JavaFX... I Found it quite easy.... It's name was "VideoPlayer".

But when I tried to put it on a web page and deploy it as an java Applet it became a Nightmare !

First I tried to use the code Netbeans give me in my 'dist' folder... It worked well on my computer but not when I putted it on my web site...

I notice then that it was trying to load the JNLP from this host: "http://localhost:8093/servlet/org.netbeans.modules.javafx.project.JnlpDownloadServlet/"... It was the problem !

So I change my "VideoPlayer_browser.jnlp" and change the host by the one of my webSite : "http://www.lexique-du-net.com/javafx/videoPlayer/". It then look like this :

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://www.lexique-du-net.com/javafx/videoPlayer/" href="VideoPlayer_browser.jnlp">
    <information>
        <title>VideoPlayer</title>
        <vendor>Jonathan ANTOINE</vendor>
        <homepage href="http://www.lexique-du-net.com/javafx/videoPlayer/"/>
        <description>VideoPlayer</description>
        <offline-allowed/>
        <shortcut>
            <desktop/>
        </shortcut>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <j2se version="1.5+"/>
        <extension name="JavaFX Runtime" href="http://dl.javafx.com/javafx-rt.jnlp"/>
        <jar href="VideoPlayer.jar" main="true"/>
    </resources>
    <applet-desc name="VideoPlayer" main-class="com.sun.javafx.runtime.adapter.Applet" width="384" height="288">
        <param name="MainJavaFXScript" value="videoplayer.Main">
    </applet-desc>
</jnlp>

It then worked well !

I also give you what to put in your HTML page :

javafx(
        {
              archive: "VideoPlayer.jar",
              draggable: true,
              width: 384,
              height: 306,
              code: "fr.antoinej.videoplayer.Main",
              name: "VideoPlayer"
        },
        {
	      isApplet: true
	 }
    );

I some params (isApplet: true) to tell my apps that it is an applet....

An other interesting thing you can add on you HTML page is to add thie next snippet in the header part. It will reload you JNLP files and do not use the cache each time you will load the page... Better when adding frequently features to you application...

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">

Update (21/12/2008): You can now find a tutorials on the JavaFx webSite : here !

+++