Playing a sequence received from a transmitter

Hello,
I have this bit of code here which obtains an unconnected sequencer and sets a sequence to be transmitted from it:
//try statement
File myMidiFile = new File("C:\\fileone.mid");
            Sequencer sequencer = MidiSystem.getSequencer(false);
            ReceiveAccomp ra = new ReceiveAccomp();
            Receiver accompRcvr = ra.getReceiver();
            sequencer.getTransmitter().setReceiver(accompRcvr);
            sequencer.setSequence(MidiSystem.getSequence(myMidiFile));
            sequencer.open();
            sequencer.start();
//catch statementReceiveAccomp, the receiving class (which implements MidiDevice), has this bit of code in the receiver part:
private class AccompanimentReceiver implements Receiver
public void send(MidiMessage message, long timestamp)
           try
                Synthesizer synth = MidiSystem.getSynthesizer();
                Receiver synthRcvr = synth.getReceiver();
                synth.open();
                synthRcvr.send(message, -1); // -1 means no time stamp
                //Play for 1 second
                Thread.sleep(1000);
                synth.close();
            catch (MidiUnavailableException e){/*print stack trace*/}
            catch (InterruptedException e){/*print stack trace*/}
         }The problem is that this plays each note at a specific duration and then cuts each note off, as opposed to the original duration of each note. I'm not sure how I'd get it to play exactly as the original sequence intended.
If anyone has any idea what I'm probably doing incorrectly here that'd be ace, thank you!

The problem is that this plays each note at a specific duration and then cuts each note off, as opposed to the original duration of each note. I'm not sure how I'd get it to play exactly as the original sequence intended.The problem is that it plays each note for exactly 1 second, I'd imagine, because that's how long you're sleeping.
You need to extract the length of the note from the MidiMessage and sleep that long, rather than a hard-coded 1 second.

Similar Messages

  • CS6 audio won't play on sequence copied from another project

    I copied a sequence from Project 1 and pasted it into Project 2 yesterday. It worked fine yesterday. Today I tried to open up the sequence, and the audio was "browned out." I right clicked on "reveal in project" and the correct audio file came up.
    Other sequences that I did not import are playing back fine.
    What's up?
    https://www.dropbox.com/s/2uu7gugk866yeug/browned%20out.png

    In case someone else finds this thread - the fix was to select all the audio tracks, right click on them, click on Audio Channels, and change the source channel to whatever the available option was. In a couple instances, I switched to "None." and it turned green, but was inaudible. Then I did it again and switched back to whatever the other option was, and it played again.
    Thanks!

  • Playing iPod through receiver from patio 25' away

    I have an iPod Classic. I play it through our Pioneer receiver in our den by using an Apple Composite AV cable. We would like to be able to control the iPod from the patio. Is there a cable available that is 25'+ that can connect the iPod to the receiver?

    I was originally going to recommend a 25' cable as you stated however I couldn't find anything more than 9'. Below is a link which will accomplish what you want however by utilizing a remote control. This way you are cable free and can move around the house beyond 25'.
    Click [HERE_|http://www.amazon.com/Philips-SJM3152-17-Universal-Connection/dp/B002R8VKTI/ref =dp_cp_ob_e_title0?ie=UTF8&qid=1275194131&sr=1-158] to see if this device will work for you.
    Axel F.

  • Can I use my ipod touch as a airplay receiver to hook up to my stereo and play my itunes music from my computer?

    I just was wondering, Can I use my ipod touch as a airplay receiver to hook up to my stereo and play my itunes music from my computer?

    I believe there's got to be a way you can use the ipod touch as a airplay receiver to use on the stereo.
    The ipod touch has a port for plugging in earphones, that can also be used to plug a stereo into it.
    Now somebody just has to make an app for using on ipod touch or iphone to plug directly into the stereos input
    jack to play itunes music from your computer wirelessly, other than the ipod being plugged into the stereo with a wire.

  • How to transform data received from file adapter

    hi',
    I am reading the data from XML file using file adapter, now I want to write the same contents which I have read from this file to a different/new XML file, the issue is I am unable to perform a transform here, when I use a transform with source element as the output of the file read and target as the input to the new file it is writing an empty file,
    I have checked the audit trail which showsme that the transform is empty.
    please tell me how can I transform the element which I have received from one file to make them as input to next file
    thanks
    Yatan

    thanks James for input, this is my XML and XSD files
    XML file:
    <?xml version="1.0" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.example.org"
    targetNamespace="http://www.example.org"
    elementFormDefault="qualified">
    <emp>
    <name>yatan</name>
    <age>28</age>
    </emp>
    </xsd:schema>
    XSD File:
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.example.org"
    targetNamespace="http://www.example.org"
    elementFormDefault="qualified">
    <xsd:element name="readfile">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="empid" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    I am reading XML file, I will describe my process.
    1.) File adapter>read operation ---> receive activity
    2.) Transform > source(receive input variable) <--->target(Invoke input variable)
    3.) File adapter > write operation ---> invoke activity
    Now when I am deploying this process it is sucessfully completing and able to read the file.
    when I check the audit trail receive activity shows XML data but when I check the transform it
    shows empty as below, however the write activity is performed which creates a xml file but no values in the elements
    transform in audit trail
    <Invoke_1_Write_InputVariable>
    -<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="readfile">
    -<readfile xmlns:ns0="http://www.example.org" xmlns="http://www.example.org">
    <ns0:name/>
    <ns0:empid/>
    </readfile>
    </part>
    </Invoke_1_Write_InputVariable>
    this is the code for my .bpel file
    <?xml version = "1.0" encoding = "UTF-8" ?>
    <!--
    Oracle JDeveloper BPEL Designer
    Created: Wed May 19 15:04:22 IST 2010
    Author: yatanveer.s
    Purpose: Empty BPEL Process
    -->
    <process name="ReadXMLFile2"
    targetNamespace="http://xmlns.oracle.com/ReadXMLFile2"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:ns4="http://xmlns.oracle.com/pcbpel/adapter/file/FileReadSync/"
    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:client="http://xmlns.oracle.com/ReadXMLFile2"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
    xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/file/ReadFile/"
    xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
    xmlns:ns3="http://www.example.org"
    xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/file/WriteFile/"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <!--
    PARTNERLINKS
    List of services participating in this BPEL process
    -->
    <partnerLinks>
    <partnerLink myRole="Read_role" name="ReadFile"
    partnerLinkType="ns1:Read_plt"/>
    <partnerLink name="WriteFile" partnerRole="Write_role"
    partnerLinkType="ns2:Write_plt"/>
    </partnerLinks>
    <variables>
    <variable name="Receive_1_Read_InputVariable"
    messageType="ns1:readfile_msg"/>
    <variable name="Invoke_1_Write_InputVariable"
    messageType="ns2:readfile_msg"/>
    </variables>
    <!--
    VARIABLES
    List of messages and XML documents used within this BPEL process
    -->
    <!--
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process
    -->
    <sequence name="main">
    <receive name="Receive_1" partnerLink="ReadFile" portType="ns1:Read_ptt"
    operation="Read" variable="Receive_1_Read_InputVariable"
    createInstance="yes"/>
    <assign name="Transform_1">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('Transformation_3.xsl',bpws:getVariableData('Receive_1_Read_InputVariable','readfile'))"/>
    <to variable="Invoke_1_Write_InputVariable" part="readfile"/>
    </copy>
    </assign>
    <invoke name="Invoke_1" partnerLink="WriteFile" portType="ns2:Write_ptt"
    operation="Write" inputVariable="Invoke_1_Write_InputVariable"/>
    </sequence>
    </process>

  • Receiver From in BPM

    hi,
    When do we use Receivers List and when do we use Send Context in Receiver From in the SEND step of BPM.
    Thanks,
    Tirumal

    Hi Tirumal,
    Receiver List is used , when you need to do Dynamic Receiver Determination based on the sequence of steps/Acknowledgement from the previous receiever.
    So it is like Conditional Receiever Determination. When you use Send Context with Receievers attached the message will go to specified Receiever.
    To know more-
    http://help.sap.com/saphelp_nw04/helpdata/en/43/6211b11c895f6ce10000000a1553f6/frameset.htm
    It also describes example too.
    Hope this helps,
    regards,
    Moorthy

  • Invalid response received from device

    Hello everyone. "iTunes cannot connect to the iPhone because an invalid response was received from the device." I get this message each time I connect my ipod touch to my computer. I have tried reinstalling itunes, uninstalling apple mobile support and all apple related programs and installing them again. However, I would still get the same result. Anyone can help please? Thanks in advance.(My ipod is 3rd gen 32gb 3.1.3)
    Message was edited by: leganda

    Okay, after the updates I am still having the same problem. I'll try explaining it as detailed as possible, hoping somebody has an answer because this is pretty weird to me.
    -I have 5 files, Ringtone1.m4r, Ringtone2.m4r, Ringtone3.m4r, Ringtone4.m4r and Ringtone5.m4r.
    -I add them to the "ringtones" section under "Devices"
    -ON ITUNES they show up perfectly fine. In order, and if I play them through itunes, all the ringtones are correct, just how they should be.
    -I eject iPhone, go to settings > sounds > ringtone, and under custom, what I see is:
    Ringtone1
    Ringtone1
    Ringtone1
    Ringtone1
    Ringtone1
    Why on Earth could this be?

  • WP8.1 Playing audio in background from http widget

    Hi,
    I'm building an app for one of music platforms. I want to add to my app playing music function from that platform with SystemMediaTransportControls. The problem is that playing music can only be controlled by http widget. There is no direct stream url
    so I cannot use mediaplayer instance in background task. I was thinking on using webview control inside background process but I don't know whether it would stream audio in that form.
    For test purpose I've build Page with WebView control and redirected it to http widget. I can play music in that form but when I lock the phone, music stops playing. Another option from above would be enabling music to play after going app to suspended
    state.
    Can anyone help me?

    Hello,
    Nithak is correct. You must use the background media player to play background audio on the Windows Phone 8.1 platform. You cannot use the WebView from a background task. The media transport controls are directly integrated into the background media player
    and cannot be used independently.
    You said: "There is no direct stream url so I cannot use mediaplayer instance in background task."
    There must be a URL that the page is connecting to and receiving audio data from. If you are not the owner of the website that the audio originates from, you should contact the owner of the website and ask them if their audio protocol is documented. If you
    have access to the documented protocol you can write your own custom
    MediaStreamSource to connect to, parse and play the custom audio stream.
    I hope this helps,
    James
    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

  • Premiere pro/audition bug? Mixdown file won't play in sequence

    Howdy.
    Never had this happen before, so I thought I'd ask you academic types what's going on.
    I created a sequence in PP that contained multiple audio (wav)/video files. I exported the audio to Audition, balanced the amplification, declicked, popped, etc. Created a mixdown of the files and exported (wav). I imported the mixdown to PP and placed it into the sequence (I've done this thousands of times before). Unfortunately, there were no waveforms on the file and no audio can be heard.
    However, if I open the same file in the source monitor the waveforms are there and the file plays as it should. I can also open and play the wav file in media play, for example, and everything appears to be fine.
    Any ideas on why it won't play in the program monitor/timeline/sequence?
    Thanks

    Oh well, not a big deal. I was able to use the clip by creating a new sequence, dragging from source monitor to new sequence, then copy/paste from the new sequence to the sequence I needed.

  • Premiere pro 5.5 stops working when playing a sequence, saving a project or closing,any ideas why?

    I can open a project, import files or other projects, but when I want to play the sequence the program stops working and closes. When I try to save the project or close the program I get a "software not responding" message.
    I hope someone can help me with this as I cannot work on any projects.
    thanks.

    Hi john,
    thanks for taking the time to help me. I have updated the software and rendered the files and now I am able to play them, but still neither the sequence nor the clip play/show on the corresponding screens, I can only hear the audio file. I also continue having problems when saving the project, the software stops working and I get the "non responding" error from microsoft.
    As you suggested, and I have to say I am pretty much a dummy with the codecs and alike, I installed the mediainfo and run one of the files.
    This is the info that appears on the screen
    I am not getting any error messages from Premiere, so I am kind of stock. If you need other info let me know.
    Thanks for your help and patience.
    Arantza
    Date: Mon, 23 Apr 2012 09:12:15 -0600
    From: [email protected]
    To: [email protected]
    Subject: premiere pro 5.5 stops working when playing a sequence, saving a project or closing,any ideas why?
        Re: premiere pro 5.5 stops working when playing a sequence, saving a project or closing,any ideas why?
        created by John T Smith in Premiere Pro CS5, CS5.5, & CS6 - View the full discussion
    Read Bill Hunt on a file type as WRAPPER http://forums.adobe.com/thread/440037What is a CODEC... a Primer http://forums.adobe.com/thread/546811What CODEC is INSIDE that file? http://forums.adobe.com/thread/440037.Report back with the codec details of your file, use the programs below... a screen shot works well to SHOW people what you are doing.For PC http://www.headbands.com/gspot/ or http://mediainfo.sourceforge.net/enFor Mac http://mediainspector.massanti.com/.http://blogs.adobe.com/premiereprotraining/2011/02/red -yellow-and-gree n-render-bars.html.If you have a red line over the timeline after importing a video and before adding any effects... your project is wrong for your video... read above about codecs.Once you know exactly what it is you are editing, report back with that information... and your project setting, and if there is a red line above the video in the timeline, which indicates a mismatch between video and project.H.264 will NOT work inside an AVI http://forums.adobe.com/thread/854115.More information needed for someone to help... click these links and provided the requested information-http://forums.adobe.com/message/4200840-http://forums.adobe.com/thread/416679.For CS5 and later, the easy way to insure that your video and your project matchSee 2nd post for picture of NEW ITEM process http://forums.adobe.com/thread/872666
         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: http://forums.adobe.com/message/4354727#4354727
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4354727#4354727. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Premiere Pro CS5, CS5.5, & CS6 by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Notification center does not play sound when receiving notifications.

    Why my new ipad Notification center does not play sound when receiving notifications.

    Settings>Notifications .... Did you set up the various apps to receive notifications?
    Do have system sounds muted?
    If you lose sounds for keyboard clicks, games or other apps, email notifications and other notifications, system sounds may have been muted.
    System sounds can be muted and controlled two different ways. The screen lock rotation can be controlled in the same manner as well.
    Settings>General>Use Side Switch to: Mute System sounds. If this option is selected, the switch on the side of the iPad above the volume rocker will mute system sounds.
    If you choose Lock Screen Rotation, then the switch locks the screen. If the screen is locked, you will see a lock icon in the upper right corner next to the battery indicator gauge.
    If you have the side switch set to lock screen rotation then the system sound control is in the task bar. Double tap the home button and in the task bar at the bottom, swipe all the way to the right. The speaker icon is all the way to the left. Tap on it and system sounds will return.
    If you have the side switch set to mute system sounds, then the screen lock rotation can be accessed via the task bar in the same manner as described above.
    This support article from Apple explains how the side switch works.
    http://support.apple.com/kb/HT4085

  • Scanner(Warning) : 027: Unable to read the sequence number from the Workstation object.

    Hi
    We are having trouble storing inventory scans from some workstations.
    We have a windows ONLY environment, with middle tier servers. (ZEN65SP1,
    W2KSP4).
    Some workstations are storing fine. The Storer function is working and we
    can see the storer functions for the 'good' workstations in the Inventory
    service window.
    However some workstations can't store to the inventory db, but DO populate
    eDir ZENworks inventory 'minimal information' but show "Scanner(Warning) :
    027: Unable to read the sequence number from the Workstation object." in
    the Scan Status...
    The Inventory service window shows no attempt by these workstations - it's
    almost as though the scan file is not arriving (though eDir knows/displays
    the scan file name)
    How does the workstation access the scandir in Windows only/middle tier
    environment? Does the scan xml stream get sent to the MT via http and then
    on to the scandir via CIFS?
    Any suggestions/explanations welcome!!
    Many thanks
    David

    David,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp
    - Check all of the other support tools and options available at
    http://support.novell.com.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://support.novell.com/forums)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://support.novell.com/forums/faq_general.html
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • Is there dvd software out there that allows you to create a dvd menu in which the viewer can choose to play different sequences of the videos offered?

    Is there dvd software out there that allows you to create a dvd menu in which the viewer can choose to play different sequences of the videos offered? It was described to me as a dvd matrix menu but I can't find anything like it for mac. The idea is that there are multiple videos on the dvd menu and you can choose to play "video A, then B, then C" or "video B, then C, then A", etc, in different orders each time. And it would play the sequence that you choose.

    meghanica wrote:
    I think that's on the right track but I'm wanting something that allows the viewer to choose the sequence when they're looking at the DVD menu. I only see how the creator of the DVD can make different sequences. It's a yoga tutorial DVD and we are wanting the viewer to be able to pick a sequence from the menu items as such: pick one of the 3 warm-up videos, then pick one of the 2 yoga practices and then pick 1 of the 3 cool-down videos and then the dvd will play the sequence of selected warm up, practice, then cool down. And it can be differently chosen every time the viewer uses the menu.
    You can do this on a DVD with DVD Studio Pro.
    DVD's have some very basic storage called SPRM/GPRM scripting IIRC.
    There are a few tutorials around for DVDSP…
    http://www.kenstone.net/fcp_homepage/dvd_language_nattress.html
    http://www.digitalproducer.com/article/DVD-Studio-Pro-Scripting-Part-4-28784
    You use scripts to set values that are stored in a tiny amount of memory on the player & then have to use additional scripts to respond to the values set, so that at the end of a sequence it will jump to the one a user previously chosen.
    Some things to consider…
    DVD's have limits on the number of chapters & titles, you need to plan around that.
    Some DVD players are terrible to navigate, the settings that a user selects will be forgotten when the player is powered off. Users will need to make the choices over & over, every time they use the DVD (computers may remember it - I haven't tested this in years).
    You will also need to setup many variations of menus to be able to indicate what selections they chose.
    It is not a trivial task, you may want to hire a programmer to set it all up.
    Testing is also a lot of work - too many combinations can quickly cause issues for testing, different players can also do odd things too.
    I have used scripting for basic, 'play all' or 'play chapter' menus where the video is encoded once on the DVD & the scripts will either play through, or simply play a chapter & return to the same menu.
    You may find that it would be better to invest in setting up a website with this. On a custom site it would be possible for users to save a playlist or several, they can also share playlists etc, it would be more flexible & usable IMO.
    See roaring apps for info on others who have used DVD Studio Pro with various OS's…
    http://roaringapps.com/app/dvd-studio-pro …it looks like 10.8 may be the last OS to work correctly with DVDSP.
    Other DVD authoring apps may be able to do GPRM scripting too, but you will have to search for them.
    I think the registers are part of the DVD spec, so devices should support them, https://en.wikipedia.org/wiki/DVD-Video

  • Transmit and receive from the same ip address?

    Helpers:
    We 've been using transmit/Receive for a while, I read all the discussions. No one seem really know does the transmit send to a destination IP address and the destination receive from the same IP or the IP address the sender send from?
    like sender send from: java Transmitter 123.4.3.162 5000
    receiver receive from: java Receive 123.4.3.162 5000
    or sender send from: java Transmitter 123.4.3.162 5000
    receiver receive from: java Receive 10.118.5.162 5000
    I think the frist one is correct, does anyone has clear idea and experience about it.
    Desperate coder!

    Receiver code is as follows
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.media.*;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.AudioFormat;
    import javax.media.format.VideoFormat;
    import javax.media.Format;
    import javax.media.format.FormatChangeEvent;
    import javax.media.control.BufferControl;
    public class AVReceive2 implements ReceiveStreamListener, SessionListener,ControllerListener
    String sessions[] = null;
    RTPManager mgrs[] = null;
    Vector playerWindows = null;
    boolean dataReceived = false;
    Object dataSync = new Object();
    public AVReceive2(String sessions[])
              this.sessions = sessions;
    protected boolean initialize()
    try
              InetAddress ipAddr;
         SessionAddress localAddr = new SessionAddress();
              SessionAddress destAddr;
              mgrs = new RTPManager[sessions.length];
              playerWindows = new Vector();
              SessionLabel session;
              for (int i = 0; i < sessions.length; i++)
                   try
         session = new SessionLabel(sessions);
              catch (IllegalArgumentException e)
         System.err.println("Failed to parse the session address given: " + sessions[i]);
                        return false;
    System.err.println(" - Open RTP session for: addr: " + session.addr + " port: " + session.port + " ttl: " + session.ttl);
         mgrs[i] = (RTPManager) RTPManager.newInstance();
         mgrs[i].addSessionListener(this);
         mgrs[i].addReceiveStreamListener(this);
         ipAddr = InetAddress.getByName(session.addr);
              if( ipAddr.isMulticastAddress())
    // local and remote address pairs are identical:
    localAddr= new SessionAddress( ipAddr,session.port,session.ttl);
    destAddr = new SessionAddress( ipAddr,session.port,session.ttl);
                        else
    localAddr= new SessionAddress( InetAddress.getLocalHost(),session.port);
    destAddr = new SessionAddress( ipAddr, session.port);
              mgrs[i].initialize( localAddr);
    BufferControl bc = (BufferControl)mgrs[i].getControl("javax.media.control.BufferControl");
                        if (bc != null)
              bc.setBufferLength(350);
                   mgrs[i].addTarget(destAddr);
              catch (Exception e)
    System.err.println("Cannot create the RTP Session: " + e.getMessage());
    return false;
         long then = System.currentTimeMillis();
    long waitingPeriod = 30000; // wait for a maximum of 30 secs.
              try
              synchronized (dataSync)
    while (!dataReceived && System.currentTimeMillis() - then < waitingPeriod)
                        if (!dataReceived)
                                  System.err.println(" - Waiting for RTP data to arrive...");
                        dataSync.wait(1000);
              catch (Exception e) {}
              if (!dataReceived)
    System.err.println("No RTP data was received.");
              close();
              return false;
    return true;
    public boolean isDone()
              return playerWindows.size() == 0;
    protected void close()
              for (int i = 0; i < playerWindows.size(); i++)
              try
         ((PlayerWindow)playerWindows.elementAt(i)).close();
              catch (Exception e) {}
              playerWindows.removeAllElements();
         // close the RTP session.
              for (int i = 0; i < mgrs.length; i++)
              if (mgrs[i] != null)
    mgrs[i].removeTargets( "Closing session from AVReceive2");
    mgrs[i].dispose();
                        mgrs[i] = null;
    PlayerWindow find(Player p)
              for (int i = 0; i < playerWindows.size(); i++)
              PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
              if (pw.player == p)
                        return pw;
              return null;
    PlayerWindow find(ReceiveStream strm)
              for (int i = 0; i < playerWindows.size(); i++)
              PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
              if (pw.stream == strm)
                        return pw;
              return null;
    public synchronized void update(SessionEvent evt)
              if (evt instanceof NewParticipantEvent)
         Participant p = ((NewParticipantEvent)evt).getParticipant();
    System.err.println(" - A new participant had just joined: " + p.getCNAME());
    public synchronized void update( ReceiveStreamEvent evt)
         RTPManager mgr = (RTPManager)evt.getSource();
    Participant participant = evt.getParticipant();     // could be null.
    ReceiveStream stream = evt.getReceiveStream(); // could be null.
              if (evt instanceof RemotePayloadChangeEvent)
    System.err.println(" - Received an RTP PayloadChangeEvent.");
    System.err.println("Sorry, cannot handle payload change.");
              System.exit(0);
              else
              if (evt instanceof NewReceiveStreamEvent)
              try {
    stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
              // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
                        if (ctl != null)
    System.err.println(" - Recevied new RTP stream: " + ctl.getFormat());
                        else
    System.err.println(" - Recevied new RTP stream");
                        if (participant == null)
    System.err.println(" The sender of this stream had yet to be identified.");
                        else
    System.err.println(" The stream comes from: " + participant.getCNAME());
    // create a player by passing datasource to the Media Manager
    Player p = javax.media.Manager.createPlayer(ds);
                        if (p == null)
                        return;
                   p.addControllerListener(this);
                        p.realize();
         PlayerWindow pw = new PlayerWindow(p, stream);
         playerWindows.addElement(pw);
                   synchronized (dataSync)
                        dataReceived = true;
                        dataSync.notifyAll();
              catch (Exception e)
         System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
                        return;
              else
              if (evt instanceof StreamMappedEvent)
                   if (stream != null && stream.getDataSource() != null)
                        DataSource ds = stream.getDataSource();
              // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
         System.err.println(" - The previously unidentified stream ");
                        if (ctl != null)
         System.err.println(" " + ctl.getFormat());
         System.err.println(" had now been identified as sent by: " + participant.getCNAME());
              else
              if (evt instanceof ByeEvent)
    System.err.println(" - Got \"bye\" from: " + participant.getCNAME());
              PlayerWindow pw = find(stream);
              if (pw != null)
                        pw.close();
              playerWindows.removeElement(pw);
    public synchronized void controllerUpdate(ControllerEvent ce)
              Player p = (Player)ce.getSourceController();
              if (p == null)
              return;
         // Get this when the internal players are realized.
              if (ce instanceof RealizeCompleteEvent)
              PlayerWindow pw = find(p);
              if (pw == null)
              // Some strange happened.
              System.err.println("Internal error!");
                        System.exit(-1);
              pw.initialize();
              pw.setVisible(true);
              p.start();
              if (ce instanceof ControllerErrorEvent)
              p.removeControllerListener(this);
              PlayerWindow pw = find(p);
              if (pw != null)
                        pw.close();
              playerWindows.removeElement(pw);
         System.err.println("AVReceive2 internal error: " + ce);
    class SessionLabel
              public String addr = null;
              public int port;
              public int ttl = 1;
    SessionLabel(String session) throws IllegalArgumentException
              int off;
              String portStr = null, ttlStr = null;
              if (session != null && session.length() > 0)
         while (session.length() > 1 && session.charAt(0) == '/')
              session = session.substring(1);
              // Now see if there's a addr specified.
                        off = session.indexOf('/');
                        if (off == -1)
                        if (!session.equals(""))
                   addr = session;
                        else
              addr = session.substring(0, off);
              session = session.substring(off + 1);
              // Now see if there's a port specified
              off = session.indexOf('/');
                        if (off == -1)
                        if (!session.equals(""))
                        portStr = session;
                             else
              portStr = session.substring(0, off);
              session = session.substring(off + 1);
              // Now see if there's a ttl specified
                                  off = session.indexOf('/');
                                  if (off == -1)
                                  if (!session.equals(""))
                                            ttlStr = session;
                   else
              ttlStr = session.substring(0, off);
              if (addr == null)
         throw new IllegalArgumentException();
              if (portStr != null)
                        try {
              Integer integer = Integer.valueOf(portStr);
                        if (integer != null)
                                  port = integer.intValue();
              catch (Throwable t)
              throw new IllegalArgumentException();
              else
              throw new IllegalArgumentException();
              if (ttlStr != null)
                        try {
              Integer integer = Integer.valueOf(ttlStr);
                        if (integer != null)
                   ttl = integer.intValue();
                        catch (Throwable t)
              throw new IllegalArgumentException();
    class PlayerWindow extends Frame {
         Player player;
         ReceiveStream stream;
         PlayerWindow(Player p, ReceiveStream strm) {
         player = p;
         stream = strm;
         public void initialize() {
         add(new PlayerPanel(player));
         public void close() {
         player.close();
         setVisible(false);
         dispose();
         public void addNotify() {
         super.addNotify();
         pack();
    class PlayerPanel extends Panel {
         Component vc, cc;
         PlayerPanel(Player p) {
         setLayout(new BorderLayout());
         if ((vc = p.getVisualComponent()) != null)
              add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null)
              add("South", cc);
         public Dimension getPreferredSize() {
         int w = 0, h = 0;
         if (vc != null) {
              Dimension size = vc.getPreferredSize();
              w = size.width;
              h = size.height;
         if (cc != null) {
              Dimension size = cc.getPreferredSize();
              if (w == 0)
              w = size.width;
              h += size.height;
         if (w < 160)
              w = 160;
         return new Dimension(w, h);
    public static void main(String args[])
              String[] argv = new String[2];
              argv[0] = "100.210.0.220/42050";
              argv[1] = "100.210.0.220/4002";
              AVReceive2 avReceive = new AVReceive2(argv);
              if (!avReceive.initialize())
         System.err.println("Failed to initialize the sessions.");
              System.exit(-1);
              try {
              while (!avReceive.isDone())
                        Thread.sleep(1000);
              } catch (Exception e) {}
              System.err.println("Exiting AVReceive2");

  • Streaming iTunes to a 'Airplay capable' receiver from a PC

    Can an 'Airplay capable' receiver (for a home stereo) wirelessly stream my itunes library from my home PC without need of downloading a program?  Or, would I need 'Airport'?  I have a windows 7 PC and my receiver would be a Denon AVR1613 that is listed as 'Airplay capable'.  Thank you!

    If you buy this
    http://www.apple.com/airportexpress/
    You can hook it up to your stereo and use it through your wirless network to play all your music from iTunes.

Maybe you are looking for

  • Back up data to a new Mac.

    When you buy a new MAC, you can back up your data, to the new MAC. You can do this process at very beginning when you first set up your new MAC or you can do later, at any time, by using Migration Assistant. What are the difference by using the two p

  • What application do I need to use to download Dreamweaver?

    I'm getting a message which says "This Link needs to be opened with an application"  which application do I need to choose?

  • Scroll Motion not able to initiate

    I need to make sticky menu on the top of the page but I am not able to initiate Scroll Motion dialog box. It is grayed on. I have basic menu with no bells and whistles. No 100% width. I am flabbergasted! Could anyone help me? Thanks a lot Daniela

  • Trial Version Aperture 1.5

    I down loaded the trial version of aperture 1.5 ages ago and bought the licence key after. Unfortunately my hard drive crashed and I've lost the software but still have the licence key. Would anyone help me in getting aperture 1.5 ( just the software

  • Connect search help to standard table

    hi! i want to connect search help to structure P0001-MSTBR, without a repair. is it possible? and if so how? regards yifat