Results 1 to 7 of 7
  1. #1
    Menre is offline Member
    Join Date
    Feb 2008
    Posts
    79
    Rep Power
    0

    Default Video MediaPlayer Errors

    Hi All,

    I have worked successfully with media files in some other languages before. I am trying to do that with Java now, but no luck so far. I have a video uploaded to my server and now want to view it with Java MediaPlayer, but I get some error messages. I got the code from a book.

    The two error messages I am getting now are on the same line. I have made a comment for the line and is shown below.

    Line 19: illegal start of expression
    Line 19: ')' expected

    My code is below.

    Java Code:
    /**
     * @(#)MediaPlayer.java
     *This code is lifted from the book learning Java
     *by Patrick Niemeyer et al, 2005
     * @author: Menre 
     * @version 1.00 2009/9/19
     */
     import java.awt.*;
     import java.net.URL;
     import javax.swing.*;
     import javax.media.*;
    
    public class MediaPlayer {
        
        public static void main(String[] args) {
            final JFrame frame = new JFrame("MediaPlayer");
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            URL url = new URL( args[0] );
            final Player player = Manager.createPlayer( % java MediaPlayer http://www.mywebsite/videos/qtv/video_two.mov);
             //the very line above is the line 19
    
            player.addControllerListener( new ControllerListener() {
            	public void controllerUpdate( ControllerEvent ce ) {
            		if ( ce instanceof RealizeCompleteEvent )
            		{
            			Component visual = player.getVisualComponent();
            			Component control = player.getControlPanelControl();
            			if ( visual != null )
            				frame.getContentPane().add( visual, "Center" );
            			  frame.getContentPane().add( control, "South" );
            			  frame.pack();
            			  frame.setVisible( true );
            			  player.start();
            			}
            		}
            	});
            player.realize();
        }
    }
    Could someone have a look at my work please?

    Thanks in advance
    Menre

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

    Default

    The line

    Java Code:
    final Player player = Manager.createPlayer( % java MediaPlayer http://www.mywebsite/videos/qtv/video_two.mov);
    is not a valid java statement.

  3. #3
    Menre is offline Member
    Join Date
    Feb 2008
    Posts
    79
    Rep Power
    0

    Default

    Hi,

    Thanks for your response. How do I correct that line that is not a valid Java statement? How do I link to my video then? The book did not actually put all the code together. I added the link to the url on that line, because the book attempted to explain it with that statement on a separate page without putting all the code together. That might be why I have not been able to get it right so far. Do you have any suggestions?

    Menre

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

    Default

    Read the API specs for the Manager.createPlayer method to see what it expects.
    Perhaps it takes a string.

    P.S If you can't distinguish between correct Java statements and incorrect ones then it is best to stop and start by reading Sun's basic Java tutorial first rather than trying to guess the correct syntax.

  5. #5
    Menre is offline Member
    Join Date
    Feb 2008
    Posts
    79
    Rep Power
    0

    Default

    Hello,

    Thanks for your response. I might have tried already what you referred to with the statement
    "Read the API specs for the Manager.createPlayer method to see what it expects. Perhaps it takes a string."

    I agree that it takes a string and I have looked at it before on the SUN's website before my initial post. But when I entered a string of URL by changing that line 19 to

    Java Code:
     final Player player = Manager.createPlayer( new URL("http://mywebsite.com/videos/qtv/video_two.mov") );
    by following their tutorials, I got more errors thrown at me. Again, I decided building my programm by leave the line 19 to
    Java Code:
     final Player player = Manager.createPlayer( url );
    and I got some error messages that

    'package javax.media does not exist'
    'cannot find symbol class Player'
    'cannot find symbol variable Manager'
    'cannot find symbol class ControllerListener'

    I am using JCreator and it shows where errors are in a programme. I am able to correct some errors myself.
    P.S If you can't distinguish between correct Java statements and incorrect ones then it is best to stop and start by reading Sun's basic Java tutorial first rather than trying to guess the correct syntax.
    There is no guess work here. If you had read my first post correctly, you would notice I mentioned this code was from a book.

    Anyway, thanks for your response and I will use another example to achieve this goal.

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

    Default

    'package javax.media does not exist' means that you are missing some required jar files.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Quote Originally Posted by Menre View Post
    There is no guess work here. If you had read my first post correctly, you would notice I mentioned this code was from a book.

    Anyway, thanks for your response and I will use another example to achieve this goal.
    As r035198x says, you ought to do the tutorials since, if you can't tell what is correct syntax and what isn't, you are seriously likely to end up out of your depth. They don't take long to do, and it'll save you scads of time in the long run.

    Compiler errors like this really aren't "advanced".

    Oh, and you really can't rely on what's in many of these text books, they often have niggling errors in the code and typos. The logic is usually correct and any typos are easy enough to fix, if you already know Java syntax...

Similar Threads

  1. video streaming
    By anniya0n in forum JDBC
    Replies: 3
    Last Post: 05-08-2013, 04:21 PM
  2. Replies: 3
    Last Post: 03-08-2009, 02:51 AM
  3. Video tutorial on EJB
    By mdeepaks in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 01-31-2009, 06:57 AM
  4. can I have video out using USB data
    By papa_china in forum CLDC and MIDP
    Replies: 0
    Last Post: 07-29-2007, 05:29 AM
  5. video stream
    By Alan in forum Advanced Java
    Replies: 2
    Last Post: 05-17-2007, 09:12 AM

Posting Permissions

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