Results 1 to 7 of 7
Thread: Video MediaPlayer Errors
- 09-19-2009, 06:32 PM #1
Member
- Join Date
- Feb 2008
- Posts
- 78
- Rep Power
- 0
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.
Could someone have a look at my work please?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(); } }
Thanks in advance
Menre
- 09-19-2009, 08:15 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
The line
is not a valid java statement.Java Code:final Player player = Manager.createPlayer( % java MediaPlayer http://www.mywebsite/videos/qtv/video_two.mov);
- 09-19-2009, 10:00 PM #3
Member
- Join Date
- Feb 2008
- Posts
- 78
- Rep Power
- 0
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
- 09-20-2009, 10:11 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
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.
- 09-20-2009, 12:37 PM #5
Member
- Join Date
- Feb 2008
- Posts
- 78
- Rep Power
- 0
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
by following their tutorials, I got more errors thrown at me. Again, I decided building my programm by leave the line 19 toJava Code:final Player player = Manager.createPlayer( new URL("http://mywebsite.com/videos/qtv/video_two.mov") );and I got some error messages thatJava Code:final Player player = Manager.createPlayer( url );
'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.
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.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.
Anyway, thanks for your response and I will use another example to achieve this goal.
- 09-20-2009, 12:50 PM #6
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
'package javax.media does not exist' means that you are missing some required jar files.
- 09-21-2009, 09:49 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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
-
video streaming
By anniya0n in forum JDBCReplies: 3Last Post: 05-08-2013, 03:21 PM -
What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03-08-2009, 01:51 AM -
Video tutorial on EJB
By mdeepaks in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 01-31-2009, 05:57 AM -
can I have video out using USB data
By papa_china in forum CLDC and MIDPReplies: 0Last Post: 07-29-2007, 04:29 AM -
video stream
By Alan in forum Advanced JavaReplies: 2Last Post: 05-17-2007, 08:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks