title: Playing youtube videos with vlcj not working anymore
body: <p>I am having a problem playing youtube videos with vlcj. Until last week or so everything was working.
  i was calling mediaPlayer.playMedia("<a href="http://www.youtube.com/watch?v=1t8fl96HPQI" rel="nofollow">http://www.youtube.com/watch?v=1t8fl96HPQI</a>") and was working fine but not anymore. it doesnt produce any errors at all. 
  Note that i can play local files and other online streaming urls, but not youtube videos.</p>
  
  <p>This is the code i am using. ( basically its a ready example)</p>
  
  <pre><code>/*
   * This file is part of VLCJ.
   *
   * VLCJ is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * VLCJ is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with VLCJ.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
   * 
   * 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;
  
  /**
   * A minimal YouTube player.
   * &lt;p&gt;
   * The URL/MRL must be in the following format:
   * &lt;pre&gt;
   *   http://www.youtube.com/watch?v=000000
   * &lt;/pre&gt;
   * The only thing that makes this different from a 'regular' media player
   * application is the following piece of code:
   * &lt;pre&gt;
   *   mediaPlayer.setPlaySubItems(true); // &lt;--- This is very important for YouTube media
   * &lt;/pre&gt;
   * Note that it is also possible to programmatically play the sub-item in 
   * response to events - this is slightly more complex but more flexible.
   * &lt;p&gt;
   * The YouTube web page format changes from time to time. This means that the
   * lua scripts that vlc provides to parse the YouTube web pages when looking
   * for the media to stream may not work. If you get errors, especially errors
   * alluding to malformed urls, then you may need to update your vlc version to
   * get 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 a URL in the format http://www.youtube.com/watch?v=000000");
      urlTextField = new JTextField(40);
      urlTextField.setFocusAccelerator('u');
      urlTextField.setToolTipText("Enter a URL in the 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); // &lt;--- This is very important for YouTube media
  
      mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
        @Override
        public void mediaSubItemAdded(MediaPlayer mediaPlayer, libvlc_media_t subItem) {
          List&lt;String&gt; 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 the cross platform look and feel.
     * 
     * @throws Exception if an 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);
  //  }
  }
  </code></pre>
  
  <p>For youtube videos you want this code:</p>
  
  <pre><code>mediaPlayer.setPlaySubItems(true); // &lt;--- This is very important for YouTube media
  </code></pre>
  
  <p>and the code below gets all subitems.</p>
  
  <pre><code>mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
        @Override
        public void mediaSubItemAdded(MediaPlayer mediaPlayer, libvlc_media_t subItem) {
          List&lt;String&gt; items = mediaPlayer.subItems();
          System.out.println(items);
          System.out.println(mediaPlayer.subItemCount());
        }
      });
  </code></pre>
  
  <p>When it was working, i noticed that the above code was printing 2 subitems, one of them being the actual url of the video.</p>
  
  <p>But now it only prints one subitem like this:</p>
  
  <p>[http://www.youtube.com/get_video_info?video_id=1t8fl96HPQI&amp;el=detailpage]</p>
  
  <p>which is not the actual url of the video and i think thats why is not playing.</p>
  
  <p>Any ideas of why this is happening? Did google change anything in the format of their youtube pages?</p>
  
  <p>I tried upgrading the vlc youtube.lua file as was suggested in a tutorial i found but with no luck.</p>
  
  <p>Also, when i use the same link in vlc, it works fine.</p>
  
  <p>Specs:</p>
  
  <p>Ubuntu 12.0.4 64 bits</p>
  
  <p>VLC media player 2.0.5 Twoflower</p>
  
  <p>vlcj 2.2.0</p>
  
  <p>Thanks in advance,</p>
  
  <p>Marios</p>