• Welcome to RadioDJ - Free Radio Automation Software Forum. Please log in or sign up.

RadioDJ REST web panel PHP

Started by Valdis, August 05, 2016, 12:21:22 AM

Valdis

This is almost a complete rewrite of the original REST control panel by Austin (aus10hollis).



What's improved

  • Error handling and display when RadioDJ REST server is not reachable.
  • Track type colours and a PHP script (css-track-colours.php) to generate CSS from settings_titles.xml.
  • Responsive design. Now the panel can be used on smaller phone and tablet screens.
  • Accessibility. All buttons are actual <button> elements instead of styled table cells with onclick events.
  • Many code improvements under the hood.

What does not work

  • If track is paused in RadioDJ, REST panel keeps counting seconds as if track was still playing. REST server plugin does not have a command to get paused status.

Setup instructions

  • Download and unzip the files.
  • Upload all files to your, preferably private, server in a separate directory.
  • Edit connection details in config.php.
  • Open the address you uploaded files in your browser.

Note: REST panel allows to control playback by stopping, playing or removing any track in playlist. Do not upload it to a public site or, if you do so, take precautions to protect it using password.

This is version 0.2b.

Download it here: REST-Web-Panel-0.2b.zip
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

Copper007

Looks really great!!! Tried it but got this:

Error: simplexml_load_file(http://127.0.0.1:8080/opt?auth=XXXXXX&command=StatusAutoDJ): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

Original restserver exe does work with same params.....

Grtz
Krid.  8)
RDJ does it all!

http://www.studio0187.nl

Valdis

Quote from: Copper007 on August 05, 2016, 02:09:48 PM
Looks really great!!! Tried it but got this:

Error: simplexml_load_file(http://127.0.0.1:8080/opt?auth=XXXXXX&command=StatusAutoDJ): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

Original restserver exe does work with same params.....
Are you absolutely sure that the port number is correct?
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

Copper007

#3
Yups, I am.... But.... found out that it works in Chrome (via port80) and not in IE11 or Edge...

I even put the server (temporarily lolz) in DMZ....
Maybe provider issues. Tried 8080, 7000, 89 as port and that didn't work. Only 80 does.

Grtz
Krid.


Fantastic solution! Tnx V, kudo´s for you!
RDJ does it all!

http://www.studio0187.nl

Valdis

#4
Quote from: Copper007 on August 05, 2016, 02:49:35 PM
Works in everything but IE (for now)

Internet Explorer issue has been fixed now.
Thanks to to testing by Copper007 I discovered that IE is caching all AJAX requests and not sending any subsequent requests to server.

ZIP file has been updated. Download it same link in my original post.
To make it work in IE, you should replace at least index.php, but her is a list of all changed files:

plmon.php
player-stop.php
player-start.php
np.php
np-json.php
item-remove.php
clear.php
autodj-toggle.php
assisted-toggle.php
status-check.php
index.php

I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

Copper007

 :ok: :ok: :ok: :ok:

* Copper007 happy!

Vanlen, U R Super!

grtz

Krid.  8)
RDJ does it all!

http://www.studio0187.nl

djdensma

getting error in chrome and cant open in ie

Error: SyntaxError: Unexpected end of JSON input
testing with USBWebserver

[attachment deleted by admin]

Valdis

Quote from: djdensma on August 25, 2016, 05:56:32 PM
getting error in chrome and cant open in ie

Error: SyntaxError: Unexpected end of JSON input
testing with USBWebserver
What version of IE are you using?
That error could be caused by unexpected output from server. Maybe some unexpected output after JSON data.
Open Chrome Developer tools (hit F12 on keyboard), switch to Network tab, reload page (F5) and look at the last response from server. Any errors should also be output to console.
Please post the request URL which caused error, response data and any errors you see in developer tools console.
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

djdensma

Quote from: Valdis on August 25, 2016, 08:15:24 PM
What version of IE are you using?
That error could be caused by unexpected output from server. Maybe some unexpected output after JSON data.
Open Chrome Developer tools (hit F12 on keyboard), switch to Network tab, reload page (F5) and look at the last response from server. Any errors should also be output to console.
Please post the request URL which caused error, response data and any errors you see in developer tools console.

i changed ip from 127.0.0.1 to actual ip 192.168.1.9 on REST server and able to connect with ie with different error
IE error is Error: SyntaxError: Syntax error

Attached is the chrome screen on refresh. dont seem to see any error.
Rest control works using andriod app

[attachment deleted by admin]

Valdis

Quote from: djdensma on August 25, 2016, 10:11:26 PM
i changed ip from 127.0.0.1 to actual ip 192.168.1.9 on REST server and able to connect with ie with different error
IE error is Error: SyntaxError: Syntax error

Attached is the chrome screen on refresh. dont seem to see any error.
Rest control works using andriod app

I'll ask again: What version of IE?

You didn't post server response that is causing the error. IE has developer tools and you can open them using same keyboard shortcut (F12).

This is how a valid response looks in Chrome developer tools:


Android app connects to REST server directly. REST panel is using PHP to connect to REST server plugin.
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

djdensma

IE 11
i cant seem to find column with header, preview, response, timing on my chrome.
not seeing any error  on IE network tab either

any ideas?

Valdis

Quote from: djdensma on August 26, 2016, 12:59:27 AM
IE 11
i cant seem to find column with header, preview, response, timing on my chrome.
not seeing any error  on IE network tab either

any ideas?

I can't reproduce the error on IE 11.51.14393.0 and REST panel worked in IE before Windows anniversary update.

The request details tabs appear after clicking a request entry. I'd like to see what you get in the headers tab as well.
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

djdensma

Quote from: Valdis on August 26, 2016, 01:06:34 AM
I can't reproduce the error on IE 11.51.14393.0 and REST panel worked in IE before Windows anniversary update.

The request details tabs appear after clicking a request entry. I'd like to see what you get in the headers tab as well.

reponse headers

Key   Value
Response   HTTP/1.1 200 OK
Date   Fri, 26 Aug 2016 02:46:57 GMT
Server   Apache/2.4.6 (Win32) PHP/5.4.17
Last-Modified   Thu, 04 Aug 2016 21:46:17 GMT
ETag   "1d77-53945e136bca6"
Accept-Ranges   bytes
Content-Length   7543
Keep-Alive   timeout=5, max=99
Connection   Keep-Alive
Content-Type   text/css


[attachment deleted by admin]

Valdis

That is a request for static CSS stylesheet and cannot cause the errors you mentioned.

Please post a response body and the response headers from status-check.php and np-json.php.
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

djdensma

cant connect to anymore using radiodj monitor. i changed ip from 127.0.0.1 to actual ip. i will  restart radiodj when possible.
wondering if my REST server plugin is setup correctly. i  see 2 folders Plugin_RestServerV1.1 and RadioDJ Monitor (sample)
maybe im running two plugins by mistake?