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

Similar Messages

  • 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

  • How can i play encrypted video(.mp4) in iphone app?

    Hello,
    I want to play encrypted mp4 video in my app.
    How can i play encrypted video in iphone app?

    Thanks for your assistance. Unfortunately I'm still not able to get this to work.
    First, I don't see an export to Quicktime in AppleTV format setting. The only choices that I have are export to Quicktime in Full, CD, email or streaming video format.
    I tried both full and CD but I still cannot get it to my AppleTV. Once the video is in Quicktime format I drag and drop the file into my iTunes library. It shows up in the movies directory on Itunes but when I sync Itunes with Apple TV - nothing. Everything else syncs but just not the quicktime movie.
    Any ideas?

  • How can I create a video with effects using my ipad?

    How can I create a video with effects (sepia, B&W, Negative, oval or any other shape borders) using my ipad?  I would Like to keep a higher res and also be able to shrink it down to email or send in a MMS. Or should I just upload it to my PC and mess with it there? Some of the apps I have are very easy to use compared to the learning curve needed for video editing software.
    Thanks

    Thats the Problem . . . how many apps do I have to try until I find the one I want? I noticed a few will render the video thus losing its original size. When I went to edit it more in iMovie the video was smaller--not good. And what software do you suggest, Templeton, for the PC? I love the apps because they are easy. I dont have hours to mess around on a software to figure out if its something I want. Im looking for simplicity. Maybe Ill get more into it later. I just want to record simple video of my playing the guitar for self analysis and create a short video for family and friends.
    Apps:
    iMovie
    CinemaFXV
    VideoFix
    Cartoonatic
    Video illusion
    VidEditor
    Software:
    Windows Movie maker (wont accept .mov files)
    After Effects (Too little time, so much to learn)
    Wondershare (Very easy but little choices)
    VideoPad (Again. Few choices)

  • 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

  • How can I export a video with audio from premiere cs 5.5 to a DVD

    how can I export a video with audio from premiere cs 5.5 to a DVD

    You don't... at least not directly... you export MPEG2-DVD and then use the TWO files (audio and video) in Encore
    CS5-thru-CC PPro/Encore tutorial list http://forums.adobe.com/thread/1448923 may help

  • How can I record a video with LAbview?

    Hi,
    I have a question: How can I record a video with labview?
    I have a camera (AXIS 221) connected via rj45 on PC. I see the video of the camera in a browser.
    And I would to acquire the video in labview.
    Could someone help me?
    Thanks
    Raf

    Unfortunately I haven't any experience with this camera. Iguess, you should install API, then crete new VI, place ActiveX container (palette Container->ActiveX) on the Front Panel, then right mouse click, then choose Insert ActiveX object..., then found you camera object and select it and press OK. Then you probably can see image from the on the front panel. Also probably you will be able to get image data in array (how easy is it - depends from the camera API).
    If you able to see image from camera in the Internet Explorer, then another method - you can put Microsoft Web Browser as ActiveX object, then you should also see the image. Disadvantage of this method - you will be not able to get image data.
    Andrey.

  • How can I locate my ipad with only the serial number

    how can i locate my ipad with only the serial number

    you can't
    even with the IMEI number the police need a warrent to get such info from the carriers

  • Premiere pro Encoded file having m4v & .wav & m4v.xmpse files how can i play this video file?

    Hello Guys,
    I am a beginner in Premiere ,just started learning.Created a project and wanted the finished project file as a bluray format,after 14 hours  adobe premiere pro(not encore) created all the above three files,what to do next? how can i play the video file?
    Kind advise pls

    Dear Mr,Hunt,
    You made my day....i felt its more than special a christmas day,thank's a Trillion..downloaded the MKV MERGE GUI ,within ten minutes job done!!!!!!!!!
    All my 16 hour rendering job is saved.End of the day i learned something new toooo.
    I would like to ask you a question which is not connected to this topic,i asked this question before in windows 7 forum but till date no body solved!!
    I am having few avi video files which having (avi.avi) extension i couldn't figure out how its occured(they all video files captured from samsung galaxy note,and appeared noraml avi files but became avi.avi i tried removing one extension,eventhough it says having one extension when you look in to the properties of that file you can see avi.avi ,the problem is eventhough it playable in vlc sometime,when i try to import to premiere pro -it says the file is corrupted.
    any idea??

  • HT1349 how can you track you ipod with only serial number ]

    2nd Generation ipod Touch

    Hello, Tommyty,
    I am sorry you have lost your iPod.  You don't yet seem to understand that its serial number is not tracked electronically.  Here is my attempt at explaining the same thing that Limnos and stevejobsfan0123 have already told you. 
    Tommytj wrote: ... HT1349 how can you track you ipod with only serial number ] ...
    Only by physically looking at the iPod's serial number.
    Tommytj wrote: i need to find my ipod can anyone help me find a way to track my ipd touch with only a serial number using icloud.
    No.
    Nobody can help you with that request because iCloud and  "Find My iPod touch" do not work that way.
    If you cannot see the iPod, you cannot track its serial number.  Unless someone sees the serial number, nobody can track it.
    Regardless of whether you have properly installed and enabled "Find My iPod touch", iCloud does not track your iPod's serial number.  This is true even when you or someone else can see your iPod's serial number.
    Regardless of how much you wish iCloud could track your iPod's serial number, it cannot.
    "Find My iPod touch" can sometimes track an iPod's location but only under the specific circumstances Limnos has already explained to you. 
    If "Find My iPod touch" cannot locate your iPod by its location, there is no iCloud way to find it.  In that case, the only way to identify your missing iPod is for you or someone else to physically look at it.
    Perhaps you will be successful with one of these alternative possibilities for recovering your iPod:
      • you can physically search and find your misplaced iPod
      • someone may it returned in response to a reward that you offer
      • the police may find it after you have reported it stolen
    Message was edited by: EZ Jim
    Mac OSX 10.7.4

  • How can I view a video with the extension .wlmp?

    How can I view a video with the extension .wlmp?

    Nevermind. Found wlmp reference elsewhere in these discussions.

  • How can I protect a video with a password?

    how can I protect a video with a password?
    Thanks
    Message was edited by: Host <to clarify Subject>

    By default, Disk Utility has the "Add to Keychain" setting checked on.
    You have to make a new image and turn this funtion off if you want to make sure the video stays private on your computer.
    If you send the video to another computer, the user will have to enter the password.

  • How can I combine different pdf files in one?

    How can I combine different pdf files in one?

    Sara,
    It is not working. I wish to decline in having the pdf pack. How can I give up this purchase? I definitely do not want the Adobe PDF Pack anymore.
    Who do I have to contact or what do I need to do to cancel this purchase?
    Flávia
    Enviado do Email do Windows
    De: Sara.Forsberg
    Enviado: terça-feira, 6 de maio de 2014 14:59
    Para: Eu
    How can I combine different pdf files in one?
    created by Sara.Forsberg in Adobe PDF Pack - View the full discussion 
    Hi Flávia,
    Adobe PDF Pack is an online subscription--it definitely allows you to combine several files into one PDF file. For more information about PDF Pack, see Reliably Create PDFs, Convert PDFs, & Merge PDFs Online | Adobe PDF Pack. If you don't have the full version of Acrobat, this is a great solution for combining PDF files.
    However, if you're using Acrobat (not Adobe Reader), you combine files by following these steps:
    Open a PDF file that you want to add pages to.
    Click the Pages pane on the Tools panel (on the right side of the application).
    Click Insert From File, and choose the file that you want to combine with the PDF that you opened in step 1.
    Make any changes necessary in the Insert Pages dialog box--these settings determine where the new file will be inserted.
    Click OK.
    Please let me know how it goes.
    Best,
    Sara
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6358990#6358990
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe PDF Pack by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • How can I use different iTunes accounts on one iPad?

    How can I use different iTunes accounts on one iPad?

    You can't, well not easily anyway.  The iPad is not meant as a multi account device. 
    You can Sign Out of your iTunes account in Settings->iTunes and App Stores->Apple ID->Sign Out
    However if you sign in with another ID and then download past purchases with it you will lock out the previous ID for 90 days. Which means it will not be able to be used on the iPad for 90 days. 

  • How can I have multiple accounts and only one library

    How can I have multiple accounts and only one library that all the purchased items feed into?

    ask your wireless provider.

Maybe you are looking for

  • About the filter function in OBIEE 11g

    Hi, all. when i use the filter function in OBIEE 11g, it turn out a wrong result. The operation steps and detail are described as follow: 1. In the Column Formula pane, I typed the Formula of the column 'count of customer' as: FILTER(count(distinct("

  • Screen Resolution doesn't fit?

    I'm honestly not sure how it happened! I've been using Photoshop and Illustrator and then I noticed that the writing in the top menu bar was blurred and I couldn't see the dock. I went into preferences and looked at the displays part and the resoluti

  • Read Data (ASCII) and send to analog output

    Hello I have the following MAX configuration: Analog input task, continous, 2 samples, rate 100Hz (PCI-6024E) Analog output task, continous, 64 samples, rate 100Hz (PCI-6723) The cards are synchronized by the RTSI bus. With Dasylab I display signals

  • What is detailed report and aggregated report

    Hi gurus, We generally tell cube gives the aggregated report and ODS gives detail report could any body tell me what exactly meaning behind there Please give me a good example for make me good under stand.. Thanks in the advance Kiran Edited by: kira

  • Can I Add the Trash to the side bar

    Can I Add the Trash to the side bar I want the trash on my side bar every time i open a folder i want it somewhere here