• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1154
  • Last Modified:

NoPlayerException of JMF

Hi,

I tried to create a player for .wav and .avi files,
but It throws the NoPlayerException, which says that no player is exit for this format (this is true for any otehr kinds of file).

Please tell me, what to do that my program will find the approptiate player ?

    Thanks
    Michael
0
MichaelMaromm
Asked:
MichaelMaromm
1 Solution
 
girionisCommented:
 Can you post the exact error message?
0
 
simonletterCommented:
This works for me, it plays the sound alright :)

code:
        try {
            // Player player = Manager.createPlayer(new URL("file://C:/Program Files/QuickTime/Sample.mov"));
            Player player = Manager.createPlayer(new URL("file://C:/WINNT/Media/tada.wav"));
            if (player.getDuration() == player.DURATION_UNBOUNDED) {
                System.out.println("duration unbounded");
            }
            if (player.getDuration() == player.DURATION_UNKNOWN) {
                System.out.println("duration unknown");
            }

            player.realize();
            player.prefetch();
            while (player.getState() != Player.Prefetched) {
                Thread.sleep(100);
            }
            System.out.println("Duration " + player.getDuration().getSeconds());
            System.out.println("StopTime " + player.getStopTime().getSeconds());

            javax.media.Control[] controls = player.getControls();
            for (int i = 0; i < controls.length; i++) {
                if (controls[i] instanceof BitRateControl) {
                    System.out.println("BitRateControl");
                    BitRateControl c = (BitRateControl)controls[i];
                    System.out.println("    Bitrate " + c.getBitRate());
                    System.out.println("    MaxSupportedBitRate " + c.getMaxSupportedBitRate());
                    System.out.println("    MinSupportedBitRate " + c.getMinSupportedBitRate());
                } else if (controls[i] instanceof BufferControl) {
                    System.out.println("BufferControl");
                    BufferControl c = (BufferControl)controls[i];
                    System.out.println("    BufferLength " + c.getBufferLength());
                    System.out.println("    EnabledThreshold " + c.getEnabledThreshold());
                    System.out.println("    MinimumThreshold " + c.getMinimumThreshold());
                } else if (controls[i] instanceof CachingControl) {
                    System.out.println("CachingControl");
                } else if (controls[i] instanceof ExtendedCachingControl) {
                    System.out.println("ExtendedCachingControl");
                } else if (controls[i] instanceof FormatControl) {
                    System.out.println("FormatControl");
                    FormatControl c = (FormatControl)controls[i];
                    System.out.println("    " + c.getFormat().getDataType().getName());
                    System.out.println("    " + c.getFormat().getEncoding());
                    System.out.println("    " + c.getFormat().toString());
                    Format[] formats = c.getSupportedFormats();
                    System.out.println("    SupportedFormats " + formats.length);
                } else if (controls[i] instanceof FrameGrabbingControl) {
                    System.out.println("FrameGrabbingControl");
                } else if (controls[i] instanceof FramePositioningControl) {
                    System.out.println("FramePositioningControl");
                } else if (controls[i] instanceof FrameProcessingControl) {
                    System.out.println("FrameProcessingControl");
                } else if (controls[i] instanceof FrameRateControl) {
                    System.out.println("FrameRateControl");
                } else if (controls[i] instanceof GainControl) {
                    System.out.println("GainControl");
                    GainControl c = (GainControl)controls[i];
                    c.setLevel((float)1.0);
                    System.out.println("    " + c.getDB());
                    c.setDB((float)0);
                } else if (controls[i] instanceof H261Control) {
                    System.out.println("H261Control");
                } else if (controls[i] instanceof H263Control) {
                    System.out.println("H263Control");
                } else if (controls[i] instanceof KeyFrameControl) {
                    System.out.println("KeyFrameControl");
                } else if (controls[i] instanceof MonitorControl) {
                    System.out.println("MonitorControl");
                } else if (controls[i] instanceof MpegAudioControl) {
                    System.out.println("MpegAudioControl");
                } else if (controls[i] instanceof PacketSizeControl) {
                    System.out.println("PacketSizeControl");
                } else if (controls[i] instanceof PortControl) {
                    System.out.println("PortControl");
                } else if (controls[i] instanceof QualityControl) {
                    System.out.println("QualityControl");
                } else if (controls[i] instanceof RTPControl) {
                    System.out.println("RTPControl");
                } else if (controls[i] instanceof SilenceSuppressionControl) {
                    System.out.println("SilenceSuppressionControl");
                } else if (controls[i] instanceof StreamWriterControl) {
                    System.out.println("StreamWriterControl");
                } else if (controls[i] instanceof TrackControl) {
                    System.out.println("TrackControl");
                }
            }

            Thread.sleep((long)player.getDuration().getSeconds() * 1000);
            System.out.println((long)(player.getDuration().getSeconds() * 1000));
            player.stop();
            player.deallocate();
            player.close();
        } catch (Throwable t) {
            t.printStackTrace();
        }
        System.exit(0);
    }
0
 
CleanupPingCommented:
MichaelMaromm:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
TimYatesCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept simonletter's comment as answer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TimYates
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now