Page 1 of 1

Using libvlc_media_new_location to open url

Posted: 29 Mar 2015 16:15
by DaveLister
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..

Re: Using libvlc_media_new_location to open url

Posted: 29 Mar 2015 17:07
by Jean-Baptiste Kempf
Try a simpler URL than a youtube one.

Re: Using libvlc_media_new_location to open url

Posted: 29 Mar 2015 17:39
by DaveLister
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..

Re: Using libvlc_media_new_location to open url

Posted: 29 Mar 2015 19:58
by RĂ©mi Denis-Courmont
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.

Re: Using libvlc_media_new_location to open url

Posted: 29 Mar 2015 20:26
by DaveLister
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..

Re: Using libvlc_media_new_location to open url

Posted: 30 Mar 2015 14:17
by Jean-Baptiste Kempf
You need to test first without youtube. If it works, then the issue is that you did not ship the right lua script

Re: Using libvlc_media_new_location to open url

Posted: 30 Mar 2015 16:32
by DaveLister
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.

Re: Using libvlc_media_new_location to open url

Posted: 08 Apr 2015 11:32
by Jean-Baptiste Kempf
You need to package the youtube lua script.

Re: Using libvlc_media_new_location to open url

Posted: 09 Apr 2015 12:12
by DaveLister
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.