Results 1 to 4 of 4
Thread: (Youtube-) Video in a Swing GUI
- 08-24-2012, 01:08 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 2
- Rep Power
- 0
(Youtube-) Video in a Swing GUI
Hey everyone,
I'm currently trying to get a video playable in my Swing GUI but I just can't seem to do it, I really need your help please.
With google and the JMF I got this far:
But all I get when I run this isJava Code:import java.awt.BorderLayout; import java.awt.Component; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.media.CannotRealizeException; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.swing.JFrame; public class MediaPanel extends JFrame { public MediaPanel() { setLayout(new BorderLayout()); // use a BorderLayout // Use lightweight components for Swing compatibility Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true); URL mediaURL = null; try { mediaURL = new URL("http://www.youtube.com/watch?v=Q7_Z_mQUBa8"); } catch (MalformedURLException ex) { System.err.println(ex); } try { // create a player to play the media specified in the URL Player mediaPlayer = Manager.createRealizedPlayer(mediaURL); // get the components for the video and the playback controls Component video = mediaPlayer.getVisualComponent(); Component controls = mediaPlayer.getControlPanelComponent(); if (video != null) { add(video, BorderLayout.CENTER); // add video component } if (controls != null) { add(controls, BorderLayout.SOUTH); // add controls } mediaPlayer.start(); // start playing the media clip } // end try catch (NoPlayerException noPlayerException) { System.err.println("No media player found"); } // end catch catch (CannotRealizeException cannotRealizeException) { System.err.println("Could not realize media player"); } // end catch catch (IOException iOException) { System.err.println("Error reading from the source"); } // end catch } // end MediaPanel constructor }
I have really spent a lot of time playing around with this, other links, other formats, other code, but this is the farthest I got and I need a couple of trained eyes to look at this I guess...Java Code:Warning: The URL may not exist. Please check URL No media player found
Any advice is greatly appreciated!
Best regards,
Patrick
- 08-24-2012, 04:17 PM #2
Re: (Youtube-) Video in a Swing GUI
You should add a call to the printStackTrace() method in the catch blocks for better error information.
If you don't understand my response, don't ignore it, ask a question.
- 08-25-2012, 12:02 AM #3
Member
- Join Date
- Aug 2012
- Posts
- 2
- Rep Power
- 0
Re: (Youtube-) Video in a Swing GUI
Well the underlaying problem here is - I think - that it doesn't even go into one of my catch blocks!
I have tried this out with a couple more "System.out.println("I'm here");
is not triggered by one of thoseJava Code:Warning: The URL may not exist. Please check URL

Where would you place the calls?
- 08-25-2012, 01:15 AM #4
Similar Threads
-
YouTube Direct and Video IDs
By LaPasticca in forum Web FrameworksReplies: 2Last Post: 02-25-2012, 02:42 PM -
Program for download video from Youtube.
By check_check in forum NetworkingReplies: 2Last Post: 08-20-2011, 06:41 PM -
tomcat embedded youtube video
By crank6015 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 06-04-2011, 01:30 AM -
youtube Video downloads
By Gloomy in forum New To JavaReplies: 2Last Post: 09-06-2010, 05:40 AM -
download youtube video
By lalit.wientech in forum NetworkingReplies: 11Last Post: 03-24-2010, 04:30 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks