How to play two videos at the same time

Hi everyone!
Ok, so what I'm trying to do is basically play two videos, which are already saved on the computer, at the same time. I can get one video to play, but when i try to start another it just displays a blank screen.
import javax.swing.*;
import javax.media.*;
import java.awt.*;
import javax.media.protocol.*;
public class TwoVideoTest {
     public static void main(String[]args) {
     MediaLocator locator1 = null;
     MediaLocator locator2 = null;
     try {
     locator1 = new MediaLocator("file:/C:/truck1.mpg");
     locator2 = new MediaLocator("file:/C:/truck2.mpg");
     } catch(Exception e) {
     System.out.println("COULNDT CREATE LOCATORS IN MAIN TEST CLASS");
                      System.exit(-1);
     Player player1 = null;
     Player player2 = null;
                 try {
      player1 = Manager.createRealizedPlayer(locator1);
     player2 = Manager.createRealizedPlayer(locator2);
                  } catch(Exception e) {
          System.exit(0);
     JFrame frame = new JFrame();
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel1 = new JPanel();
   JPanel panel2 = new JPanel();
    panel1.add(player1.getVisualComponent());
   frame.getContentPane().add(panel1);
   frame.setSize(new Dimension(500,500));     
   frame.setVisible(true);
   player1.start();
   player2.start();
}

HELLO AGAIN! I guess i post too soon....
So i modified my code and now the videos play together. Threads, sigh.
But the audio that comes with the video doesn't appear to be starting at the same time. And this problem I ASSURE you i have no clue how to handle. And yes i know, the two video audios will overlap, but this a test for heavens sake!
Anyways, heres the modified code in case it will help anyone
import javax.swing.*;
import javax.media.*;
import java.awt.*;
import javax.media.protocol.*;
public class Video implements Runnable{
     String url;
     MediaLocator locator;
     Player player;
     JPanel panel;
     public Video (String url,JPanel panel) {
          this.url = url;
          try {
               locator = new MediaLocator(url);
               player = Manager.createRealizedPlayer(locator);     
               panel.add(player.getVisualComponent());
               player.start();
          } catch (Exception e) {
               System.out.println("ERROR CREATING MEDIALOCATOR");
               System.exit(-1);
     public void run() {
          try {
          Thread.sleep(100);
          } catch(Exception e) {}
     public static void main(String[]args) {
        JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JPanel panel1 = new JPanel();
          JPanel panel2 = new JPanel();
          panel1.setPreferredSize(new Dimension(100,100));
          panel2.setPreferredSize(new Dimension(100,100));
          Thread thread1 = new Thread(new Video("file:/C:/truck1.mpg",panel1));
          Thread thread2 = new Thread(new Video("file:/C:/truck2.mpg",panel2));
          frame.getContentPane().add(panel1);
          frame.getContentPane().add(panel2);
          frame.setSize(new Dimension(500,500));     
          frame.setVisible(true);
          thread1.start();
          thread2.start();
     

Similar Messages

  • Is it possible to play two videos at the same time in Captivate 4

    My idea is to create some e-learning material which shows a screencast of a powerpoint presentation and a video in the top left corner of the screen showing somebody presenting the slides.
    Does anybody know if it is possible to do this with Captivate 4?
    I know this functionality is provided in Adobe Director.
    Any help regarding this will be greatly appreciated
    Kind Regards
    Jay

    Hi Jay
    Do you have the eLearning Suite? If so, you have Adobe Presenter available to you. If you don't, you should be able to download the Presenter installation file and evaluate it.
    Presenter is an add in for PowerPoint. The neat thing about it is that it provides for a Table of Contents type of functionality as you see is configured in Captivate. But the twist with that is you are able to do something you cannot do in Captivate. You are able to insert videos inside the TOC area!
    Just musing out loud... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Loading and Playing 2 videos at the same time

    Hello everyone
    I'm having a problem on loading and playing two videos at the same time on XletView.
    The background video, I'm loading by editing channels.xml that is located at config folder into xletview folder. I've just to add the file path and when i start the video it starts playing.
    But now, I have a problem. I have to load a file that is into my HD, and play it at the same time of the main(background) video.
    Do anyone know how to do this?

    anyone?
    PowerBook G4 1.67 GHz Mac OS X (10.4.7) 1.5 GB ram

  • Any way to play two clips at the same time one over the other? (transprent)

    Any way to play two clips at the same time one over the other? (transprent)

    Yes.
    See the information here for a variety of ways to do this:
    http://discussions.apple.com/thread.jspa?threadID=933500&tstart=50
    http://discussions.apple.com/thread.jspa?threadID=903151&tstart=0
    http://karsten.schluter.googlepages.com/jackiechancredit
    http://www.geethree.com/slick/V_04.html

  • Apple TV plays two languages at the same time!

    Hello,
    I ripped some of my DVDs using handbrake. I added two language tracks (original language + my mother tongue).
    After adding meta data with subler i also checked both language tracks at subler so they will both appear in itunes.
    Everything works fine when i watch the movie on my computer, i can perfectly switch languages in the settings menu.
    But wen i stream it to my apple tv (i use itunes on my computer at chose apple tv as streaming device/airplay instead of browsing with the apple tv directly)
    it will play both languages at the same time! no matter if i chose a language in itunes or not, it always plays both languages.
    Did anyone else have this problem?
    Or even a solution?

    When an apple tv and an airport express are connected at the same time and the apple tv is powered on, the itunes multiple speakers feature will show both the express and the apple tv. you can select either, or both using the multiple speakers option.

  • How to select two things at the same time ?

    Hey guys, i'm French and I need your help !
    I'm working everyday on iWork and especially Pages.
    How to select two parts of a text at the same time ?
    Before we only need to select one, to press the "cmd" button and then to select another part. It doesn't work anymore!
    Thanks for you help
    and sorry for the mistakes !

    Hey guys, i'm French and I need your help !
    I'm working everyday on iWork and especially Pages.
    How to select two parts of a text at the same time ?
    Before we only need to select one, to press the "cmd" button and then to select another part. It doesn't work anymore!
    Thanks for you help
    and sorry for the mistakes !

  • How to process two files at the same time using BPM

    Hi experts,
    I have a Integration Process it takes two files one Header xml and one Lines xml. These files shoudl be processed at the same time because them will be mappend in a Idoc.
    The realy trouble is that these inbound xmls never are executed at the same time. Then a IP is executed for each inbound xml.
    This is the IP:
    http://picasaweb.google.com/hose86/SapXi#5377539387476591346
    This is related documentation:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/cb/15163ff8519a06e10000000a114084/frameset.htm
    I try to do all what I know, but It don't work fine :S
    Thanks in advance and Regards,
    Jose Antonio.

    Hi Jose,
    Don't specify any end condition for  fork step and check the start process check box in both the receive step.
    Also put all steps inside the block.. so that the control step in deadline branch can throw exception and after that the BPM ends. As per the design now, if a deadline exception is raised (it will b handled) but after that the transformation step and send step is executed. There the BPM fails.
    Regards
    Suraj
    Edited by: S.R.Suraj on Sep 4, 2009 5:39 AM

  • Can itunes play two songs at the same time? Mine can!!

    If you let a song run until just before the end and then click to an earlier part in the song on the time bar, itunes starts playing both that tune and the next one.
    Does this happen with anyone else?
    What a basic error, how did apple not catch this?
    Peace and God Bless.
    ibook g4   Mac OS X (10.4.8)  

    Actually, I have the same problem...only moreso.
    When I'm streaming from another computer, my songs frequently start double-playing without my doing ANYTHING at all. Right now, The Skeleton Killers' "Despair" is doubling up--that's twice the dirge--and I wasn't even touching the computer when it started.
    Oh, goodie! One of the streams has finished and the next song, George Michael's "Outside", has begun, now running concurrently with the last minute of "Despair". I can't tell you how poorly these songs go together.
    The problem started with 7.0 and continues with 7.0.1
    Apple! Help!
    --Jay

  • Play two instruments at the same time?

    Hi!
    I'm stuck with GarageBand right now, where I can only play one instrument at a time. Preferably I want to play both (for example) piano and strings using one real-time MIDI input. Is it possible to do that with either Logic Express or Pro?

    Do you mean play the same thing at once with two instrumets simultaneously playing two different sounds?

  • How to print two PLD at the same time

    Dear Expert,
    I have made two PLD on the purchase order (Page 1 & Page 2 both are the saperate PLD's)
    Is there any shortcut or function available in the SBO that when I print the PLD 1 system has to print the 2 nd PLD without any cammand.
    Regards,
    Datta Kharat

    Hi Datta Kharat,
    I think, It is not possible in SAP B1.
    so, Try to Create Single PLD and Use Number of Layout Pages -> 2 in PLD.
    ->> Open the Require PLD.
    ->> Right Click in PLD and Choose the Display Document Properties.
    ->> Assign the Number of Layout Pages = 2 in Paper Format Tab on Document Properties Window.
    Regards,
    Madhan.

  • How to start two threads at the same time

    Hi there,
      I want to include multithreading in the CVI program. I have two tasks which has no dependence between them, so I would like to start two threads for perform the tasks. I follow the introduction http://www.ni.com/white-paper/3663/en/ to start my code. In my code, I add a command button, when it is pressed, I create two threads to perform the tasks. In each task, I have a big loop and in each iteration, I use ProcessSystemEvents to avoid no response on system message. But it doesn't work actually, the program suspended. I wonder must I initialize the threads in main. I am looking for a way to start the threads in the callback function for a button since I am not starting those threads at the beginning but while it is triggered.
    the main frame of the code looks
    int CVICALLBACK Test1(void *functionData)
    { int i=0;
    for (i = 0; i<100000; i++) {ProcessSystemEvents();}
    return 0;
    int CVICALLBACK Test2(void *functionData)
    int i = 0;
    for (i = 0; i<100000; i++) {ProcessSystemEvents();}
    return 0;
    int CVICALLBACK cmdcb(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
    { int threadID1, threadID2;
    if (event==EVENT_COMMIT)
    SetPanelAttribute(panelHandle, ATTR_DIMMED, 1);
    CmtScheduleThreadPoolFunction(DEFAULT_THREAD_POOL_HANDLE, Test1, NULL, &threadID1);
    CmtScheduleThreadPoolFunction(DEFAULT_THREAD_POOL_HANDLE, Test2, NULL, &threadID2);
    CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE, threadID1, 0);
    CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE, threadID2, 0);
    return 0;
    Attachments:
    TestThread.zip ‏239 KB

    In my opinion your threads may be simply lasting longer than expected due to an incorrect sleep policy of threads paired with with ProcessSystemEvents () in the loop.
    I made up a quick example that shows this behaviour: playing with "Do not sleep" and "Call ProcessSystemEvents" options you can see how threads execute.
    BTW: do not forget to release the thread function IDs at the end of functions.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?
    Attachments:
    thread.zip ‏7 KB

  • How to open two projects in the same time?

    I have over 40 file project. Stadium.
    I am in finish of my work, but I forgot about something. I didn't notice that I lost a few keyfreme animation. I didn't realize that in 30 project and I am more over 40 right now. I made a lot of work and I can't go back to 30 project. I don't want to do this from the beginning, so I would like to COPY my keyfremes from project 3o to project 40. To do that I need to have 2 programs opens (to copy keyfremes from 30 project to 40 project). But I can't open two After Effects.
    How Can I copy my keyframes on timeline?
    To copy ALL of this in one turn and paste also:

    By FILE - IMPORT - FILE? It's just simple?
    Thank you!

  • [KDE] Unable to play two sounds in the same time

    I am switching from gnome to kde, and i did a fresh install (i formatted) the entire system.
    The problem is that, for example, before in genome i was able to have songbird playing while a movie was being as well played and if someone talked to me via pidgin, the warning sound would be heard as well....
    In kde, if i am listening to amarok, i cannot listen the audio from a video from youtube, and sometimes, while i am listening to music, someone talks to me on kopete, stops the playback on amarok and then plays the new message warning sound...... i understand this is a misconfiguration of my audio system, isn't it?
    Where should i start from? I am using xine as sound engine (phonon-xine)-.....
    Thanks!
    Last edited by Xi0N (2009-10-15 16:08:10)

    Seems to be a problem with your alsa conf...
    But, here with a stupid intel chipset, it works without any configuration !
    Maybee your gnome was configured with pulseaudio?

  • I want to play two sources at the same time - what software is there?

    Hi
    Something of an unusual request. I have CDs of natural background sounds (my favourite is one of the sea which I have on iTunes on repeat). The sad thing is, I have to choose between these and my music.
    What I need is a free CD player (software) that allows me to play my CDs on repeat in the background, then I can use iTunes for all my regular music playlists, and have them both going at once.
    Any ideas?

    I've found something called SimpleAudioCDPlayer which plays the CD (and does have a Loop facility).
    Problems:
    1. there is no icon in the Dock, just a little icon that floats right in the middle of my screen (I can adjust it to tiny but it's not moveable and is a bit of a nuisance)
    2. more seriously, there is no volume control which means I cannot reduce the sea sound to background sound.
    So maybe someone knows of something better?

  • How to update two tables at the same time using jdbc

    Plz will anybody tell me what is the code or query in jdbc by which you insert entry in one table and simultaneously it goes in another table?
    Thanks in advance

    You might be
    able to design a trigger to do what you're talking
    about, but that would be a database thing, not a java
    thingAnother option would be an updatable view (google for usage), but it has limitations and should be used with caution. And yes, its a database thinggy and not java.
    cheers,
    ram.

Maybe you are looking for

  • HP OfficeJet Pro 8500A and Google Calendar

    The Google Calendar application for my HP OfficeJet Pro 8500A always prints the calendar offset by one day; i.e. Sunday's events are listed on Monday, Tuesday's events on Wednesday, etc.  All settings are fine, otherwise, prints like a champ on every

  • Available Services in Standard Business Package

    Hi All, What are all the services(applications) provided by MDM standard Business Package? Are there any links which clearly states the list of services supported. Thanks in Advance!! Regards, Revathi Raju. Edited by: Revathi Raju on Mar 11, 2009 8:4

  • [SOLVED] [udev] invalid key/value pair in custom rule

    Hey, this simple rule in /etc/udev/rules.d/99-usb-backup.rules, which is used to automatically mount my encrypted backup disk when plugging in run a backup script after the backup disk has been mounted, is said to be invalid: SUBSYSTEMS=="usb", ATTRS

  • An " " symbol at the top of each JavaHelp page?

    Hello all, I have generated JavaHelp off an imported Word 2007 document on a Windows 7 box.  Interestingly, an unsightly ">" (the greater than sign) is appearing at beginning of each help page when ported to my Fedora 13/Linux box.  The preview of th

  • ITunes Producer Won't Launch

    Greets, When I try to run iTunes Producer 2.9 I get the following error message: "You can't open the application iTunes Producer because it is not supported on this type of Mac." I've checked the system requirements and it states: "iTunes Producer 2.