?
Solved

NoPlayerException of JMF

Posted on 2003-03-05
5
Medium Priority
?
1,129 Views
Last Modified: 2007-12-19
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
Comment
Question by:MichaelMaromm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 8070804
 Can you post the exact error message?
0
 

Accepted Solution

by:
simonletter earned 200 total points
ID: 8125622
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
 

Expert Comment

by:CleanupPing
ID: 9058909
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
 
LVL 35

Expert Comment

by:TimYates
ID: 9762215
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question