Skip to main content

How to see Videos with the Java-Video player offline?

3 replies [Last post]
theuserbl
Offline
Joined: 2004-05-04

In the an Internetcafé I have tried out the video-example on JavaFX.com on
http://www.javafx.com/samples/SimpleVideoPlayer/index.html
and it works well. Also the videos on that side at
http://www.javafx.com/launch/win-player.jsp
works ok.

But how can I run the video player at home (where I have no internet connection) offline? It is part of the examples of JavaFX 1.0 SDK.

Here what I have tries out:

-----------------------------------------------------------------

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart>dir
Datenträger in Laufwerk F: ist Daten
Volumeseriennummer: 0C1D-97E4

Verzeichnis von F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart

01.01.2003 01:04 .
01.01.2003 01:04 ..
01.01.2003 00:41 lib
01.01.2003 00:50 89 SimpleVideoPlayer.bat
25.11.2008 16:12 4.755 SimpleVideoPlayer.jar
25.11.2008 16:12 781 SimpleVideoPlayer.jnlp
25.11.2008 16:12 858 SimpleVideoPlayer_browser.jnlp
01.01.2003 00:07 z
4 Datei(en) 6.483 Bytes
4 Verzeichnis(se), 41.745.842.176 Bytes frei

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart>type SimpleVideoPlaye
r.bat
@echo off
javafx -cp SimpleVideoPlayer.jar;lib\mediacomponent.jar simplevideoplayer.Main
F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart>SimpleVideoPlayer.bat

using mediaUrl = http://capra.sfbay.sun.com/~jm158417/javafx_videos/big_buck_bun
ny_512x288_h264.flv
com.sun.javafx.runtime.AssignToBoundException: Cannot mutate bound sequence
Before Media object creation.
Error with Media: MediaError: media unavailable:com.sun.media.jmc.MediaUnavailab
leException: Media unavailable: http://capra.sfbay.sun.com/~jm158417/javafx_vide
os/big_buck_bunny_512x288_h264.flv
After Media object creation: 265
Before MediaPlayer object creation.
Error with MediaPlayer: MediaError: media unavailable:com.sun.media.jmc.MediaUna
vailableException: Media unavailable: http://capra.sfbay.sun.com/~jm158417/javaf
x_videos/big_buck_bunny_512x288_h264.flv
After MediaPlayer object creation.

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart>cd z

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z>dir
Datenträger in Laufwerk F: ist Daten
Volumeseriennummer: 0C1D-97E4

Verzeichnis von F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z

01.01.2003 00:07 .
01.01.2003 00:07 ..
01.01.2003 01:25 3.373 Main.fx
05.12.2008 21:06 18.133.182 video.flv
2 Datei(en) 18.136.555 Bytes
2 Verzeichnis(se), 41.745.842.176 Bytes frei

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z>type Main.fx
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
* Copyright 2008 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" A
ND
* 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 F
OR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGE
S
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N
* 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.
*/

import javafx.stage.Stage;
import javafx.scene.Scene;
import com.sun.fxmediacomponent.*;
import javafx.scene.Group;

def mediaUrl:String ="video.flv";
println("using mediaUrl = {mediaUrl}");
var vidWidth = 512;
var vidHeight = 288;
var fullWidth = 700;
var fullHeight = 400;

var mediaBox:MediaComponent = MediaComponent {

// set the media and make the component visible
mediaSourceURL : bind mediaUrl
visible:true

// the position and size of the media on screen
mediaX: (fullWidth-vidWidth)/2 // center
mediaY: (fullHeight-vidHeight)/2 // center
mediaViewWidth : vidWidth
mediaViewHeight: vidHeight
mediaVisible: true

// determines if the control bar is visible at all
controlBarVisible: true

// determines if the control bar is below the media or on top with a fade in

staticControlBar: false

// the position of the scroll bar.
//leave as the defaults to have it be below the media
//controlBarX: -1
//controlBarY: -1

// set the size for full screen.
// useful if you have extra component on the side which you turn off
// to cover with video in the full screen mode.
fullScreenWidth: fullWidth
fullScreenHeight: fullHeight
//fullScreen: true

// make the movie play as soon as it's loaded
mediaPlayerAutoPlay: true

// set the volume
volume: 0.5
};

Stage {
title: "Simple Media Player"
scene: Scene{
width: fullWidth
height: fullHeight
content: mediaBox
}
}

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z>javafxc -cp ..\lib\mediacomponent.jar Main.fx

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z>javafx -cp .;..\lib\mediacomponent.jar Main
using mediaUrl = video.flv
com.sun.javafx.runtime.AssignToBoundException: Cannot mutate bound sequence
Before Media object creation.
Error with Media: MediaError: unknown:java.lang.NullPointerException
After Media object creation: 63
Before MediaPlayer object creation.
Error with MediaPlayer: MediaError: unknown:java.lang.NullPointerException
After MediaPlayer object creation.

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z>java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

F:\JavaFX\javafx-sdk1.0\samples\SimpleVideoPlayer\webstart\z>

-------------------------------------------------------------

It opens everytime a window, but the video don't start. It seems, that it don't find the video. But how can I say, where my local video-file is, if it is not a http:// address?

Greatings
theuserbl

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sargeras
Offline
Joined: 2008-12-20

If the video file at the current classpath, you can use:

def mediaUrl:String =java.lang.ClassLoader.getSystemResource("video.flv").toString();

to get the url;

or if the video file at c:\video.flv, you can use the "file:/c:/video.flv" locate it.

alexsch
Offline
Joined: 2007-07-12

If a video file at the same directory where is an fx file, you can use the __DIR__ variable:

def mediaUrl = "{__DIR__}video.flv";

aski
Offline
Joined: 2007-06-27

I may being able to answer your question. To check it, I need a test video file in flv format. Can you send me a link to download such a test video file (in flv format)?
Greeting from NRW
Asghar