• We just launched and are currently in beta. Join us as we build and grow the community.

Function to control VLC over wifi with ESP8266

profitnet2k

Tactical Genius
P Rep
0
0
0
Rep
0
P Vouches
0
0
0
Vouches
0
Posts
110
Likes
142
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
/*
The following function is to control vlc media player over wifi with esp8266 use it like this:
control_vlc("play"); / control_vlc("pause"); / control_vlc("fullscreen"); etc...
0. Activate the vlc web control in the setting and use the password "123456",
To enable the HTTP control interface as a primary or extra interface, go to
*** Tools -> Preferences (select "All" radio-button) -> Interface -> Main interfaces -> check "Web" ***
go to "Main interfaces" -> "Lua", and set a password of "123456" under Lua HTTP
now you will be able to access the web interface with the browser under 127.0.0.1:8080, user is empty, password is 123456.
(you can use different password but you must change it in the request header, it's base64 as "OjEyMzQ1Ng==", witch is ":123456",
witch means user = "" pass = "123456".
1. Using arduino IDE and esp8266, make sure you are also using the library
#include <ESP8266HTTPClient.h>
2.Define the constants in the code head, fill it with your computer ip and vlc port.
it's recommended to make your PC ip static so it won't change in the future with different in the code.
#define VLC_IP "192.168.1.14"
#define VLC_PORT 8080
*/
void control_vlc(String command){
if (WiFi.status() == WL_CONNECTED) {
String url="";
if (command=="play" || command=="pause"){url="/requests/status.xml?command=pl_pause";}
if (command=="start" || command=="reset"){url="/requests/status.xml?command=seek&val=0";}
if (command=="stop"){url="/requests/status.xml?command=stop";}
if (command=="fullscreen"){url="/requests/status.xml?command=fullscreen";}
HTTPClient http;
http.begin(VLC_IP,VLC_PORT,url);
http.addHeader("Content-Type", "text/html");
http.addHeader("Authorization", "Basic OjEyMzQ1Ng==");
int httpCode = http.GET();
Serial.println(httpCode);
/*if (httpCode > 0) { //Check the returning code
String payload = http.getString(); //Get the request response payload
Serial.println(payload); //Print the response payload
}
*/
http.end(); //Close connection
}
 

450,270

322,965

322,974

Top