Results 1 to 16 of 16
  1. #1
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Exclamation Catching exception from another library (class)

    Hi,

    I'm using IBM MPEG-4 toolkit to playback video files/stream.

    I managed to catch exceptions while executing control commands. such as player.play, stop and whatever... And it plays without problems.

    But if i have corrupted video file, i get some exception into the console window while playback. I want to catch and log them, but i cant, because it's not try{play}catch{exception log} situation. How can catch those?

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    What do you mean by it's not a try catch situation??
    Swastik

  3. #3
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    basicly pogram looks like that:

    frame.add(player.getRendererComponent())
    button.addActionListener(new play())

    ActionListener play{
    try
    {player.play()}
    catch
    {exception and log}
    }

    So if there are any problems starting playback - I log them. But playback continues and new exceptions are thrown into console, but i cannot read them, because they are not realeated to start.play... its related to player.* rendered component into frame.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Post your catch block.

  5. #5
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    private class playIT implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    mainFrame.add(player.getRendererComponent(), BorderLayout.CENTER);
    player.stopUrl();
    player.playUrl(fileName);
    try {
    player.start();
    }
    catch (Exception f)
    {
    System.out.println("I've got you!");
    }
    }
    }

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Wrap all the code in your actionPerformed method in the try catch and see if it catches that exception.

  7. #7
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    Well, nothing.
    The code i posted above catches first exception related to starting playback and gives message, but after 10 seconds of playback i have another exception i cannot catch. and i have no ideo how can i catch it or where should i put try/catch method.

    i've tried to put

    ExceptionListener listener = new ExceptionListener() {
    public void exceptionThrown(Exception z) {
    System.out.println("Error");
    }
    };

    anythere in the program, but i think it also should be somewhere in the specific place.

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Post the stacktrace of the exception.

  9. #9
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    It's gonna take me some time...

  10. #10
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    D:\JAVA\KURSINIS>java -classpath .;IBMPlayerForMpeg4SDK.jar JavaMpeg

    // THIS IS FIRST ERROR AND IT OCCURS ON PLAYER.START()

    java.lang.IllegalStateException
    at I4f.start(Unknown Source)
    at JavaMpeg$groti.actionPerformed(JavaMpeg.java:177)
    at java.awt.MenuItem.processActionEvent(Unknown Source)
    at java.awt.MenuItem.processEvent(Unknown Source)
    at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
    at java.awt.MenuComponent.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Warning - The decoder supports only SIMPLE_OBJECT and the Object type is Other


    // THIS IS SECOND ERROR AFTER 10 SECONDS OF PLAYING
    Exception - No marker bit before 'vop time increment'



    We get second error because I intentionally modified video file to get any error. To make a program tracking video stream errors. BUt i cannot vatch it, only see it in console.

    You can get code, video file and library here: ftp://217.117.27.34/Upload/Marius/2/KURSINIS.ZIP

    But it's in my native language. To open file use 1st menu 1st item. to play use 2nd menu 1st item.

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    That player/decoder obviously uses its own Threads; those Threads throw the Exception. Can you reach those Threads? If so, the method Thread.setUncaughtExceptionHandler( ... ) can be of use.

    kind regards,

    Jos

  12. #12
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    Well library decompiling does not show any string named Thread...

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by ezilka View Post
    Well library decompiling does not show any string named Thread...
    Well, if that method doesn't start another Thread you should be able to catch any Exception thrown from it. Try to catch the mother of all Exceptions, the Throwable.

    kind regards,

    Jos

  14. #14
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    That's the main problem. HOW? How can I catch any exception not depending on try function catch exception.

  15. #15
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by ezilka View Post
    That's the main problem. HOW? How can I catch any exception not depending on try function catch exception.
    So that method does create another Thread and that thread throws an Exception somewhere in the (near) future?

    kind regards,

    Jos

  16. #16
    ezilka is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    It's video playback... file can be hours long, so basically I can get exception during all this play back time. Player.start() just initiates that playback.

Similar Threads

  1. Replies: 1
    Last Post: 01-03-2010, 10:48 PM
  2. Replies: 2
    Last Post: 09-19-2009, 12:22 AM
  3. URGENT: How to include a library in Java class path?
    By gsmurthy30 in forum New To Java
    Replies: 3
    Last Post: 09-15-2008, 05:58 PM
  4. URGENT: How to include a library in Java class path?
    By gsmurthy30 in forum Advanced Java
    Replies: 1
    Last Post: 09-15-2008, 09:39 AM
  5. AWT - catching click button event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-12-2008, 12:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •