How to use microphone in JavaFX?

Hi there,
Didn't find a similar question in this forum so I'd like to raise it. With JavaFX API, can I use microphone to record a piece of voice and send it to a web/app server?
Thanks.
Edited by: user1165065 on 2012-2-26 下午6:15

With JavaFX API, can I use microphone to record a piece of voice.No, see http://javafx-jira.kenai.com/browse/RT-3458 for to track the feature request.

Similar Messages

  • How to use List within javaFX(*.fx) script?

    How to use java.util.List within javaFX(*.fx) script?
    The following is my code in Java
    PDBFileReader pdbreader = new PDBFileReader();
              pdbreader.setPath("/Path/To/PDBFiles/");
              pdbreader.setParseSecStruc(true);// parse the secondary structure information from PDB file
              pdbreader.setAlignSeqRes(true);  // align SEQRES and ATOM records
              pdbreader.setAutoFetch(true);    // fetch PDB files from web if they can't be found locally
              try{
                   Structure struc = pdbreader.getStructureById(code);
                   System.out.println("The SEQRES and ATOM information is available via the chains:");
                   int modelnr = 0 ; // also is 0 if structure is an XRAY structure.
                   List<Chain> chains = struc.getChains(modelnr);
                   for (Chain cha:chains){
                        List<Group> agr = cha.getAtomGroups("amino");
                        List<Group> hgr = cha.getAtomGroups("hetatm");
                        List<Group> ngr = cha.getAtomGroups("nucleotide");
                        System.out.print("chain: >"+cha.getName()+"<");
                        System.out.print(" length SEQRES: " +cha.getLengthSeqRes());
                        System.out.print(" length ATOM: " +cha.getAtomLength());
                        System.out.print(" aminos: " +agr.size());
                        System.out.print(" hetatms: "+hgr.size());
                        System.out.println(" nucleotides: "+ngr.size()); 
              } catch (Exception e) {
                   e.printStackTrace();
              }The following is my code in JavaFX(getting errors)
    var loadbtn:SwingButton = SwingButton{
        text:"Load"
        action: function():Void{
            var pdbreader = new PDBFileReader();
            var structure = null;
            try{
                structure = pdbreader.getStructure(filepath.text);
                List<Chain> chains = structure.getChains(0);
                foreach (Chain cha in chains){
                        List < Group > agr = cha.getAtomGroups("amino");
                        List < Group > hgr = cha.getAtomGroups("hetatm");
                        List < Group > ngr = cha.getAtomGroups("nucleotide");
            } catch (e:IOException) {
                e.printStackTrace();
        };I'm using Netbeans 6.5 with JavaFX
    (PDBFileReader, Chain, Structure etc are classes from my own package, already added to the library folder under the project directory)
    Simply put, How to use List and Foreach in JavaFX?

    We can not use Java Generics syntax in JavaFX. But we can use Java Collection classes using the keyword 'as' for type-casting.
    e.g.
    import java.util.LinkedList;
    import java.util.List;
    import javafx.scene.shape.Rectangle;
    var outerlist : List = new LinkedList();
    var innerlist : List = new LinkedList();
    innerlist.add(Rectangle{
        width: 10 height:10});
    innerlist.add(Rectangle{
        width: 20 height:20});
    outerlist.add(innerlist);
    for (inner in outerlist) {
        var list : List = inner as List;
        for (element in list) {
            var rect : Rectangle = element as Rectangle;
            println("(width, height)=({rect.width}, {rect.height})");
    }

  • How to use HTML in JavaFX controls?

    Does JavaFX support using HTML in JavaFX controls' text? For example, in Swing components:
    button = new JButton("<html><font face=arial size=16><center><b><u>E</u>nable</b></font><br>"
      + "<font face=cambria size=12 color=#ffffdd>middle button</font></html>");
    If no, could we find a workaround?

    Embedding a WebView in a Labeled for HTML Rendering
    A WebView is a node which displays HTML.
    Most controls implement Labeled, or have elements that are Labeled.
    A Labeled has a setGraphic(node) method which allows you to set the graphic attached to the labeled to any given node (including a WebView).
    For instance:
    WebView webview = new WebView();
    webview.getEngine().loadContent("<html><font face=arial size=16><center><b><u>E</u>nable</b></font><br><font face=cambria size=12 color=#ffffdd>middle button</font></html>");
    webview.setPrefSize(150, 50);
    Button buttonWithHTML = new Button("", webview);
    should create a button with html in it (I didn't actually try running the above example).
    Apart from the relatively slow startup time on first use and the overhead (which I can't quantify) of using WebView in this way, there are a couple of jira requests outstanding which make it a little bit of a nuisance.
    RT-25004 Allow for transparent backgrounds in WebView
    RT-25005 Automatic preferred sizing for WebView
    You can vote for the above jira requests or comment on them if such functionality is important to you.
    TextFlow/FXML/CSS Alternative
    Rather than using html in the Labeled, support for the TextFlow control was introduced in Java 8, so that could be used instead.
    TextFlow also works well with FXML and css if you prefer to have the stuff in the TextFlow managed via markup and a declarative styling language.
    Open Feature Request
    There is an open feature request RT-2160 HTML support for text which is currently scheduled for implementation in the initial Java 8 release.  I think the likelihood of it actually being included there is zero percent, though it may be considered for a future release.  You can vote for the issue or add comments to it, or provide an implementation if you are so inclined.
    Implementation Considerations
    A possible implementation would be something which parses the HTML then constructs a TextFlow the parsed HTML according to processing rules which are laid out in laborious mind-numbing detail in the HTML5 spec.
    You could use a relaxed HTML parser such as the validator.nu parser (though there may be others which would be a better fit). 
    A simple implementation would just be to use the parser in the jdk which is used for the swing controls, but that is hopelessly outdated.
    Perhaps, even simpler would to only accept strict html input and just use SAX to parse it out, though things like validator.nu are too difficult to work with.
    Then, for the limited number of parsed tags that you want to support (and you really don't want to support all of HTML5 for something like this - otherwise you would just use WebView), create your TextFlow from the DOM model that your parser has created.
    I wouldn't even both trying to handle most of the stuff in your html string in your implementation, stuff to do with styling, fonts, colors, etc. Those things were never any good in html anyway, and css is better for handling them, so just support stuff commonly used in usual modern day html (take a look at bootstrap html source as an example to see what that might be - if bootstrap doesn't use it, I don't think you should support it).  The stuff you will be supporting are things around document structure like lists, headings, etc. div blocks and span nodes - so only implement that important stuff and delegate everything else to css where it belongs.
    Also make sure your implementation fits in with FXML so that you can easily embed your html subset in an FXML doc.

  • How to use constructer for javafx class

    hi
    when i create an instance of javafx class i do like this :
    var instance = ClassName{
    attribute1 : value1
    attribute2 : value2
    so i have to put all attributes as public ...wich is not respect the OOP rules !!
    how can i avoid this ?
    thx

    to preserve encapsulation you can use the public-init modifier like so
    public-init var foo;This allows initialization from public and read from public but write only from within the same script (file).
    All of the access modifiers are explained here: [http://java.sun.com/javafx/1/tutorials/core/modifiers/|http://java.sun.com/javafx/1/tutorials/core/modifiers/]

  • How to use microphone

    Hi everybody,
    my program should recieve data from a microphone in real time. Does anybody know how to do this?
    Thanks,
    efmdg

    Yeah, I've done this. You need to set the audio input in windoze to make sure you have the mic selected, but then it's easy.
    I'm feeling lazy, so here's the entire source for a fast and dirty voice chat program I wrote a while ago. It might get mangled by the forum software.
    package vox;
    * Title:        Vox
    * Description:  Voice communications over a LAN
    * Designed for Quake Deathmatch
    * Copyright:    � Edward Asquith 2001
    * Company:      Splat! Software
    * @author Edward Asquith
    * @version 0.1
    import java.net.*;
    import javax.sound.sampled.*;
    public class Vox {
      public static final AudioFormat FORMAT = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 16000.0f, 16, 1, 2, 16000.0f, true);
      public static final int PORT = 6000;
      public static void main(String[] args) {
        Vox app = new Vox(args);
      public Vox(String[] args) {
        DatagramSocket socket = null;
        DatagramPacket packet = new DatagramPacket(new byte[]{1},1);
        InetAddress remote = null;
        try {   
          if (args.length==0) {
            System.out.println("Waiting for partner...");
            socket = new DatagramSocket(PORT);
            socket.receive(packet);
            socket.connect(packet.getAddress(),PORT);
          } else {
            socket = new DatagramSocket(PORT);
            socket.connect(InetAddress.getByName(args[0]),PORT);
        }catch (Exception exec) {
          System.out.println("Exception creating connection:");
          exec.printStackTrace(System.out);
        System.out.println("Connected to partner...");
        Record rec = new Record(socket);
        Play ply = new Play(socket);
        rec.start();
        ply.start();
    class Record implements Runnable {
      private TargetDataLine line = null;
      private DatagramSocket connection = null;
      private InetAddress address= null;
      private Thread thread = null;
      public Record(DatagramSocket socket) {
        connection = socket;
        address = connection.getInetAddress();
      public void start() {
        thread = new Thread(this);
        thread.setName("Record");
        thread.start();
      public void stop() {
          thread = null;
      public void run() {
        DataLine.Info info = new DataLine.Info(TargetDataLine.class, Vox.FORMAT);
        try {
            line = (TargetDataLine) AudioSystem.getLine(info);
            line.open(Vox.FORMAT, line.getBufferSize());
        } catch (LineUnavailableException exec) {
            System.out.println("Record: Audio Input not ready.\n"+exec.getMessage());
            System.exit(3);
        } catch (Exception exec) {
            System.out.println("Record: Fatal Exception:\n"+exec.getMessage());
            System.exit(4);
        int frameSizeInBytes = Vox.FORMAT.getFrameSize();
        int bufferLengthInFrames = line.getBufferSize() / 8;
        int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
        int minPacketSize = (int)(bufferLengthInBytes/1.5);
        byte[] data;
        int bytesAvailable;
        line.start();
        System.out.println("Record started...");
        while (thread != null) {
          // Send data only when we have a buffer of at least 50%
          if ((bytesAvailable = line.available())>=minPacketSize) {
            data = new byte[bytesAvailable];
            line.read(data,0,bytesAvailable);
            try {
              connection.send(new DatagramPacket(data,bytesAvailable));
            }catch(Exception exec) {
              System.out.println("Record: Exception sending packet:\n"+exec.getMessage());
          try {
            thread.sleep(50);
          }catch(InterruptedException exec) {}
        line.stop();
        line.flush();
        line.close();
        line = null;
    class Play implements Runnable {
      public final int BUFFER = 8000;
      private SourceDataLine line = null;
      private DatagramSocket connection = null;
      private Thread thread = null;
      public Play(DatagramSocket socket) {
        connection = socket;
      public void start() {
        thread = new Thread(this);
        thread.setName("Play");
        thread.start();
      public void stop() {
          thread = null;
      public void run() {
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, Vox.FORMAT);     
        try {
            line = (SourceDataLine) AudioSystem.getLine(info);
            line.open(Vox.FORMAT, BUFFER);
        } catch (LineUnavailableException exec) {
            System.out.println("Play: Audio Output not ready.\n"+exec.getMessage());
            System.exit(5);
        } catch (Exception exec) {
            System.out.println("Play: Fatal Exception:\n"+exec.getMessage());
            System.exit(6);
        line.start();
        DatagramPacket packet = new DatagramPacket(new byte[65536],65536);
        System.out.println("Play started...");
        while (thread != null) {
          try {
            connection.receive(packet);
          }catch(Exception exec) {
            System.out.println("Play: Exception receiving packet:\n"+exec.getMessage());
          line.write(packet.getData(),0,packet.getLength());
          packet = new DatagramPacket(new byte[65536],65536);
          thread.yield();
        line.stop();
        line.flush();
        line.close();
        line = null;
    }Remember to substitute > for & gt ;

  • How to use built in microphone on ipad3 I have Siri on but no icon shows on my keyboard just want to record voice

    How to use built in microphone on ipad3 just for audio no dictation

    If you just want to record a a voice memo, use the included Voice Memos app. That has nothing to do with Siri.

  • How to use earphones microphone (iMac late 2006)?

    Hey,
    On the late 2006 iMac, there are two jacks, One microphone and one speaker/earphones..
    How can I use my Klipsch S4i's microphone with my iMac? As I can't use both the jacks at the same time, which is what I need :/
    Is there something I could buy? (I really want to use my earphones microphone)
    Thanks, Seb

    Seb_XD wrote:
    Sorry - I just found this:
    http://www.amazon.co.uk/StarTech-com-USB-2-0-Audio-Adapter/dp/B000NPKGGK/ref=sr_ 1_8?s=computers&ie=UTF8&qid=1324394815&sr=1-8
    And: http://www.amazon.co.uk/Dynamode-USB-2-0-Sound-Card/dp/B0010JP9CY/ref=sr_1_1?s=c omputers&ie=UTF8&qid=1324394869&sr=1-1
    I don't suppose these would work?
    Thanks again, Seb
    Re: How to use earphones microphone (iMac late 2006)? 
    Just wanted to remind you about this post.
    Thanks again, Your amazing!

  • How to use DoubleBinding to multiply two TextFields in javafx fxml appl

    Hi everyone!
    I want to multiply two TextFields created with Scene Builder.
    how to use DoubleBinding to multiply two TextFields in javafx fxml application.
    I shall be very gratefull to you for this guidance.
    Regards
    Tanvir

    Hi tanvir,
    I don't think it is pretty hard. Here is simple code below which grabs the value of Textfield and sums them up and update to the DoubleProperty.
    //t1: TextField
    //t2: TextField
    //sumProperty :DoubleProperty
    double sum = 0;
    try{
         double d1 = Double.parseDouble( t1.getText());
         double d2 = Double.parseDouble( t2.getText());
         sum = d1+d2;
         sumProperty.set(sum);
    }catch(NumberFormatException nfe){
         nfe.printStackTrace();
    }   Thanks
    Narayan

  • Urgent: how to use cookies or session in javafx

    Hi....
    i am new to javafx and need help to learn how to use cookies and session in javafx.i want to create a simple website using javafx.....
    Urgent reply is requested
    mufaddal

    Please correct me if I'm wrong: I think LiveConnect is not supported on IE, and Mozilla has plans to discontinue it.
    Didn't an earlier version of JavaFX allow access to the Applet instance, including the AppletContext? Seems to me, just generally, that JavaFX applets are hobbled unless they have that functionality available. Cookies are one example. Also applet parameters, hyperlinks, and the browser status display.
    Especially hyperlinks.

  • HOW DO use the Mikey 2.0 iPod and iPhone Microphone with my IPHONE4

    HOW DO use the Mikey 2.0 iPod and iPhone Microphone with my IPHONE4

    Did the microphone come with a user manual? You might contact support for the microphone.
    Just so you know the iPhone 4 has a built-in microphone

  • Anybody have any example on how to use javafx.stage.Popup

    I wants to popup an customerize UI stage to let user to something, and found there have a javafx.stage.Popup class. Any example for how to use it, seems it no titile bar and not OK and cancel button? Search for Forum seems don't find an useful one.
    Edited by: 931222 on Oct 22, 2012 8:54 AM

    follow up.

  • How to use JavaScript in Web bean generated JSP

    I want to do some simple JavaScript validations (for example, checking if a particular field is empty) in the JSP page rendered by the data web bean. Because the HTML is rendered by the bean, I'm not able to refer to the HTML controls in the JSP page. I'm not even able to refer to the form with the following standard piece of JavaScript code - "document.forms[0].control_name".
    Is anybody aware of how to use JavaScript with these rendered JSP pages?

    You just have to add it like and applet , including this line in your JSP or JSF
    <script src="http://dl.javafx.com/dtfx.js"></script>Then add the applet
    <script>
        javafx(
                  archive: "./resources/jar/Draw.jar",
                  width: 400,
                  height: 200,
                  code: "Draw",
                  name: "Draw"
    </script>./resources/jar/Draw.jar - is the path and the name of the jar

  • Satellie A100: How to use MMC card in card reader

    Hi everybody,
    first of all I have a Toshiba Satellie A100 Notebook.
    And now my question: at the front of the (closed) Notebook, there is card reader slot, right next to microphone and volume,etc.
    I have a MMC card of my mobile phone, but it doesn't fit in becuse the slot I much to big. Do i need an adapter? I'm afraid, that i won't get it out anymore afterwards!
    Can somebody help me please?!
    Thanks!
    grettings, thomas87

    No, i don't mean the express-card-slot on the left side of the notebook.
    sorry, it is a satellie A100-773.
    I have already looked into the manuals and there is a cardreader SD/MMC/...
    under the slot there are also symbols of different mediacards!
    so it does really exist! =)
    but how to use it? it's such a big slot, and the mmc is rather small. so how should i put in the mmc? more left, or right or in the middle...you know what i mean? or do i need an adapter?
    thanks, thomas87

  • How to use PAL-N for Video Input

    Is not a problem with the conection or the cables the problem is that source is PAL-N and I see the image in black and white.
    Thre isn't a problem with the input of the card because with the same cables and the same connector but with a source in NTSC (a playstation) worked great
    My question is if the problem with the sources in PAL-N is a limitation of the hardware or with with software and if it is workaround
    Thanks

    Quote
    Originally posted by kamaleonb
    Is not a problem with the conection or the cables the problem is that source is PAL-N and I see the image in black and white.
    Thre isn't a problem with the input of the card because with the same cables and the same connector but with a source in NTSC (a playstation) worked great
    My question is if the problem with the sources in PAL-N is a limitation of the hardware or with with software and if it is workaround
    Thanks
    yes men. there are 3 choices .a s-video,a  composite and the another one i can't remeber the clear.
    And excuse me. did you play "playstaion" on your pc? how can you do that. i have been try for this. but you know ps have 3 line for conect with TV. one for video, one for audio and another one i don't know how to use.
    my problem is when i put my ps on my pc. there are only one socket on video card(MX460-VT) for conect video line. no socket for audio in. some body told me it's on the sounds card. but i did. there are only 3 hell. one for speaker, one for microphone the last one is "line-in" so i put the audio line(from ps) in to he line-in . but i got nothing. how can you do this? tell me please!
    Thank you very much.

  • How to use Preloader with stand-alone application in Eclipse? Thank you.

    My IDE is eclipse and my project is a stand-alone application(pure CS architecture with OSGI framework).
    How to use Preloader thus the preloader would be started before my main Application and hid later?
    I found some code in http://docs.oracle.com/javafx/2/deployment/preloaders.htm#BABGGDJG
    but I still don't know how to deploy the Preloader with my startup Application in OSGI framework.
    I give some code of my startup application below:
    public class MyPrjMain extends Application
        private static Stage primaryStage;
         public void start(final Stage stage)
            throws BusinessException
            primaryStage = stage;
            init(primaryStage);
            primaryStage.show();
    }Thanks very much, everybody.
    Edited by: Slash Wang on 2013-2-27 下午5:36

    Your question has already been answered on StackOverflow:
    http://stackoverflow.com/questions/15126210/how-to-use-javafx-preloader-with-stand-alone-application-in-eclipse/15148611

Maybe you are looking for

  • How to avoid 'for update' clause ?

    Hi All, I am trying to build the data-entry form based on complex view. I've got JBO-26080 Error while selecting entity... (ORA-02014 select ... for update). Is it possible to delete 'for update' clause in select ? What is the best practice to deal w

  • Installing IDES on drive other than C:

    We are trying to install MSA Workgroup server and installed SQL on C: drive but with the database location as D: drive During installation, IDES was not loaded and switchdb would not manually copy it afterwards because it looks to C: by default Has a

  • Fullscreen video playback on external monitor (overlay problem?)

    I want to watch videopodcasts via iTunes fullscreen on my external Monitor/TV. It works fine with Quicktime and WindowsMediaPlayer but iTunes doesn't play my Videos in Fullscreen on my external Monitor. I had the idea it is because the overlay mode i

  • TrackPoint on a T420s not showing up anywhere and not working

    Hi folks, seems like Arch doesn't recognize that my thinkpad has a TrackPoint. coldcache ~ % find /dev/input/event* -exec udevadm info --attribute-walk --name={} \; | grep -e product -e name | sort -u ATTRS{name}=="AT Translated Set 2 keyboard" ATTRS

  • Connect MacBook to Performa 6400

    I want to connect my Performa 6400 to my MacBook. Both have Ethernet. What's the proper technique?