Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

VLC HTTP interface library.


  • Please log in to reply
26 replies to this topic
specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
VLC HTTP Interface Library
Updated 11/24/11

This is a library of the http interface commands for VLC Media Player. I prefer not using hotkeys whenever possible as sometimes they conflict with hotkeys of other apps.

A new library for the latest version of VLC Media Player can be found at VLCHTTP2.

Advantages of using VLCHTTP and VLC Media Player.
:D VLC does NOT need to be the active window to use HTTP functions and therefore doesn't interfere with other windows.
:D HTTP functions can be used over the internet, local networks or on one computer.
:D VLC can play full screen on any monitor, not just the default monitor.
:D VLC will open full screen on which ever monitor the media link was clicked.
:D VLC does not drop out of full screen when it looses focus. Play a movie on one monitor and work on the other.This latest version includes all transport, playlist and status functions as well as many other custom functions. "UrlDownloadTofile" has been changed to olfen's "UrlDownloadToVar". Functions are faster and creating/reading text files is no longer needed. All needed functions are also included such as UrlDownloadToVar by olfen and UnHTM by SKAN.

Download VLCHTTP Here. Re-upped 8-21-12.
Right click and save file as some characters are not correctly displayed in a web browser.

Quick example,
Gui, Add, Button, gButton1, Play/Pause
Gui, Add, Button, gButton2, Volume Up
Gui, Show
Return

Button1:
VLCHTTP_Pause() ; Use pause instead of play to toggle play/pause mode.
Return

Button2:
VLCHTTP_VolumeUp(1) ; Turns the volume up 1 step.
Return

Download AHK example using all commands. Lost in ahk.net crash.
Posted Image
The gui resembling a remote is obviously to control VLC. The center window acts as a playlist. The 3rd window displays what is actually being received from VLC that must be parsed to retrieve the data for the other two windows. It also contains a list of all the functions.

Setting up VLC.
In VLC's option you will need to activate the http interface by checking the box in front of it. It's located in Interface/Main Interface. Then add this information to Interface/Main Interface/Http
Host Address-    127.0.0.1:8080
Source Directory-   C:\Program Files\VideoLAN\VLC\http
Posted ImagePosted Image
The source directory has changed in some version of vlc, make sure the file index.html is in the directory or change the source directory to the folder it is in. Once set up, you can view the HTML example supplied with VLC by entering the host address into a browser and pressing enter.


Edit 11/24/11
Switched from "UrlDownloadTofile" to olfen's "UrlDownloadToVar", functions are faster and creating/reading text files is no longer needed.
Added all transport, playlist and status commands and created several others to compliment them.
Note, Playlist sort HTTP functions are broken in the latest version of VLC and do not operate correctly from these functions or in VLC's HTML examples.
Service Discovery Module functions have been added but are untested.

Edit 4/16/11
Added several commands including some playlist commands.
Changed the confusing return file name and directory. It now is written to C:\vlc_return.txt.

Edit 7/10/11
Added several functions.
Added a parameter to pass to functions such as ff/rw and volume.
Added toggle mute function.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Looks cool. I'm trying to use it, but my host address won't save in preferences. I copy and paste the host and the source into the boxes and click save. When I open it (the preferences) again only the source has a value and the host is blank. Any ideas?
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
Um, not sure why it wouldn't save. Try checking that your index.html file is actually in the source directory. On my system it's,
C:\Program Files\VideoLAN\VLC\http\Index.html
but I believe it may be different in other versions. I currently have version 1.0.2.

That is the only thing I can think to check, please let me know what you find and I'll do a little research.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Besides the fact that it's lowercase, yes index.html is in C:\Program Files (x86)\VideoLAN\VLC\http\ which is in the Source Directory field.

Not sure if this is normal behaivor but when I close preferences and reopen it, it defaults to simple options.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
On the interface page there is a check box for "Show Advanced Options". Until you check that it will always revert back to "Simple".

Something I missed in my first post, on the page Interface-Main Interfaces you need to check the box beside "HTTP remote control interface". I also have "Remote control interface" checked for use with another app. I don't know if those both need to be check or not for just HTTP use.

The only other thing I can think of is once you change settings you have to close VLC and reopen it for them to take affect. I'll search the VLC forums and see if there's any post similar to your problem, you could look too.

Doyle nli
  • Guests
  • Last active:
  • Joined: --
Anyway of getting info on what's playing?

Name of file. Length. How far it has progressed?

That would be interesting. I want to make an annotator.

specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007

Anyway of getting info on what's playing?

Name of file. Length. How far it has progressed?

That would be interesting. I want to make an annotator.


I've updated the library with a few new functions. To get information on the currently playing item use,
VLCHTTP_Status()

This returns a text file to C:\vlc_return.txt with the information which can be read in AHK with FileReadLine.

I would think the URL download to variable function would allow you to retrieve the info without having to write/read a text file.
http://www.autohotke...pic.php?t=10466

specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
Updated 11/24/11
I you need new version of any scripts I haven't re-uploaded yet feel free to pm me.

toddat
  • Members
  • 1 posts
  • Last active: Dec 25 2011 10:30 PM
  • Joined: 25 Dec 2011
what am i doing wrong? I should just be able to compile the libraries, yes?

Error: Call to nonexistent function.

Specifically: VLCHTTP_CurrentVol()

Line#
113: CurVol := VLCHTTP_CurrentVol()

specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007

what am i doing wrong? I should just be able to compile the libraries, yes?

Error: Call to nonexistent function.

Specifically: VLCHTTP_CurrentVol()

Line#
113: CurVol := VLCHTTP_CurrentVol()


Forgive me if I'm being too basic but since you joined today it looks as if your new to AHK scripting. I can't reproduce the error with the same line number your showing but I can conclude it is from the example script in the first post. The example and the library are two different scripts. The library is a group of functions that anyone can use in their scripts and the example shows how they can be used. The important thing to remember is if you use the example you must still download and install the library.

Libraries of Functions:
Read the documentation in the link above for more on libraries. Most libraries you can think of as being able to use a short one line command in your script that actually adds a complex multi-line command. In order for the short command to be able to reference the long one the library file must be in one of two places and must also be named correctly.

The easiest method is to place a folder called "lib" in your Autohotkey folder, usually C:/Progrma Files/Autohotkey. The file must be named VLCHTTP.ahk. Once you have it in the folder the example script should be able to find it and run without getting the errors.

Download the quick example to see how the script and library work together then use the complete example if you want to but it was just meant to demonstrate all the functions and does have some bugs.

Feel free to ask further questions.
I you need new version of any scripts I haven't re-uploaded yet feel free to pm me.

ColoQ
  • Guests
  • Last active:
  • Joined: --
Hello,

I was looking for something to control Vlc while in a full screen game, and landed here. Good one, I guess :wink:

I placed your file in the ahk lib folder, which I had to create first ( I am using ahk 64 bit on Win 7).

When I now try to start one of your examples, after converting them to utf-8 (Iread that the 64 bit could only use utf-8 is that right?) it says the following:


Error: Too many parameters passed to the function.

Specifically: vlchttp_playlistsortrandom(0)


Then it lists some more lines with functions.

Is this a UAC Problem? Starting it as admin doesn't help.

Thanks alot.

If I get it to work, can I also just make a script where I assign keyboard keys to some functions?

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
VLCHTTP_PlaylistSortRandom doesn't take any parameters. Remove the 0 and try again. (Most of the other PlayListSort functions do, but not the random one. In any case, 0 is the default for all of them, so if you want 0, just leave it out.)

And, that's not a UAC problem. AutoHotkey is saying your code is invalid and it doesn't know what to do with it. If there was a UAC problem, it would just not work... no error message or anything (in most cases).
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

ColoQ
  • Guests
  • Last active:
  • Joined: --
Hy,

thank you, but there is no 0 , just ()

Also I get different errors if I start the scripts with shortcuts, than when I double click the ahk files directly.

Via the shortcuts it says it cannot find the other scripts, although they are in the same folder.

Could this be a problem with the 64 bit version not handling the library correctly?

Because if I comment out the autostart lines, then it complains about something else like labels not found etc.

I am using the exact scripts from the example zip above.

thx

Colo

specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
I likely didn't make this clear but all the sort commands seem to be broken in the latest version of VLC. I have only tested them with XP but they do not work with VLC's browser example either. I included all the commands I could to be thorough and for others to try in case I was missing something. Frankie is correct that this command does not take a parameter so I don't know why it would say there is one unless one is being passed to it accidentally.

However if you use VLCHTTP_PlayListRandom() then it picks tracks randomly from the playlist making the sort command unnecessary. This is the same as clicking the "Random" button on the player.

As far as starting with shortcuts, that sounds like the "Include" command is not correct. I don't have my example scripts on this computer and I have to go as soon as I'm done responding to this but I can look and test later tonight.

I'm afraid I don't know anything about Win7 or UTF so I can't be sure if it could be a problem. However, since this is simply html functions I don't see how it could make a difference either way.

What script are you using? If you are just using my example script then yes it could be script problems as that example is buggy. I was looking for a quick way to cram every command into the example. Also I've never attempted to create a playlist editor before so this one likely has some problems.

If your using your own script post it and maybe I or someone else can look through it.

I am fairly sure I tested all the commands before posting this but it is still possible there are typos or I've done something incorrectly. I'll see what I can find later tonight, let me know if you have any more questions.
I you need new version of any scripts I haven't re-uploaded yet feel free to pm me.

ColoQ
  • Guests
  • Last active:
  • Joined: --
Thank you for your lengthy answer.

I am pretty new to ahk and tried to get what I needed from the wiki and doc.

I was looking for a way to control vlc from inside a game and since many keys are used there, I thought that the html function would be great.

I don't need such a sophisticated program as you present here. All I need are the commands vol+ and - play and pause and some frames forward and back. All that bound to one hotkey each.

But I don't know how to use such lengthy functions for hotkeys yet.

I don't even get

SC014::
Shift
t
return

to work :? when I want more than one button pressed without using Send.