Playing LOCAL video with Java FX

Hello,
I'm trying to make a media player with Java FX.
I have downloaded the next example (BasicMoviePlayer)
[http://jfxtras.org/portal/pro-javafx-platform/-/asset_publisher/1Bl5/content/16700?redirect=%2Fportal%2Fpro-javafx-platform|http://jfxtras.org/portal/pro-javafx-platform/-/asset_publisher/1Bl5/content/16700?redirect=%2Fportal%2Fpro-javafx-platform]
and now I want to play a local video.
Anybody knows how to do this?
Thank you very much!

For example:
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.media.*;
var source = "C:/Movie/big-buck-bunny-640x360.flv";
Stage {
    title: "Simple Video Player"
    scene: Scene {
        width: 640
        height: 360
        content: [
            MediaView {
                preserveRatio: true
                mediaPlayer: MediaPlayer {
                    autoPlay: true
                    media: Media {
                        source: source
}

Similar Messages

  • How can I play different videos with only one MediaPlayer?

    I want to play two videos with only one MediaPlayer:
    private static MediaPlayerBuilder mpB;
    private static Media mLogo;
    private static Media mSaludo;
    private static MediaPlayer mpLogo;
    private static MediaView mvLogo;
    private static Group gLogo;
    public void start(final Stage stage) {
    mLogo = MediaBuilder.create().source(myGetResource(VIDEOLOGO_PATH)).build();
    mSaludo = MediaBuilder.create().source(myGetResource(VIDEOSALUDO_PATH)).build();
    mpB = MediaPlayerBuilder.create();
    mpLogo = mpB.media(mLogo).build();
    mvLogo = MediaViewBuilder.create().mediaPlayer(mpLogo).build();
    gLogo.getChildren().add(mvLogo);
    sActual = new Scene(gPozos, WIDTH, HEIGHT, Color.BLACK);
    stage.setScene(sActual);
    stage.show();When I want to play mLogo:
    sActual.setRoot(gLogo);
    mpLogo.play();Then, when I want to play mSaludo I do this:
    mpLogo = mpB.media(mSaludo).build();
    sActual.setRoot(gLogo);
    mpLogo.play();or this:
    mpB.media(mSaludo).applyTo(mpLogo);
    sActual.setRoot(gLogo);
    mpLogo.play();or this:
    mpB.media(mSaludo);
    sActual.setRoot(gLogo);
    mpLogo.play();But is impossible to change the Media. It doesn't work. Sometimes I play mLogo video and sometimes (depends on the code) the video mLogo doesn't start and I see an image of the first keyframe and nothing else. I have no exceptions, no errors, nothing.
    I want to play mLogo and then mSaludo. How can I do this?
    Thanks
    Noelia

    Ok, I understand, if I have 100 videos I have to build 100 MediaPlayers but only one MediaView.
    Here I post my code with only two videos, I included all the asynchronous errors.
    package pruebafx;
    import java.util.logging.FileHandler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaErrorEvent;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.MediaView;
    import javafx.stage.Stage;
    * @author Solange
    public class PruebaFX extends Application {
        private static final Logger logger = Logger.getLogger("pruebafx.pruebafx");
        private static final String MEDIA_PATH = "/images/";
        private static final String VIDEOLOGO_PATH = MEDIA_PATH + "logo.flv";
        private static final String VIDEOSALUDO_PATH = MEDIA_PATH + "saludo.flv";
        private static Group root;
        private static Scene scene;
        private static MediaPlayer mpLogo;
        private static MediaPlayer mpSaludo;
        private static Media mLogo;
        private static Media mSaludo;
        private static MediaView mediaView;
         * @param args the command line arguments
        public static void main(String[] args) {
            Application.launch(args);
        @Override
        public void start(Stage primaryStage) {
            try {
                FileHandler fh = new FileHandler("DisplayManagerlog-%u-%g.txt", 100000, 100, true);
                // Send logger output to our FileHandler.
                logger.addHandler(fh);
                // Request that every detail gets logged.
                logger.setLevel(Level.ALL);
                // Log a simple INFO message.
                logger.info("Starting PruebaFX");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            primaryStage.setTitle("Change Videos");
            root = new Group();
            mLogo = new Media(myGetResource(VIDEOLOGO_PATH));
            mSaludo = new Media(myGetResource(VIDEOSALUDO_PATH));
            mpLogo = new MediaPlayer(mLogo);
            mpSaludo = new MediaPlayer(mSaludo);
            mediaView = new MediaView(mpLogo);
            mpLogo.setOnEndOfMedia(new Runnable() {
                public void run() {
                    mpLogo.stop();
                    mediaView.setMediaPlayer(mpSaludo);
                    mpSaludo.play();
            mpSaludo.setOnEndOfMedia(new Runnable() {
                public void run() {
                    mpSaludo.stop();
                    mediaView.setMediaPlayer(mpLogo);
                    mpLogo.play();
            mLogo.setOnError(new Runnable() {
                public void run() {
                    logger.severe("Error en Media mLogo");
            mSaludo.setOnError(new Runnable() {
                public void run() {
                    logger.severe("Error en Media mSaludo");
            mpLogo.setOnError(new Runnable() {
                public void run() {
                    logger.severe("Error en MediaPlayer mpLogo");
            mpSaludo.setOnError(new Runnable() {
                public void run() {
                    logger.severe("Error en MediaPlayer mpSaludo");
            mediaView.setOnError(new EventHandler<MediaErrorEvent>() {
                public void handle(MediaErrorEvent t) {
                    logger.severe("Error en MediaView mediaView");
                    logger.severe(t.getMediaError().getMessage());
            root.getChildren().addAll(mediaView);
            scene = new Scene(root, 300, 250);
            primaryStage.setScene(scene);
            primaryStage.show();
            mpLogo.play();
        public String myGetResource(String path) {
            return (this.getClass().getResource(path).toString());
    }My video saludo.flv hangs up.
    Here is the content of the log file:
    <?xml version="1.0" encoding="windows-1252" standalone="no"?>
    <!DOCTYPE log SYSTEM "logger.dtd">
    <log>
    <record>
    <date>2011-12-12T12:03:53</date>
    <millis>1323702233578</millis>
    <sequence>0</sequence>
    <logger>pruebafx.pruebafx</logger>
    <level>INFO</level>
    <class>pruebafx.PruebaFX</class>
    <method>start</method>
    <thread>12</thread>
    *<message>Starting PruebaFX</message>*
    </record>
    <record>
    <date>2011-12-12T12:04:06</date>
    <millis>1323702246109</millis>
    <sequence>1</sequence>
    <logger>pruebafx.pruebafx</logger>
    <level>SEVERE</level>
    <class>pruebafx.PruebaFX$6</class>
    <method>run</method>
    <thread>12</thread>
    *<message>Error en MediaPlayer mpSaludo</message>*
    </record>
    <record>
    <date>2011-12-12T12:04:06</date>
    <millis>1323702246109</millis>
    <sequence>2</sequence>
    <logger>pruebafx.pruebafx</logger>
    <level>SEVERE</level>
    <class>pruebafx.PruebaFX$4</class>
    <method>run</method>
    <thread>12</thread>
    *<message>Error en Media mSaludo</message>*
    </record>
    </log>
    Do you know when will be available the 2.0.2 version???
    I have to finish my application!!!
    Thanks.
    Noelia

  • On Windows 7, Itunes 64-bit is playing all videos with a green overlay

    On Windows 7, Itunes 64-bit is playing all videos with a green overlay. You can see the video, but it's all green-scale (like grey-scale, only green). I've tried setting the Quicktime Direct3D options per Apple knowledge base articles, but to no avail... Windows 7 is all up to date, and I have the latest video drivers installed.
    The videos play perfectly in Quicktime (32-bit; I guess there isn't a 64-bit Quicktime?).
    Here's a screenshot:
    I'd love to get this fixed; it's really baffling and annoying.

    I had the same problem and surfed around the internet like a maniac. Finally, after several re-openings and re-installs of iTunes, I tried to log on to my account through the "Genius" - which I could. After that I have not had any problems to go to the Store!
    Hope it works for you too!

  • HT3775 how do you play a video with this format/title DVDSCR XViD AC3-sC0rp?

    How do you play a video with this format " DVDSCR XViD AC3-sC0rp" using quicktime?

    Try this. It can handle formats Quicktime can't:
    VLC

  • HT204382 I want to play a video with an .avi format

    I want to play a video with an .avi format for the first time on my iMac v. 10.8. ..I downloaded DivX but still no go. Suggestions?

    Try http://www.iskysoft.com/topic-snow-leopard/how-to-play-avi-with-quicktime-on-mac .html
    Allan

  • Play local videos one after the other

        Hi - I'm setting up 10 videos locally in Dreamweaver to play one after the other.  By local I mean everything is on a the computer and you just open up the HTML page in Chrome and it works.  When the HTML opens in Chrome, I got the first video to auto play and loop too.  But after video #1 ends, I need it for the 2nd video to start, then third, and so on until the 10th is over then it goes back to #1 again.
    The code I have on the local HTML page is and it works for one video is:
    <video width="720" height="406" controls autoplay loop>
      <source src="1E.mp4" type="video/mp4">
      <object data="1E.mp4" width="720" height="406">
      </object>
    </video>
    ...but I just can't figure out how to get the other 9 videos in there so they play after #1 then loop back to #1 again.
    Does anyone have any idea how to do this?  Thanks.

    Hooking up the computer to the TV is the easy part :-)
    I tried getting a windows media playlist set up and although I like that player, it seemed difficult to make a simple playlist in it.  Unless I wasn't reading the instructions correctly, I couldn't get it to work.
    I also like QT but it seems like you need to buy the QT Pro version as the basic player doesn't seem to allow for playlists (unless i'm missing something).
    If I could get either of the above to work and play these videos locally over and over I'm set.  But because I had problems with WMV and you have to pay for QT Pro that's why I'm trying to build something locally in DW.

  • When I play any video with any player, it stops after few minutes

    When I want to play any video it stops after few minutes as freeze. Sometimes it continues without sound and others stops completly. I try to play it with more than one players, but same.
    The video it's .mkv
    I tried with:
    - Quicktime X with Perian
      - MplayerX
      - Mplayer OS X Extended

    You should probably take it to the closest apple retail store and have someone at the genuis bar help you. If you dont want to do that you should probably purchase a software or use a free trail version of one to run a virus check.Ive found that Mcfee is a good virus scan program.

  • Itunes does not work when I want to play Mp4 videos with most recent versions

    When I want to play videos with mp4 format on itunes, it does not do anything and I have to close itunes with the windows system manager. Does any one know how to solve this problem? I did not have this isue with 10.5 and previous versions of itunes.

    I found the solution, the problem was the encoding of the configuration files.
    I put:
    => Encoding: UTF8 without signature
    => line endings: UNIX(LF)
    And now it works :)

  • Chaning the locale languge with Java

    Hi All
    I want to change the display language in Locale with Java Code.
    I tried this Locale.setDefault(Locale.FRENCH);
    When I print following command :
    logger.debug("DEF LOCALE Now :: " + Locale.getDefault());
    then it shows me
    "fr" but still I am seeing display language as English not French.
    Am I missing anything, please correct me.
    To add one more thing:
    I am printing the value of getDisplayLanguage then it shows me the following results
    Language = anglais
    But still I am seeing JSP in English.

    JUST_YOU wrote:
    I want to change the display language in Locale with Java Code.
    But still I am seeing JSP in English.I don't know anything about JSP but that certainly seems nonsensical to me.
    JSP is a server feature. You can certainly change the locale of the server VM but it would have nothing to do with display.
    Conversely if you want to display different languages in JSP to different users (clients) then that certainly makes sense. But that has nothing to do with changing the default locale for the server.
    [http://java.sun.com/developer/technicalArticles/Intl/MultilingualJSP/]

  • Playing .mov video with flvPlayback

    I have some .mov files I need to play with the flvPlayback component. When I had them in my actionscript it does not work. I've read allot and it says that the component will play mov video but it does not for me.
    I am running CS4 with FlashPlayer 10 and AS3.
    Any suggestions?

    There are many different types of .mov files. I think that flvPlayback can only play .mov files that have been encoded with the H.264 codec. So if you have Quicktime open the mov file with that and check the information for what codec was used on the video stream.

  • Only play local songs with iTunes Match?

    Hey,
    I have iTunes Match set up. It all working well. Except on my MacBook Pro, when I play my library in shuffle I expect it to only play the songs that are locally stored, but instead it keeps downloading new tracks from iCloud. Which interrupts my listening while it buffers and gets the song. Not only that it uses up my storage on my MBP. I only want select songs on here with my whole library being on my desktop.
    Is there a way to only play local songs? Short of tunring iTunes Match off and on everytime I want to get more songs.
    Thanks,
    J.

    Yeah, try a Smart Playlist with this criteria:

  • How can i play a video with dv4 format?

    i need to view a cctv video because my imac got stolen and it was caught on camera. I retrieved the file from the cctv but unable to play the video on my macbook pro as the format is in dv4. what application can i download to help me view it? pleaase help. Thanks

    The last post in this thread might help.
    https://discussions.apple.com/thread/3782011

  • Playing WMV videos with VLC

    On my iPad I have VLC Media Player which allows me to play WMV videos. I told some friends about this and they can't find it. I looked for it and can't find it either. 1) do you know where I might have gotten it, and 2) why can't I find it in the App Library?

    It's gone
    http://www.macnn.com/articles/11/01/07/move.said.to.be.related.to.licensing.disp ute/

  • AppleTV sound stuttering on playing local videos

    Is anyone having this problem? I have some mp4's (400 kbps) located inside AppleTV. I was able to play back with no issues a couple of weeks ago. Yesterday, when I ran the same video, the mp4's are played back with stuttering sound.
    I have the same issue while I was playing the movie trailers as well.
    Any thoughts?
    Cheerful_cal

    Having the same issue, but with all content, local, synced computer and web trailers. Did not happen when the apple tv was initially installed. I think I have to take it back into store. I see a number of threads on this issue.

  • FCP X viewer window plays back video with color errors

    I am new to Final Cut X and Final Cut PRo in general. I am doing a project at work where I needed to learn FCPX.
    I figured out a lot pretty fast. But one issue i am having is that all of the clips being played back in the viewer window are being played back with this weird color error. Its happens to movie clips, still photos and titles. See below, This is a screenshot of what it looks like. When I first installed FCP it wasn't doing this but now it started doing it all the time. Its annoying because I can't see the transitions properly, and sometimes video gets out of sync with audio.
    I am running Lion 10.7.1 with a Mac Pro 2 x 2.8ghx Quad Core Xeon. 16GB RAM. Nothing special on the HD's but they are at 7200rpm.
    I tried adjusting prefs for playback quality, I tried transcoding media. However, its doing this to a still frame jpeg as well, which should be giving the machine ay trouble. I feel like my machine should be able to keep up with FCPX.
    EDIT: I also restarted my machine a bunch of times and killed all processes that weren't necessary for the machine to run and for FCP to be working. I also have an NVIDIA GeForce 8800 GT graphics card, which meets the requirements for FCP X.

    I am also seeing the same issue. I have an Eizo Display and if I color correct with the i1 it behaves as above. It has been driving me crazy. If I switch back to standard profile it seems to work but my dislplay is not color calibrated. Is there a fix?

Maybe you are looking for

  • Nvidia 8600M GT GPU (no clue what this thing is) issues - please explain

    what is this exactly? well, whatever it is, someone told me this is why my MBP is in shop right now! screen went totally black lastnight with the computer running fine and normal. if this Nvidia thing is truly the problem and damaged, is this a big d

  • Can I safely delete the contents of Content.IE5?

    I'm running MacOS 10.6.8 (Snow Leopard) and using Bootcamp 3 (I think) so run Windows XP SP3. My Bootcamp drive is formatted in FAT32, There is a hidden folder in Windows called Content.IE5 where, as I understand it, Internet Explorer stores all of i

  • AWT co-ordinate system

    Hello. I still can't figure out. I'm plotting graph co-ordinates on an AWT Canvas component. i.e (x,y) values However, due to the AWT co-ordinate system, the origin (0,0) is at the top left hand corner of the screen. What trick can I do to plot my po

  • ESS Claims: Reimbursement types not appearing in portal

    Hi ESS Experts, I have done al the configuration required for Claims functionality and it was working fine also. Now I am not able to see cliam list in ESS application. I using Java Application. T7INT9 and A9 tables are cofigured and eligibility is s

  • B1 communication on Internet

    Hi All, I am new to SAP B1, I want to know how can SAP B1 server & the B1 client be made to communicate via internet. Example: The server is at the head office and the client is at the warehouse (a completely different location). Please Advise, also