Using libvlc_media_new_location to open url

This forum is about all development around libVLC.
DaveLister
New Cone
New Cone
Posts: 7
Joined: 28 Mar 2015 23:29

Using libvlc_media_new_location to open url

Postby DaveLister » 29 Mar 2015 16:15

Hi -

I am not sure how active this forum is - but I am stuck and could really do with some help :). I am using Delphi to interact with the library and I have no problem in opening a media file that is disk-based but cannot get it to work with a url using "libvlc_media_new_location".

here is a summary of the code I am using..

Code: Select all

vlcInstance := libvlc_new(0, nil); // url := 'http://www.youtube.com/watch?v=dDeeapR_yMY&list=PLYutciIGBqC2rqlBw3wVX4LjFlcjtWjGP&index=3'; vlcMedia := libvlc_media_new_location (vlcInstance, 'http://www.youtube.com/watch?v=dDeeapR_yMY&list=PLYutciIGBqC2rqlBw3wVX4LjFlcjtWjGP&index=3'); vlcMediaPlayer := libvlc_media_player_new_from_media(vlcMedia); libvlc_media_player_set_position(vlcMediaPlayer,0.0); if libvlc_media_player_will_play(vlcMediaPlayer) then showmessage('ok') else showmessage('wont play'); // now no need the vlc media, free it //libvlc_media_release(vlcMedia); // play video in a TPanel, if not call this routine, vlc media will open a new window libvlc_media_player_set_hwnd(vlcMediaPlayer, Pointer(Panel1.Handle)); // play media libvlc_media_player_play(vlcMediaPlayer);
Any help would be MUCH appreciated.

Cheers..

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Using libvlc_media_new_location to open url

Postby Jean-Baptiste Kempf » 29 Mar 2015 17:07

Try a simpler URL than a youtube one.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

DaveLister
New Cone
New Cone
Posts: 7
Joined: 28 Mar 2015 23:29

Re: Using libvlc_media_new_location to open url

Postby DaveLister » 29 Mar 2015 17:39

Hi Jean -

Thanks for your response. Unfortunately, its Youtube videos that I really want to access. Also, I did try find a video with a simple host OTHER than youtube and tbh - cant find any - lol. If there are any, they are usually embedded (flash etc.)

Does my code seem ok ? I did search forum about using the "libvlc_media_new_location to open url" and there were posts suggesting that the function was "broke" with recent releases of the library.

If anyone has code accessing a youtube url that works - I would be very grateful if they would share it.

Thanks again..

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libvlc_media_new_location to open url

Postby Rémi Denis-Courmont » 29 Mar 2015 19:58

I do not see anything wrong, but then again I am no Delphi expert. You had better look at the LibVLC logs if you want to know whether it does what you expect.

I hate to say this as a VLC developer, but if you only want to play YouTube videos, you should use the official YouTube API documented by Google. It is only a matter of time before the heuristics in LibVLC are defeated by some YouTube site update, and your application breaks without warnings.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

DaveLister
New Cone
New Cone
Posts: 7
Joined: 28 Mar 2015 23:29

Re: Using libvlc_media_new_location to open url

Postby DaveLister » 29 Mar 2015 20:26

OK thanks. I did look at the google API but its not very well suited to Win32 application integration - more for embedded html / php - type code.

Thanks for the feedback.

Cheers..

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Using libvlc_media_new_location to open url

Postby Jean-Baptiste Kempf » 30 Mar 2015 14:17

You need to test first without youtube. If it works, then the issue is that you did not ship the right lua script
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

DaveLister
New Cone
New Cone
Posts: 7
Joined: 28 Mar 2015 23:29

Re: Using libvlc_media_new_location to open url

Postby DaveLister » 30 Mar 2015 16:32

Hi again -

I have just checked with a simpler link. In this case I uploaded a video to my own web site and entered the url the same way I did with the Youtube video. It worked perfectly. So the problem does lie with the url I am using to access the youtube video. Apart from the conveluted url that many youtube videos seem to have - I notice one other difference and that is - with the url I tested on my own domain - I supplied the fully qualified path (including the physical name of the file along with the file extension.) With youtube videos - you simply get a long url.

I wonder if the Youtube server is querying the browser agent to validate that it is a browser trying to access the resource and not an app ? Anyway at least we have established that (afaik) its not possible to supply a youtube url and have it work with the "open location" method (unless someone can tell me how to parse the url so its accepted.)

I know that the youtube I was using works when supplied to a browser - just not when supplied to the API.

Anyone have a youtube link that works or a work-around ?

Cheers.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Using libvlc_media_new_location to open url

Postby Jean-Baptiste Kempf » 08 Apr 2015 11:32

You need to package the youtube lua script.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

DaveLister
New Cone
New Cone
Posts: 7
Joined: 28 Mar 2015 23:29

Re: Using libvlc_media_new_location to open url

Postby DaveLister » 09 Apr 2015 12:12

Hi Jean -
I took some earlier advice and used the Youtube api (Remi). But thanks, I did find this post, which is a solution that was posted earlier - where you add the link to a media list and play from there.

http://stackoverflow.com/questions/1143 ... tube-video

It is always nice to have some alternatives though in case one approach breaks :)

Thanks.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 50 guests