RadioDJ - Free Radio Automation Software Forum

More or Less Radio Talk => Website, Programming and related => Topic started by: Valdis on August 05, 2016, 12:21:22 AM

Title: RadioDJ REST web panel PHP
Post by: Valdis on August 05, 2016, 12:21:22 AM
This is almost a complete rewrite of the original REST control panel by Austin (aus10hollis).

(http://image.prntscr.com/image/dba2dd17199b4818bdcb17c8bb42e5ad.png)

What's improved

What does not work

Setup instructions

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 (https://axellence.lv/downloads/REST-Web-Panel-0.2b.zip)
Title: Re: RadioDJ REST web panel PHP
Post by: 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.....

Grtz
Krid.  8)
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 05, 2016, 02:27:38 PM
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?
Title: Re: RadioDJ REST web panel PHP
Post by: Copper007 on August 05, 2016, 02:49:35 PM
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!
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 05, 2016, 04:12:59 PM
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

Title: Re: RadioDJ REST web panel PHP
Post by: Copper007 on August 05, 2016, 04:34:13 PM
 :ok: :ok: :ok: :ok:

/me happy!

Vanlen, U R Super!

grtz

Krid.  8)
Title: Re: RadioDJ REST web panel PHP
Post by: 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

[attachment deleted by admin]
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 25, 2016, 08:15:24 PM
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.
Title: Re: RadioDJ REST web panel PHP
Post by: djdensma on August 25, 2016, 10:11:26 PM
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]
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 25, 2016, 10:45:45 PM
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:
(http://image.prntscr.com/image/7a2996746eee49f9a3901967ed395203.png)

Android app connects to REST server directly. REST panel is using PHP to connect to REST server plugin.
Title: Re: RadioDJ REST web panel PHP
Post by: 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?
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 26, 2016, 01:06:34 AM
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.
Title: Re: RadioDJ REST web panel PHP
Post by: djdensma on August 26, 2016, 04:50:25 AM
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]
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 26, 2016, 05:14:53 AM
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.
Title: Re: RadioDJ REST web panel PHP
Post by: djdensma on August 26, 2016, 02:39:35 PM
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?
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 26, 2016, 06:45:51 PM
Quote from: djdensma on August 26, 2016, 02:39:35 PM
cant connect to anymore using radiodj monitor. i changed ip from 127.0.0.1 to actual ip. i will  restart radiodj when possible.
Changing IP address in REST server plugin setting takes effect after stopping and starting REST server. No need to restart RadioDJ.

Quote from: djdensma on August 26, 2016, 02:39:35 PM
wondering if my REST server plugin is setup correctly.
Stop wondering and show your settings. And also show settings you have entered in config.php of REST panel.

Quote from: djdensma on August 26, 2016, 02:39:35 PM
i  see 2 folders Plugin_RestServerV1.1 and RadioDJ Monitor (sample)
maybe im running two plugins by mistake?
There should not be a folder named "Plugin_RestServerV1.1" in RadioDJ Plugins folder and RadioDJ will not load plugin DLL files from subfolders. REST server plugin is one file - Plugin_RestServer.dll and its version - 4.0.0.0. It is more likely that you have a folder named "Radio DJ Monitor V1.1".
Both "Radio DJ Monitor V1.1" and "RadioDJ Monitor (sample)" contain a sample application for controlling RadioDJ using REST server plugin.
Title: Re: RadioDJ REST web panel PHP
Post by: djdensma on August 26, 2016, 10:16:33 PM
sample application does not have to be in plugin folder?

header

Key   Value
Response   HTTP/1.1 200 OK
Date   Fri, 26 Aug 2016 20:10:10 GMT
Server   Apache/2.4.6 (Win32) PHP/5.4.17
X-Powered-By   PHP/5.4.17
Content-Length   7644
Keep-Alive   timeout=5, max=100
Connection   Keep-Alive
Content-Type   text/html

body
[sub]
<!DOCTYPE html>
<html>
<!-- For use with RadioDJ 1.7.5+ with REST Server Plugin -->
<head>
<meta charset="utf-8" />
<title>RadioDJ REST Control Panel</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="assets/style.css">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/REST-panel-icon.png">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
-->
</head>

<body>
<div id="statusbar" class="noselect">
<div class="notification" style="display:none;">
</div>
<div class="controls">
<button id="play" title="Play or play next"><span>play</span></button>
<button id="stop" title="Stop playback"><span>stop</span></button>
</div>
<div class="nowPlaying">
<h2 class="title" id="nowPlayingTitle">-</h2>
<h3 class="artist" id="nowPlayingArtist">-</h3>
</div>
<div class="npTimes" id="countdownNP">--:--:--</div>
</div>
<div id="optionsRow" class="noselect">
<button class="button activated" id="autodj" title="Enable/Disable Automatic Playlist Generation">AUTODJ</button>
<button class="button activated" id="assisted" title="Enable/Disable Playlist Auto Advance">AUTOMATED</button>
<button class="button normal" id="clear" title="Clear The Current Playlist">CLEAR</button>
</div>
<div class="playlist-container noselect">
<table id="playlistRows">
</table>
</div>
<div class="log" id="thelog"></div>
<div class="overlay"></div>
<script>
(function($){
$(document).ready(function() {
$('#play').click(function(){
playPlaylistTrack(0);
$(this).blur();
});

$('#stop').click(function(){
playerSTOP();
$(this).blur();
});

$('#autodj').click(function(){
toggleAutoDJ();
$(this).blur();
});

$('#assisted').click(function(){
toggleAssisted();
$(this).blur();
});

$('#clear').click(function(){
clearPlaylist();
$(this).blur();
});

$('#playlistRows').on('click', '.playbutton', function(){
$(this).parents('tr.item').remove();
var trackRow = $(this).parents('tr.item')
var index = trackRow.data('index');
playPlaylistTrack(index);
trackRow.remove();
});

$('#playlistRows').on('click', '.clearbutton', function(){
var trackRow = $(this).parents('tr.item')
var index = trackRow.data('index');
dropPlaylistTrack(index);
trackRow.remove();
});

if(window.console != undefined)
console.log( "RadioDJ REST Web Interface Ready!" );

// Prevent IE from caching AJAX requests
$.ajaxSetup({ cache: false });

var xhrFailed = false;
$( document ).ajaxError(function(event, jqxhr, settings, thrownError) {
// Stop all timers if error occurs
stop();
var message = thrownError;

if( jqxhr.status >= 400 || jqxhr.status === 0 ) {
message = jqxhr.responseJSON != undefined ? jqxhr.responseJSON.error : (jqxhr.responseText? jqxhr.responseText : jqxhr.status+" - "+thrownError);
}

$('.notification').html('<p class="error notice">We have encountered an error. See <a href="#thelog">log messages</a>.</p>').slideDown('fast');

$(".log" ).append('<div class="notice error"><b>Error:</b> '+ message +'</div>');

if(window.console != undefined)
console.log(jqxhr, thrownError);
xhrFailed = true;
});

// Check for connection status and init only if connection works
$.ajax({
url: "status-check.php",
method: 'GET',
success: function(){
init();
}
});

});

var montime, nptime, playingTimer, rdjStatusTimeout;
var isplaying = false;
var timeRemaining = 0;
var trackEndsAt = new Date();
var trackID = 0;

function init() {
rdjStatus();
nowPlayingMonitor();
playlistMonitor();
}

function stop(){
clearTimeout(montime);
clearTimeout(nptime);
clearTimeout(playingTimer);
clearTimeout(rdjStatusTimeout);
resetNowPlaying();
}

function nowPlayingMonitor() {
$.get("np-json.php", function(data){
$('#nowPlayingArtist').html(data.artist);
$('#nowPlayingTitle').html(data.title);
timeRemaining = data.secondsRemaining;
trackEndsAt = new Date(new Date().valueOf()+(data.secondsRemaining*1000));
if(data.secondsRemaining > 0) {
nptime = setTimeout(nowPlayingMonitor, data.secondsRemaining*1000);
}
isplaying = data.isplaying;
count();
playlistMonitor();
});
}

function playlistMonitor() {
clearTimeout(montime);
$.get("plmon.php", function(response){
$('#playlistRows').html(response);
montime = setTimeout(playlistMonitor, 5000);

if(trackID != $('#currentTrack').data('id')) {
nowPlayingMonitor();
}

trackID = $('#currentTrack').data('id');
});
}

function toggleAutoDJ() {
$.get("autodj-toggle.php", function(data) {
if(data.autodj == true) {
$('#autodj').text('AUTODJ').removeClass('deactivated').addClass('activated');
} else {
$('#autodj').text('MANUAL').removeClass('activated').addClass('deactivated');
}
nowPlayingMonitor();
});
}

function toggleAssisted() {
$.get("assisted-toggle.php", function(data) {
if(data.assisted == true) {
$('#assisted').text('ASSISTED').removeClass('activated').addClass('deactivated');
} else {
$('#assisted').text('AUTOMATED').removeClass('deactivated').addClass('activated');;
}
nowPlayingMonitor();
});
}

function clearPlaylist() {
$.get("clear.php", function(){
$('#playlistRows .item').remove();
playlistMonitor();
});
}

function rdjStatus() {
$.get("status-check.php", function(status) {

clearTimeout(rdjStatusTimeout);
rdjStatusTimeout = setTimeout(rdjStatus, 5000);

if(status.autodj) {
$('#autodj').text('AUTODJ').removeClass('deactivated').addClass('activated');
} else {
$('#autodj').text('MANUAL').removeClass('activated').addClass('deactivated');
}

if(status.assisted) {
$('#assisted').text('ASSISTED').removeClass('activated').addClass('deactivated');
} else {
$('#assisted').text('AUTOMATED').removeClass('deactivated').addClass('activated');;
}

});
}

function playPlaylistTrack(playlistid) {
clearTimeout(nptime);
$.get("player-start.php?index="+playlistid, function(data){
if(data.changed) {
nowPlayingMonitor();
}
});
}

function dropPlaylistTrack(playlistid) {
$.get("item-remove.php?index="+playlistid, function(data){
if (data.success) {
playlistMonitor();
} else {
alert('Could not remove track');
}
});
}

function playerSTOP() {
$.get("player-stop.php", function(data){
if(data.changed) {
clearTimeout(nptime);
clearTimeout(playingTimer);
setTimeout(nowPlayingMonitor, 5000);
}
});
}

function setTimer(seconds) {
var formated = '00:00:00';
if(seconds >= 0) {
var time = new Date();
time.setHours(0);
time.setMinutes(0);
time.setSeconds(seconds);
formated = time.toTimeString().split(" ")[0];
}
$('#countdownNP').text(formated);
}

function count() {

// Remove duplicate playingTimer
clearTimeout(playingTimer);

var timeRemaining = (trackEndsAt - new Date())/1000;
setTimer(timeRemaining);

if(timeRemaining > 0) {
playingTimer= setTimeout(count, 1000);
}
}

function resetNowPlaying(){
$('#countdownNP').text('--:--:--');
$('#nowPlayingArtist').text('-');
$('#nowPlayingTitle').text('-');
}
})(jQuery);

</script>
</body>
</html>

Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 26, 2016, 10:39:36 PM
Quote from: djdensma on August 26, 2016, 10:16:33 PM
sample application does not have to be in plugin folder?
No. It doesn't matter where the sample applications are.

Quote from: djdensma on August 26, 2016, 10:16:33 PM
header

Key Value
Response HTTP/1.1 200 OK
Date Fri, 26 Aug 2016 20:10:10 GMT
Server Apache/2.4.6 (Win32) PHP/5.4.17
X-Powered-By PHP/5.4.17
Content-Length 7644
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type text/html


body

<!DOCTYPE html>
<html>
<!-- For use with RadioDJ 1.7.5+ with REST Server Plugin -->
<head>
<meta charset="utf-8" />
<title>RadioDJ REST Control Panel</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="assets/style.css">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/REST-panel-icon.png">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
-->
</head>

<body>
<div id="statusbar" class="noselect">
<div class="notification" style="display:none;">
</div>
<div class="controls">
<button id="play" title="Play or play next"><span>play</span></button>
<button id="stop" title="Stop playback"><span>stop</span></button>
</div>
<div class="nowPlaying">
<h2 class="title" id="nowPlayingTitle">-</h2>
<h3 class="artist" id="nowPlayingArtist">-</h3>
</div>
<div class="npTimes" id="countdownNP">--:--:--</div>
</div>
<div id="optionsRow" class="noselect">
<button class="button activated" id="autodj" title="Enable/Disable Automatic Playlist Generation">AUTODJ</button>
<button class="button activated" id="assisted" title="Enable/Disable Playlist Auto Advance">AUTOMATED</button>
<button class="button normal" id="clear" title="Clear The Current Playlist">CLEAR</button>
</div>
<div class="playlist-container noselect">
<table id="playlistRows">
</table>
</div>
<div class="log" id="thelog"></div>
<div class="overlay"></div>
<script>
(function($){
$(document).ready(function() {
$('#play').click(function(){
playPlaylistTrack(0);
$(this).blur();
});

$('#stop').click(function(){
playerSTOP();
$(this).blur();
});

$('#autodj').click(function(){
toggleAutoDJ();
$(this).blur();
});

$('#assisted').click(function(){
toggleAssisted();
$(this).blur();
});

$('#clear').click(function(){
clearPlaylist();
$(this).blur();
});

$('#playlistRows').on('click', '.playbutton', function(){
$(this).parents('tr.item').remove();
var trackRow = $(this).parents('tr.item')
var index = trackRow.data('index');
playPlaylistTrack(index);
trackRow.remove();
});

$('#playlistRows').on('click', '.clearbutton', function(){
var trackRow = $(this).parents('tr.item')
var index = trackRow.data('index');
dropPlaylistTrack(index);
trackRow.remove();
});

if(window.console != undefined)
console.log( "RadioDJ REST Web Interface Ready!" );

// Prevent IE from caching AJAX requests
$.ajaxSetup({ cache: false });

var xhrFailed = false;
$( document ).ajaxError(function(event, jqxhr, settings, thrownError) {
// Stop all timers if error occurs
stop();
var message = thrownError;

if( jqxhr.status >= 400 || jqxhr.status === 0 ) {
message = jqxhr.responseJSON != undefined ? jqxhr.responseJSON.error : (jqxhr.responseText? jqxhr.responseText : jqxhr.status+" - "+thrownError);
}

$('.notification').html('<p class="error notice">We have encountered an error. See <a href="#thelog">log messages</a>.</p>').slideDown('fast');

$(".log" ).append('<div class="notice error"><b>Error:</b> '+ message +'</div>');

if(window.console != undefined)
console.log(jqxhr, thrownError);
xhrFailed = true;
});

// Check for connection status and init only if connection works
$.ajax({
url: "status-check.php",
method: 'GET',
success: function(){
init();
}
});

});

var montime, nptime, playingTimer, rdjStatusTimeout;
var isplaying = false;
var timeRemaining = 0;
var trackEndsAt = new Date();
var trackID = 0;

function init() {
rdjStatus();
nowPlayingMonitor();
playlistMonitor();
}

function stop(){
clearTimeout(montime);
clearTimeout(nptime);
clearTimeout(playingTimer);
clearTimeout(rdjStatusTimeout);
resetNowPlaying();
}

function nowPlayingMonitor() {
$.get("np-json.php", function(data){
$('#nowPlayingArtist').html(data.artist);
$('#nowPlayingTitle').html(data.title);
timeRemaining = data.secondsRemaining;
trackEndsAt = new Date(new Date().valueOf()+(data.secondsRemaining*1000));
if(data.secondsRemaining > 0) {
nptime = setTimeout(nowPlayingMonitor, data.secondsRemaining*1000);
}
isplaying = data.isplaying;
count();
playlistMonitor();
});
}

function playlistMonitor() {
clearTimeout(montime);
$.get("plmon.php", function(response){
$('#playlistRows').html(response);
montime = setTimeout(playlistMonitor, 5000);

if(trackID != $('#currentTrack').data('id')) {
nowPlayingMonitor();
}

trackID = $('#currentTrack').data('id');
});
}

function toggleAutoDJ() {
$.get("autodj-toggle.php", function(data) {
if(data.autodj == true) {
$('#autodj').text('AUTODJ').removeClass('deactivated').addClass('activated');
} else {
$('#autodj').text('MANUAL').removeClass('activated').addClass('deactivated');
}
nowPlayingMonitor();
});
}

function toggleAssisted() {
$.get("assisted-toggle.php", function(data) {
if(data.assisted == true) {
$('#assisted').text('ASSISTED').removeClass('activated').addClass('deactivated');
} else {
$('#assisted').text('AUTOMATED').removeClass('deactivated').addClass('activated');;
}
nowPlayingMonitor();
});
}

function clearPlaylist() {
$.get("clear.php", function(){
$('#playlistRows .item').remove();
playlistMonitor();
});
}

function rdjStatus() {
$.get("status-check.php", function(status) {

clearTimeout(rdjStatusTimeout);
rdjStatusTimeout = setTimeout(rdjStatus, 5000);

if(status.autodj) {
$('#autodj').text('AUTODJ').removeClass('deactivated').addClass('activated');
} else {
$('#autodj').text('MANUAL').removeClass('activated').addClass('deactivated');
}

if(status.assisted) {
$('#assisted').text('ASSISTED').removeClass('activated').addClass('deactivated');
} else {
$('#assisted').text('AUTOMATED').removeClass('deactivated').addClass('activated');;
}

});
}

function playPlaylistTrack(playlistid) {
clearTimeout(nptime);
$.get("player-start.php?index="+playlistid, function(data){
if(data.changed) {
nowPlayingMonitor();
}
});
}

function dropPlaylistTrack(playlistid) {
$.get("item-remove.php?index="+playlistid, function(data){
if (data.success) {
playlistMonitor();
} else {
alert('Could not remove track');
}
});
}

function playerSTOP() {
$.get("player-stop.php", function(data){
if(data.changed) {
clearTimeout(nptime);
clearTimeout(playingTimer);
setTimeout(nowPlayingMonitor, 5000);
}
});
}

function setTimer(seconds) {
var formated = '00:00:00';
if(seconds >= 0) {
var time = new Date();
time.setHours(0);
time.setMinutes(0);
time.setSeconds(seconds);
formated = time.toTimeString().split(" ")[0];
}
$('#countdownNP').text(formated);
}

function count() {

// Remove duplicate playingTimer
clearTimeout(playingTimer);

var timeRemaining = (trackEndsAt - new Date())/1000;
setTimer(timeRemaining);

if(timeRemaining > 0) {
playingTimer= setTimeout(count, 1000);
}
}

function resetNowPlaying(){
$('#countdownNP').text('--:--:--');
$('#nowPlayingArtist').text('-');
$('#nowPlayingTitle').text('-');
}
})(jQuery);

</script>
</body>
</html>

Please use code tags (# button) when posting long text chunks.

That is a response from index.php file. I need to see response body and response headers from status-check.php and np-json.php.
You have to reload the page after opening IE F12 Developer tools to see all requests.

This is how the request looks in IE developer tools when request to status-check.php fails, because RadioDJ is not running:
(https://dl.dropboxusercontent.com/u/9294655/RadioDJ/REST%20panel%20IE%20fail.png?raw=1)
Title: Re: RadioDJ REST web panel PHP
Post by: starm on August 27, 2016, 10:36:03 AM
Hello,

I use jquery ui to a progress bar

[attachment deleted by admin]
Title: Re: RadioDJ REST web panel PHP
Post by: djdensma on August 27, 2016, 07:22:09 PM
status-check.php and np-json.php not showing anything. just waiting on broswer

going to re-download the files again
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 28, 2016, 10:20:48 AM
Quote from: starm on August 27, 2016, 10:36:03 AM
Hello,

I use jquery ui to a progress bar
Nice. Are you going to share your improvements?
Title: Re: RadioDJ REST web panel PHP
Post by: starm on August 29, 2016, 12:04:08 PM
Valdis Hello, attached the pieces of code, the web radiodj PHP script is in SQL for us to switch to another radiodj since we have several remote broadcasts animating with skype ...
I'll have to clean the source code after the share  :hihi: :(

so :
in the index file
<div id="myprogressbar" value="0" max="100" style="width: 100%;height: 20px;">
   <span class="DureeTimes" id="countdownDuree" style="float: left;font-size: 11pt;margin: 0px 0px 0px 10px">00:00:00</span>
   <span class="IntroTimes" id="countdownIntro" style="color:#FFA500; float: left;font-size: 11pt;margin: 0px 0px 0px 50px">00:00:00</span>
   
   <span style="float: right;font-size: 11pt;margin: 0px 20px 0px 0px;" style="height: 5px;" class="npTimes" id="countdownNP">00:00:00</span>
   <span style="color:red; float: right;font-size: 11pt;margin: 0px 45px 0px 0px;" style="height: 5px;" class="OutroTimes" id="countdownOutro">00:00:00</span>
   </div>




countdownDuree
countdownIntro
countdownNP
countdownOutro
div which are working np.php


add at the end:
do not forget to call jquery ui

<script>
   $(document).ready(function(){
      $( "#myprogressbar" ).progressbar({value: 0});
      nowPlayingMonitor();
    playlistMonitor();
    rdjStatus();
   });
</script>

in the javascript
$("#myprogressbar").progressbar( "value", Math.ceil(currentSongPosition * 100 / currentSongLength));
Title: Re: RadioDJ REST web panel PHP
Post by: molnarb83 on August 30, 2016, 12:17:23 PM
I can enable/disable AutoDJ/Assist. I can see the current song for a second, but after that I got this error message:
Error: simplexml_load_file(): http://62.15.23.12:5555/p?auth=password:1: parser error : xmlParseCharRef: invalid xmlChar value 0
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 30, 2016, 07:11:21 PM
Quote from: molnarb83 on August 30, 2016, 12:17:23 PM
I can enable/disable AutoDJ/Assist. I can see the current song for a second, but after that I got this error message:
Error: simplexml_load_file(): http://62.15.23.12:5555/p?auth=password:1: parser error : xmlParseCharRef: invalid xmlChar value 0
That error is caused by invalid XML output from REST server plugin. The XML data contains character reference which is a NULL character and is invalid XML. Please provide the XML output from the URL in the error message.
Chances are that you won't see the error unless a specific track is in the playlist and you'll have to search the database for fields containing NULL characters.
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on August 30, 2016, 07:51:37 PM
Quote from: starm on August 29, 2016, 12:04:08 PM
Valdis Hello, attached the pieces of code, the web radiodj PHP script is in SQL for us to switch to another radiodj since we have several remote broadcasts animating with skype ...
What do you mean by "several remote broadcasts animating with skype"?
Please use [ code ] tags when posting code samples.

Quote from: starm on August 29, 2016, 12:04:08 PM
so :
in the index file
<div id="myprogressbar" value="0" max="100" style="width: 100%;height: 20px;">
<span class="DureeTimes" id="countdownDuree" style="float: left;font-size: 11pt;margin: 0px 0px 0px 10px">00:00:00</span>
<span class="IntroTimes" id="countdownIntro" style="color:#FFA500; float: left;font-size: 11pt;margin: 0px 0px 0px 50px">00:00:00</span>

<span style="float: right;font-size: 11pt;margin: 0px 20px 0px 0px;" style="height: 5px;" class="npTimes" id="countdownNP">00:00:00</span>
<span style="color:red; float: right;font-size: 11pt;margin: 0px 45px 0px 0px;" style="height: 5px;" class="OutroTimes" id="countdownOutro">00:00:00</span>
</div>


Why do you use inline styles? That is against all best practice recommendations. Appearance should not be defined in HTML. Besides, you have added multiple style properties, which is invalid HTML.
Also, the value and max properties are not valid for <div> element.

Quote from: starm on August 29, 2016, 12:04:08 PM
countdownDuree
countdownIntro
countdownNP
countdownOutro
div which are working np.php

Adding HTML in "np.php" makes no sense, because that script is not even used by my version of REST panel. I'm using "np-json.php" to return playlist as JSON.

Quote from: starm on August 29, 2016, 12:04:08 PM
add at the end:
do not forget to call jquery ui

<script>
$(document).ready(function(){
$( "#myprogressbar" ).progressbar({value: 0});
nowPlayingMonitor();
    playlistMonitor();
    rdjStatus();
});
</script>

in the javascript
$("#myprogressbar").progressbar( "value", Math.ceil(currentSongPosition * 100 / currentSongLength));
You don't need to add whole jQuery UI to create a progress bar. HTML5 already has <progress> with that functionality and it can be updated with vanilla JavaScript or jQuery.
The last line of code you posted is out of context. Where does it belong and where do you get currentSongPosition and currentSongLength variables.
Title: Re: RadioDJ REST web panel PHP
Post by: DJAntares on September 20, 2016, 07:51:21 PM
Quote from: molnarb83 on August 30, 2016, 12:17:23 PM
I can enable/disable AutoDJ/Assist. I can see the current song for a second, but after that I got this error message:
Error: simplexml_load_file(): http://62.15.23.12:5555/p?auth=password:1: parser error : xmlParseCharRef: invalid xmlChar value 0

The error that Edge and Chrome reports is:

Error: simplexml_load_file(http://mypubblicip:theportvsrestserver/opt?auth=password&command=StatusAutoDJ): failed to open stream: Connection timed out

The Rest Server work normally, in fact in a web page that I do myself it's accepting all commands
Title: Re: RadioDJ REST web panel PHP
Post by: Valdis on September 21, 2016, 11:30:19 AM
Quote from: DJAntares on September 20, 2016, 07:51:21 PM
The error that Edge and Chrome reports is:

Error: simplexml_load_file(http://mypubblicip:theportvsrestserver/opt?auth=password&command=StatusAutoDJ): failed to open stream: Connection timed out

The Rest Server work normally, in fact in a web page that I do myself it's accepting all commands
That error indicates a connection issue from PHP to the REST server and has nothing to do with the browser. Are you sure that the IP address and port number is correct?
Title: Re: RadioDJ REST web panel PHP
Post by: starm on September 21, 2016, 06:18:43 PM
I also use the first version of Austin we have adapted

in the np.php

$introdecompte= $xml->cueIntro - $xml->Position;
$heureduserveur= time();
if ($introdecompte <= 0)
$introdecompte = 0;



if ($introdecompte <= 0)
{
echo "document.getElementById('countdownIntro').innerHTML = \"00:00:00\";";
}
else{
echo "document.getElementById('countdownIntro').innerHTML = \"".gmdate("H:i:s", round($introdecompte))."\";";
}

Title: Re: RadioDJ REST web panel PHP
Post by: DJAntares on September 23, 2016, 04:59:56 PM
Quote from: Valdis on September 21, 2016, 11:30:19 AM
That error indicates a connection issue from PHP to the REST server and has nothing to do with the browser. Are you sure that the IP address and port number is correct?

Yes I'm sure. I use the public's static IP and the REST port on the RDJ machine setted correctaly on my router; in fact i can launch normally all commands with <a> flags in my PHP pages
Title: Re: RadioDJ REST web panel PHP
Post by: Copper007 on October 11, 2016, 11:41:01 AM
@ Valdis:

Working with it for a while, and it's so perfect for the editors in controlroom here......  :cool:

Kudo's for you and tnx again...

Grtz
Krid  8)
Title: Re: RadioDJ REST web panel PHP
Post by: FoxFrenzy on February 16, 2017, 04:57:45 AM
Valdis, I just got my web server up and running and I'm looking for a way to plop the UI on a Wordpress page.

Just FYI, before the panic, the link to the page will only be accessible after a user logs in with special permissions.
Title: Re: RadioDJ REST web panel PHP
Post by: DJ Garybaldy on February 16, 2017, 09:12:02 AM
Quote from: FoxFrenzy on February 16, 2017, 04:57:45 AM
Valdis, I just got my web server up and running and I'm looking for a way to plop the UI on a Wordpress page.

Just FYI, before the panic, the link to the page will only be accessible after a user logs in with special permissions.

Valdis hasn't been on the forums for a few months now you may not get the help you need with this issue unless someone knows...
Title: Re: RadioDJ REST web panel PHP
Post by: FoxFrenzy on February 16, 2017, 07:32:49 PM
Quote from: DJ Garybaldy on February 16, 2017, 09:12:02 AM
Valdis hasn't been on the forums for a few months now you may not get the help you need with this issue unless someone knows...

Blast and damnation.  I hope everything's okay with him.

I got it to somewhat display on the page if I trigger the index.php, but the style sheet won't load and it won't connect to the REST server.  I know the REST server works because I can use the Monitor tool without a problem.
The main object is to give my DJs a login which unlocks a special page in the menu on the website (that works).  Once they go to that page, they'll have access to the rest server and can turn off the AutoDJ and start their own copy RadioDJ.  The only thing I might have a problem with is kicking the server off Shoutcast so the DJ can connect his own.  I spoke with Marius about it in brief a few months ago.  A plugin that displays who's connected to the stream and a button to wrestle control from them.

I think I'm just trying to do more with RDJ than what Marius originally intended.  =/
Title: Re: RadioDJ REST web panel PHP
Post by: Jhonny on May 06, 2017, 08:46:42 PM
http://dj-jhonny.nl/!Andy-downloads/index.php (http://dj-jhonny.nl/!Andy-downloads/index.php)
Title: Re: RadioDJ REST web panel PHP
Post by: Jhonny on May 07, 2017, 03:24:37 PM
Sorry copy the link not well, updated it.

All his plugins are there Andy's plugins (http://dj-jhonny.nl/!Andy-downloads/index.php).
Title: Re: RadioDJ REST web panel PHP
Post by: afonsosantos53 on September 03, 2019, 03:38:28 AM
Hey all!

Any chance of re-posting the script? The link is offline...

Thanks!
Title: Re: RadioDJ REST web panel PHP
Post by: Jhonny on September 03, 2019, 07:55:27 AM
Sorry my old provider >:D is not redirecting the links.
https://radiodj.info/downloads-oldplugs/index.php (https://radiodj.info/downloads-oldplugs/index.php)
For the plug-ins v182
Title: Re: RadioDJ REST web panel PHP
Post by: afonsosantos53 on September 03, 2019, 07:00:31 PM
Thank you for the answer, but the download link now seems offline.
It's this one: https://radiodj.info/downloads-oldplugs/download.php?file=REST-Web-Panel-0.2b.zip
Title: Re: RadioDJ REST web panel PHP
Post by: Jhonny on September 03, 2019, 10:53:53 PM


Andy-downloads/REST-Web-Panel-0.2b.zip (https://radiodj.info/Andy-downloads/REST-Web-Panel-0.2b.zip)
Title: Re: RadioDJ REST web panel PHP
Post by: afonsosantos53 on September 03, 2019, 11:49:08 PM
Thank you for the updated link!
Title: Re: RadioDJ REST web panel PHP
Post by: Netgearss on September 11, 2019, 01:42:54 PM
Links not working, please update it if possible.
Title: Re: RadioDJ REST web panel PHP
Post by: Rick95 on September 11, 2019, 02:32:48 PM
Quote from: Netgearss on September 11, 2019, 01:42:54 PM
Links not working, please update it if possible.

Download:

[attachment deleted by admin]
Title: Re: RadioDJ REST web panel PHP
Post by: Netgearss on September 11, 2019, 04:03:23 PM
Thank you!
Title: Re: RadioDJ REST web panel PHP
Post by: deskr on July 31, 2020, 11:51:37 PM
Does it work with version 1.8?