Play sound with JMF on xletview

How to play a sound (such as midi) file with JMF?
now I test it on xletview,
Manager.createPlayer(new MediaLocator("file://D:/Project/Test/classes/0.mid"));
how can I use relative path instead of using absolute path?
thx for your help

Hi Redduke
Althought your post is from July 2007 I will reply you ;)
I'm trying to plays video on JMF (on a MHP project), but I can't. Nevertheless I am capable to play audio from two different ways:
1. Via HSound: You create an HSound player, load the file on it and then plays it
2. Via JMFPlayer: Like before but with JMF
The restriction is that the sound would be in .mp1 o .mp2 format. I try with .mp2 and i can plays audio.
Regards ;)

Similar Messages

  • Play movie with JMF

    Hey,
    I just started out with JMF (I wanted to play a movie with java).
    I got this code:
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.media.*;
    * Demonstrate simple code to play a movie with Java Media Framework.
    * @author Ian F. Darwin, http://www.darwinsys.com/
    * @version $Id: JMFPlayer.java,v 1.9 2004/02/09 03:21:20 ian Exp $
    public class NewJApplet extends JPanel implements ControllerListener {
        /** The player object */
        Player thePlayer = null;
        /** The parent Frame we are in. */
        JFrame parentFrame = null;
        /** Our contentpane */
        Container cp;
        /** The visual component (if any) */
        Component visualComponent = null;
        /** The default control component (if any) */
        Component controlComponent = null;
        /** The name of this instance's media file. */
        String mediaName;
        /** The URL representing this media file. */
        URL theURL;
        /** Construct the player object and the GUI. */
        public NewJApplet(JFrame pf, String media) {
            parentFrame = pf;
            mediaName = media;
            // cp = getContentPane();
            cp = this;
            cp.setLayout(new BorderLayout());
            try {
                theURL = new URL(getClass().getResource("."), mediaName);
                thePlayer = Manager.createPlayer(theURL);
                thePlayer.addControllerListener(this);
            } catch (MalformedURLException e) {
                System.err.println("JMF URL creation error: " + e);
            } catch (Exception e) {
                System.err.println("JMF Player creation error: " + e);
                return;
            System.out.println("theURL = " + theURL);
            // Start the player: this will notify our ControllerListener.
            thePlayer.start(); // start playing
        /** Called to stop the audio, as from a Stop button or menuitem */
        public void stop() {
            if (thePlayer == null) {
                return;
            thePlayer.stop(); // stop playing!
            thePlayer.deallocate(); // free system resources
        /** Called when we are really finished (as from an Exit button). */
        public void destroy() {
            if (thePlayer == null) {
                return;
            thePlayer.close();
        /** Called by JMF when the Player has something to tell us about. */
        public synchronized void controllerUpdate(ControllerEvent event) {
            // System.out.println("controllerUpdate(" + event + ")");
            if (event instanceof RealizeCompleteEvent) {
                if ((visualComponent = thePlayer.getVisualComponent()) != null) {
                    cp.add(BorderLayout.CENTER, visualComponent);
                if ((controlComponent = thePlayer.getControlPanelComponent()) != null) {
                    cp.add(BorderLayout.SOUTH, controlComponent);
                // re-size the main window
                if (parentFrame != null) {
                    parentFrame.pack();
                    parentFrame.setTitle(mediaName);
        public static void main(String[] argv) {
            JFrame f = new JFrame("JMF Player Demo");
            Container frameCP = f.getContentPane();
            NewJApplet p = new NewJApplet(f,
                    argv.length == 0 ? "file:/C:/Users/Patrick Kos/Pictures/BAA.avi"
                    : argv[0]);
            frameCP.add(BorderLayout.CENTER, p);
            f.setSize(200, 200);
            f.setVisible(true);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }but I always get a unable to handle format exception, expect with mp3 files.
    But i"ve looked up the supported formats and its says its supported so??

    i get this error
    Unable to handle format: XVID, 320x240, FrameRate=29.9, Length=230400 0 extra bytes
      Unable to handle format: unknown, 22050.0 Hz, 0-bit, Stereo, Unsigned, 8000.0 frame rate, FrameSize=9216 bits
    Failed to realize: com.sun.media.PlaybackEngine@7259da
    Error: Unable to realize com.sun.media.PlaybackEngine@7259da
    Exception in thread "main" javax.media.CannotRealizeException
            at javax.media.Manager.blockingCall(Manager.java:2005)
            at javax.media.Manager.createRealizedPlayer(Manager.java:580)
            at projectnemo.NewJApplet.main(NewJApplet.java:102)

  • Quicktime movies playing sound with no picture (only in firefox)

    Hi There,
    I'm having a weird issue with quicktime in firefox on apple macs. I'm not really familiar with macs and I was wondering if someone can offer a solution? When I visit the page in firefox on a mac the video plays sound but not the picture. This seems to happen to all firefox browsers that I have tested.
    I have a test link here for people to look at. http://www.wellcom.net.au/quicktime.aspx

    To Apple Discussions!
    Thank you for providing the link for others to test for you. A got a flash video which I had no problem viewing with sound. The picture did take a few seconds to appear. However, the sound came in right away. Here is the direct video link: http://www.wellcom.net.au/images/movingimages/BookCity.mp4
    Picture & sound was instant from the .mp4 link.
    Make sure you have the latest versions of Adobe Flash Player Software, repair permissions & restart your computer.
    If the above does not work, then please advise which version of FireFox you are using?

  • Phone will play sound with headphones only?

    My iPhone 4S will not play sound except on headphones.  When I push the up or down button for volume adjustment it doesn't change on the screen at all ( like bars going up / down?)

    1. Remove the headphone.
        If you see red light in the headphone port, plug the headphone
        in and out of the port 5 or 6 times to flip the microswitch inside.
        Sound output may be stuck in the digital mode.
    2. Reset PRAM.  http://support.apple.com/kb/PH4405
    Best.

  • My computer only plays sound with headphones

    Product Name: pavilion pd6 
    product number: vm22ua#aba
    operating system: Windows 7
    error: my laptop only plays sound when i have headphones plugged in
    no changes made to the system before the issue occurred. new drivers were installed for my audio settings after the problem occurred but nothing worked.

    Do the Music and Videos app still play through the iPad's speakers ? If so then have you got notifications muted ? Only notifications (including games) get muted, so the Music and Videos apps and headphones, still get sound.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

  • Playing sound with labview

    I have saved some sound clips into a matrix. Now I want to play the
    samples back (there are 10 of them) when I press the respective button
    (button 1 for sound 1, button 2 for sound 2, etc). My problem is I can't
    get the sounds to play when I press the button. I've tried a case
    structure that would select the sound, but I also tried to let the sound
    play (flipping a boolean). I can't get it to work. Does someone have a
    VI that I can get ideas, or does someone want to chit-chat?
    *peace*
    DG
    [email protected]
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    Hi Dorian,
    I'm working on something similar. Have you looked at the telephone
    dialer example that comes with labview (5.0 and 5.1)? That's a pretty
    decent start.
    Does someone have something better?
    Cid
    In article <87di90$dmv$[email protected]>,
    Dorian Grey wrote:
    >
    >
    > I have saved some sound clips into a matrix. Now I want to play the
    > samples back (there are 10 of them) when I press the respective button
    > (button 1 for sound 1, button 2 for sound 2, etc). My problem is I
    can't
    > get the sounds to play when I press the button. I've tried a case
    > structure that would select the sound, but I also tried to let the
    sound
    > play (flipping a boolean). I can't get it to work. Does someone have a
    > VI that I can get ideas, or does someone w
    ant to chit-chat?
    >
    > *peace*
    >
    > DG
    >
    > [email protected]
    >
    > Sent via Deja.com http://www.deja.com/
    > Before you buy.
    >
    Sent via Deja.com http://www.deja.com/
    Before you buy.

  • How to record sound with JMF?

    I just want to record a clip of sound and save it in a WAV file. I exhausted the web but just couldn't find a tutorial. Would someone be kind enough to give me a tutorial or a sample code? The simpler the better. Thanks.

    Hi there,
    The following lines of code will record sound for 5 sec and save it in file C:/test.wav.
    import java.io.IOException;
    import javax.media.CannotRealizeException;
    import javax.media.DataSink;
    import javax.media.Format;
    import javax.media.Manager;
    import javax.media.MediaLocator;
    import javax.media.NoDataSinkException;
    import javax.media.NoProcessorException;
    import javax.media.NotRealizedError;
    import javax.media.Processor;
    import javax.media.ProcessorModel;
    import javax.media.format.AudioFormat;
    import javax.media.protocol.FileTypeDescriptor;
    public class WAVWriter {
         public void record(){
              AudioFormat format = new AudioFormat(AudioFormat.LINEAR, 44100, 16, 1);
              ProcessorModel model = new ProcessorModel(new Format[]{format}, new FileTypeDescriptor(FileTypeDescriptor.WAVE));
              try {
                   Processor processor = Manager.createRealizedProcessor(model);
                   DataSink sink = Manager.createDataSink(processor.getDataOutput(), new MediaLocator("file:///C:/test.wav"));
                   processor.start();
                   sink.open();
                   sink.start();
                   Thread.sleep(5000);
                   sink.stop();
                   sink.close();
                   processor.stop();
                   processor.close();
              } catch (NoProcessorException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (CannotRealizeException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (NoDataSinkException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (NotRealizedError e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (InterruptedException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args) {
              new WAVWriter().record();
    }I hope this will help. Don't forget to go through JMF guide (http://www.cdt.luth.se/~johank/smd151/jmf/jmf2_0-guide.pdf), especially page 81... it's not always helpfull, but sometimes, it may give you some good answers.
    Happy coding!!!

  • Record / copy playing movie with JMF

    Hi
    I am trying to copy a videofile which I am playing in JMF. It's easy as long as I want the whole video, but how can I cut out a part of the file? Any solution or example?
    Regards
    Saqi

    which type of file formats you are using tell me

  • IPad won't play sound with video? Will play music and radio apps, but not if there is a video component. Same for my iTunes movies.

    Help! My iPad won't play any audio when there is a video component to an app or game.   It will play my music and I can see the video on my movies, but not the movie sound.   Turning off and turning it on again worked as a temporary fix once, but now that is not working either.   Been going on for an week or two?

    Try a system reset.  It cures many ills and it's quick, easy and harmless...
    Hold down the on/off switch and the Home button simultaneously until the screen blacks out or you see the Apple logo.  Ignore the "Slide to power off" text if it appears.  You will not lose any apps, data, music, movies, settings, etc.

  • IPad only plays sound with music and some games

    My iPad was working great until a week ago but now I only have sound for my music. I have no sound when I type (yes I checked to make sure that the keyboard clicks were on). On certain games I have no sound. When I put my headphones on I have sound on Geometry wars but when i take the headphones out I got nothing. Also when I lock my iPad it doesn't make a sound. Any ideas?

    I don't fully understand what's involved but I've found that a System Reset cures many ills.  It's easy, quick and harmless:
    Hold down the on/off switch and the Home button  simultaneously until you see the Apple logo.  Ignore the "Slide to power off" text if it appears.
    A System Reset does not remove any apps, music, movies, etc. nor does it cause any settings to revert back to default.
    Also, you might wish to download the iPad-2 User Guide.  Pay special   attention to page 162.  Note that this Guide also applies to the iPad-1 with IOS 4.3 except for those functions that are not supported by the hardware.
    http://support.apple.com/manuals/#ipad
    Finally, the User Guide can be downloaded at no charge via iBooks and a less comprehensive version of the Guide is included as a Safari bookmark.

  • My hp touchpad only plays sound with headphones..what is the problem??

    what is the problem with my hp touchpad ..i could hear the sound only through the headphones

    http://support.apple.com/kb/TS2802

  • My 15in Pro won't play sound with out headphones.

    The red light is on inide the port also. Ive tried wiggling a tooth pic and head phone jacks in gently but no luck. Any help??

    Try inserting the headphone jack into the port and wiggle that and then remove. May have to do it several times. Other option is to remove the bottom and work the port switch manually to put it back so it doesn't register that a plug is inserted.

  • Please.. need help!! Problem with playing sounds

    Hello, any help at all greatly appreciated.
    I need a dead-certain way of playing sounds with my java application.
    Java media player doesn't seem to be working with sound files with a duration of longer than 30 seconds.
    I need a way of accessing the windows sound API from inside my java app.
    Anyone have any ideas??????

    Hello, any help at all greatly appreciated.
    I need a dead-certain way of playing sounds with my java application.
    Java media player doesn't seem to be working with sound files with a duration of longer than 30 seconds.
    I need a way of accessing the windows sound API from inside my java app.
    Anyone have any ideas??????

  • No sound with ALSA & Fluidsynth enabled (as normal user)

    Ahoy!
    I'm using pure ALSA (no pulseaudio) and I have a problem that when I start Fluidsynth I have no sound anymore. Without starting Fluidsynth, everything is working just fine.
    I can play sound with Fluidsynth enabled though when I add myself to the audio group. However, I didn't need to do that in the past. In fact, I have Fluidsynth up and running with ALSA on my laptop and everything works just fine and I remember reading in the wiki that the user is not supposed to be added to the audio group.
    Here's some information:
    aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: A2G [AuzenTech X-Meridian 2G], device 0: Multichannel [Multichannel]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 0: A2G [AuzenTech X-Meridian 2G], device 1: Digital [Digital]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 7: HDMI 0 [HDMI 0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 8: HDMI 0 [HDMI 0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 9: HDMI 0 [HDMI 0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    cat /proc/asound/cards
    0 [A2G ]: CMI8788 - AuzenTech X-Meridian 2G
    C-Media Oxygen HD Audio at 0xc000, irq 17
    1 [NVidia ]: HDA-Intel - HDA NVidia
    HDA NVidia at 0xfa080000 irq 17
    aconnect -o
    client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
    client 16: 'AuzenTech X-Meridian 2G' [type=kernel]
    0 'AuzenTech X-Meridian 2G MIDI'
    And here's how it looks like when I start Fluidsynth (including the error message I get):
    USER@PROBLEM ~ % speaker-test -c 2
    speaker-test 1.0.28
    Playback device is default
    Stream parameters are 48000Hz, S16_LE, 2 channels
    Using 16 octaves of pink noise
    Rate set to 48000Hz (requested 48000Hz)
    Buffer size range from 2048 to 16384
    Period size range from 1024 to 1024
    Using max buffer size 16384
    Periods = 4
    was set period_size = 1024
    was set buffer_size = 16384
    0 - Front Left
    1 - Front Right
    ^CWrite error: -4,Interrupted system call
    xrun_recovery failed: -4,Interrupted system call
    Transfer failed: Interrupted system call
    USER@PROBLEM ~ % sudo systemctl start fluidsynth.service
    USER@PROBLEM ~ % sudo systemctl status fluidsynth.service
    ● fluidsynth.service - FluidSynth Daemon
    Loaded: loaded (/usr/lib/systemd/system/fluidsynth.service; disabled)
    Active: active (running) since Sat 2014-10-04 10:11:18 UTC; 6s ago
    Main PID: 1017 (fluidsynth)
    CGroup: /system.slice/fluidsynth.service
    └─1017 /usr/bin/fluidsynth -is -a alsa -m alsa_seq -r 48000 /usr/s...
    Oct 04 10:11:19 PROBLEM fluidsynth[1017]: fluidsynth: warning: Requested...d
    Hint: Some lines were ellipsized, use -l to show in full.
    USER@PROBLEM ~ % speaker-test -c 2
    speaker-test 1.0.28
    Playback device is default
    Stream parameters are 48000Hz, S16_LE, 2 channels
    Using 16 octaves of pink noise
    ALSA lib pcm_dmix.c:989:(snd_pcm_dmix_open) unable to create IPC semaphore
    Playback open error: -13,Permission denied
    aconnect -o
    client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
    client 16: 'AuzenTech X-Meridian 2G' [type=kernel]
    0 'AuzenTech X-Meridian 2G MIDI'
    client 128: 'FLUID Synth (1017)' [type=user]
    0 'Synth input port (1017:0)'
    Any ideas?
    Last edited by Janusz11 (2014-10-04 08:26:54)

    Thanks. I've set Fluidsynth up the way it is described in the wiki (FluidSynth). If I'm not mistaken it is already started with the "-a alsa" option through the config file (SYNTHOPTS="-is -a alsa -m alsa_seq -r 48000" ).
    Well, since adding the user to the audio group fixes the problem I'll do that now.

  • No Sound with Vidoes!

    hello!just got an ipod yesterday!wel the first experience was much daunting,but then i enjoyed it!the forum helped a lot in setting up the oh so famous topic "ipod just shows a cd pic with a cable..." ...
    i need help,ipod aint playin sound wit ma videos!anyone has any simple solutions?i dont hv quick time pro cuz,so cant use the MPEG streamline s/w 2 export the converted video...

    well it does play sound with some videos...but the videos that i converted from MPEG,its not playing sound with them!and the ipod is showin some strange blue green illusions when i play my video!guess some one else also faced the same issue,so i'll reset it..?

Maybe you are looking for