/* 
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. 
 * 
 * This file is available and licensed under the following license:
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice, 
 *     this list of conditions and the following disclaimer.
 *
 *   * Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *   * Neither the name of Sun Microsystems nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software 
 *     without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.sun.javafx.mediabox;

import javafx.stage.*;
import javafx.scene.*;
import com.sun.javafx.mediabox.MediaBox;

/**
 * @author baechul
 */

var index = 0;
var media = [
    "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_2956241001_big-buck-bunny-640x360.flv",
    "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_11657401001_09b01828-11.flv",
    "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_11810873001_09c01923-00.flv"
];

var theme = getFXArgString("theme", "paranara");
var mediaUrl = getFXArgString("mediaURL", media[0]);
var mediaViewWidth = getFXArgInt("mediaViewWidth", 640);
var mediaViewHeight = getFXArgInt("mediaViewHeight", 360);
var mediaTitle = getFXArgString("mediaTitle", "");
var mediaDescription = getFXArgString("mediaDescription", "");

var mediaBox: MediaBox = MediaBox {
    // media and play variables
    mediaSource: mediaUrl
    mediaTitle: if(mediaUrl == media[0]) "Big Buck Bunny" else mediaTitle
    mediaDescription: if(mediaUrl == media[0])
        "A well-tempered rabbit finds his day spoiled by the rude actions of the..."
        else mediaDescription
    autoPlay: true             // default: false
    preserveRatio: true        // default: true
    
    // size and layout position
    width: bind mediaBox.scene.width
    height: bind mediaBox.scene.height
    layoutX: 0;
    layoutY: 0;

    // view
    themeStr: theme             // default: "paranara"
    mediaControlBarHeight: 25   // default: 25, possible values: 20~50
    showMediaInfo: true         // default: true

    // function variables
    onEndOfMedia: function() {
        index++;
        index = index mod sizeof media;
        mediaBox.mediaSource = media[index];
    }
    onMouseClicked: function(me) {
        index++;
        index = index mod sizeof media;
        mediaBox.mediaSource = media[index];
    }
}

Stage {
    title: "MediaBox Player"
    resizable: true

    scene: Scene {
        width: getFXArgInt("mediaViewWidth", 640)
        height: getFXArgInt("mediaViewHeight", 360)
        content: mediaBox
    }
}

mediaBox.requestFocus();

// helper functions
function getFXArgString(arg:String, defaultValue:String): String {
    var val = FX.getArgument(arg);
    if (val == null) {
        return defaultValue;
    }
    return val as String;
}

function getFXArgInt(arg:String, defaultValue:Integer): Integer {
    var val = FX.getArgument(arg);
    if (val == null) {
        return defaultValue;
    }
    try {
        return Integer.parseInt(val as String);
    } catch (nfe: java.lang.NumberFormatException) {
        return defaultValue;
    }
}
JavaFX Sample

/* 
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. 
 * 
 * This file is available and licensed under the following license:
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright notice, 
 *     this list of conditions and the following disclaimer.
 *
 *   * Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *   * Neither the name of Sun Microsystems nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software 
 *     without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.sun.javafx.mediabox;

import javafx.stage.*;
import javafx.scene.*;
import com.sun.javafx.mediabox.MediaBox;

/**
 * @author baechul
 */

var index = 0;
var media = [
    "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_2956241001_big-buck-bunny-640x360.flv",
    "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_11657401001_09b01828-11.flv",
    "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_11810873001_09c01923-00.flv"
];

var theme = getFXArgString("theme", "paranara");
var mediaUrl = getFXArgString("mediaURL", media[0]);
var mediaViewWidth = getFXArgInt("mediaViewWidth", 640);
var mediaViewHeight = getFXArgInt("mediaViewHeight", 360);
var mediaTitle = getFXArgString("mediaTitle", "");
var mediaDescription = getFXArgString("mediaDescription", "");

var mediaBox: MediaBox = MediaBox {
    // media and play variables
    mediaSource: mediaUrl
    mediaTitle: if(mediaUrl == media[0]) "Big Buck Bunny" else mediaTitle
    mediaDescription: if(mediaUrl == media[0])
        "A well-tempered rabbit finds his day spoiled by the rude actions of the..."
        else mediaDescription
    autoPlay: true             // default: false
    preserveRatio: true        // default: true
    
    // size and layout position
    width: bind mediaBox.scene.width
    height: bind mediaBox.scene.height
    layoutX: 0;
    layoutY: 0;

    // view
    themeStr: theme             // default: "paranara"
    mediaControlBarHeight: 25   // default: 25, possible values: 20~50
    showMediaInfo: true         // default: true

    // function variables
    onEndOfMedia: function() {
        index++;
        index = index mod sizeof media;
        mediaBox.mediaSource = media[index];
    }
    onMouseClicked: function(me) {
        index++;
        index = index mod sizeof media;
        mediaBox.mediaSource = media[index];
    }
}

Stage {
    title: "MediaBox Player"
    resizable: true

    scene: Scene {
        width: getFXArgInt("mediaViewWidth", 640)
        height: getFXArgInt("mediaViewHeight", 360)
        content: mediaBox
    }
}

mediaBox.requestFocus();

// helper functions
function getFXArgString(arg:String, defaultValue:String): String {
    var val = FX.getArgument(arg);
    if (val == null) {
        return defaultValue;
    }
    return val as String;
}

function getFXArgInt(arg:String, defaultValue:Integer): Integer {
    var val = FX.getArgument(arg);
    if (val == null) {
        return defaultValue;
    }
    try {
        return Integer.parseInt(val as String);
    } catch (nfe: java.lang.NumberFormatException) {
        return defaultValue;
    }
}