java - Playing youtube videos with vlcj not working anymore -


i having problem playing youtube videos vlcj. until last week or working. calling mediaplayer.playmedia("http://www.youtube.com/watch?v=1t8fl96hpqi") , working fine not anymore. doesnt produce errors @ all. note can play local files , other online streaming urls, not youtube videos.

this code using. ( ready example)

/*  * file part of vlcj.  *  * vlcj free software: can redistribute and/or modify  * under terms of gnu general public license published  * free software foundation, either version 3 of license, or  * (at option) later version.  *  * vlcj distributed in hope useful,  * without warranty; without implied warranty of  * merchantability or fitness particular purpose.  see  * gnu general public license more details.  *  * should have received copy of gnu general public license  * along vlcj.  if not, see <http://www.gnu.org/licenses/>.  *   * copyright 2009, 2010, 2011 caprica software limited.  */  package com.javacodegeeks.youtube.test;  import java.awt.borderlayout; import java.awt.canvas; import java.awt.color; import java.awt.frame; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.windowadapter; import java.awt.event.windowevent; import java.util.list;  import javax.swing.boxlayout; import javax.swing.imageicon; import javax.swing.jbutton; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jtextfield; import javax.swing.swingutilities; import javax.swing.uimanager; import javax.swing.uimanager.lookandfeelinfo; import javax.swing.border.emptyborder;  import uk.co.caprica.vlcj.binding.internal.libvlc_media_t; import uk.co.caprica.vlcj.player.mediaplayer; import uk.co.caprica.vlcj.player.mediaplayereventadapter; import uk.co.caprica.vlcj.player.mediaplayerfactory; import uk.co.caprica.vlcj.player.embedded.embeddedmediaplayer; import uk.co.caprica.vlcj.test.vlcjtest;  /**  * minimal youtube player.  * <p>  * url/mrl must in following format:  * <pre>  *   http://www.youtube.com/watch?v=000000  * </pre>  * thing makes different 'regular' media player  * application following piece of code:  * <pre>  *   mediaplayer.setplaysubitems(true); // <--- important youtube media  * </pre>  * note possible programmatically play sub-item in   * response events - more complex more flexible.  * <p>  * youtube web page format changes time time. means  * lua scripts vlc provides parse youtube web pages when looking  * media stream may not work. if errors, errors  * alluding malformed urls, may need update vlc version  * newer lua scripts.  */ public class newclass extends vlcjtest {    private mediaplayerfactory factory;   private embeddedmediaplayer mediaplayer;   private frame mainframe;    private jlabel urllabel;   private jtextfield urltextfield;   private jbutton playbutton;    public static void main(string[] args) throws exception {     setlookandfeel();      swingutilities.invokelater(new runnable() {       @override       public void run() {         new newclass().start();       }     });   }    public newclass() {     mainframe = new frame("vlcj youtube test");     mainframe.seticonimage(new imageicon(getclass().getresource("/icons/vlcj-logo.png")).getimage());     mainframe.setsize(800, 600);     mainframe.addwindowlistener(new windowadapter() {       @override       public void windowclosing(windowevent e) {         exit(0);       }     });     mainframe.setlayout(new borderlayout());      jpanel cp = new jpanel();     cp.setbackground(color.black);     cp.setlayout(new borderlayout());      jpanel ip = new jpanel();     ip.setborder(new emptyborder(4, 4, 4, 4));     ip.setlayout(new boxlayout(ip, boxlayout.x_axis));      urllabel = new jlabel("url:");     urllabel.setdisplayedmnemonic('u');     urllabel.settooltiptext("enter url in format http://www.youtube.com/watch?v=000000");     urltextfield = new jtextfield(40);     urltextfield.setfocusaccelerator('u');     urltextfield.settooltiptext("enter url in format http://www.youtube.com/watch?v=000000");     playbutton = new jbutton("play");     playbutton.setmnemonic('p');      ip.add(urllabel);     ip.add(urltextfield);     ip.add(playbutton);      cp.add(ip, borderlayout.north);      canvas vs = new canvas();     vs.setbackground(color.black);     cp.add(vs, borderlayout.center);      mainframe.add(cp, borderlayout.center);      urltextfield.addactionlistener(new actionlistener() {       @override       public void actionperformed(actionevent e) {         play();       }     });      playbutton.addactionlistener(new actionlistener() {       @override       public void actionperformed(actionevent e) {         play();       }     });      factory = new mediaplayerfactory();      mediaplayer = factory.newembeddedmediaplayer();     mediaplayer.setvideosurface(factory.newvideosurface(vs));      mediaplayer.setplaysubitems(true); // <--- important youtube media      mediaplayer.addmediaplayereventlistener(new mediaplayereventadapter() {       @override       public void mediasubitemadded(mediaplayer mediaplayer, libvlc_media_t subitem) {         list<string> items = mediaplayer.subitems();         system.out.println(items);         system.out.println(mediaplayer.subitemcount());       }     });   }    private void start() {     mainframe.setvisible(true);   }    private void play() {     string mrl = urltextfield.gettext();     mediaplayer.playmedia(mrl);    }    private void exit(int value) {     mediaplayer.stop();     mediaplayer.release();     factory.release();     system.exit(value);   }    /**    * set cross platform , feel.    *     * @throws exception if error occurs    */  //  private static void setlookandfeel() throws exception { //    string lookandfeelclassname = null; //    lookandfeelinfo[] lookandfeelinfos = uimanager.getinstalledlookandfeels(); //    for(lookandfeelinfo lookandfeel : lookandfeelinfos) { //      if("nimbus".equals(lookandfeel.getname())) { //        lookandfeelclassname = lookandfeel.getclassname(); //      } //    } //    if(lookandfeelclassname == null) { //      lookandfeelclassname = uimanager.getsystemlookandfeelclassname(); //    } //    uimanager.setlookandfeel(lookandfeelclassname); //  } } 

for youtube videos want code:

mediaplayer.setplaysubitems(true); // <--- important youtube media 

and code below gets subitems.

mediaplayer.addmediaplayereventlistener(new mediaplayereventadapter() {       @override       public void mediasubitemadded(mediaplayer mediaplayer, libvlc_media_t subitem) {         list<string> items = mediaplayer.subitems();         system.out.println(items);         system.out.println(mediaplayer.subitemcount());       }     }); 

when working, noticed above code printing 2 subitems, 1 of them being actual url of video.

but prints 1 subitem this:

[http://www.youtube.com/get_video_info?video_id=1t8fl96hpqi&el=detailpage]

which not actual url of video , think thats why not playing.

any ideas of why happening? did google change in format of youtube pages?

i tried upgrading vlc youtube.lua file suggested in tutorial found no luck.

also, when use same link in vlc, works fine.

specs:

ubuntu 12.0.4 64 bits

vlc media player 2.0.5 twoflower

vlcj 2.2.0

thanks in advance,

marios

did google change in format of youtube pages?

most likely. happens time, point don't rely on functionality in application (even though it'd nice if could.) it's temperamental, 1 small change layout of youtube , stops working. i'm not sure lua file vlcj uses same install of vlc (though wrong there.)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -