Home of the Squeezebox™ & Transporter® network music players.
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21
  1. #11
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,723

    Problems with controlling my squeezeboces via myhomepage?!

    > Representation of the control and database on the client via
    > Javascript.
    > Communication of the website via Ajax to a php-file on the server.
    > Communication with the LMS via the php-file, e.g. json/rpc interface.
    >
    > For the first two points I will find the solution on the internet and it
    > is not really correlated with the LMS-problematic. But could you please
    > send me a link/tutorial/something to read, for the last point, how the
    > json/rpc interface works.


    First find some sample code for PHP doing JSON/RPC on the server side.
    Eg. http://jsonrpcphp.org. Familiarize yourself with this method.

    Then get familiar with LMS' implementation. It's easiest to eg. fire up
    firebug in firefox and monitor what is going on when you browse the LMS
    web UI. In the console you'd see all the requests going back and forth.
    Documentation of the commands and queries available you'll find in
    http://pi:9000/html/docs/cli-api.html (or whatever your server)

    --

    Michael

  2. #12
    Junior Member
    Join Date
    Mar 2014
    Posts
    16
    Now everything is a bit clearer.
    Will have a look into this. thx

  3. #13
    Junior Member
    Join Date
    Mar 2014
    Posts
    16

    Plugin SqueezeCloud usable with CLI/JSON-RPC

    Hi,

    something I come across while studying the CLI/JSON-RPC stuff was the controlling of the plugins, to be exact the SqueezeCloud-plugin.

    Using the http-request method, the plugin can be controlled like this:

    Code:
    anyurl?p0=playlist&p1=add&p2=soundcloud%3A%2F%2F106399621&p3=Falscher Hase at Fuchsbau Festival - 16-08-2013&player=MAC-adress
    How should this command look like, if I use the CLI/JSON API??? :S

  4. #14
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,723

    Problems with controlling my squeezeboces via myhomepage?!

    > --------------------
    > anyurl?p0=playlist&p1=add&p2=soundcloud%3A%2F%2F10 6399621&p3=Falscher Hase at Fuchsbau Festival - 16-08-2013&player=MAC-adress
    > --------------------


    This would become something like

    ["00:02:40:....", ["playlist", "add", "soundloud:....", "Falscher hase..."]]

    Check http://yourserver:9000/html/docs/cli...playlist%20add for
    the command reference. It's pretty much putting p0-p99 into a list of
    the json object.

    --

    Michael

  5. #15
    Junior Member
    Join Date
    Mar 2014
    Posts
    16
    Hi,

    I found another (better?) solution. I just used the curl-function of php to control the LMS. Looks like this now:

    Code:
    $JsonString = '$Json = json_encode(array("id" => 1, "method"=> "slim.request","params"=> array(';
    
    switch ($_POST["p0"]) {
    	case 'pause' :
    	case 'play' :
    		$JsonString .= $playerId.',array("pause"))));';
    		break;
    
    	case 'rewind':
    		$JsonString .= $playerId.',array("time","-10"))));';
    		break;
    ...
    }
    eval($JsonString);
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $LmsUrl);
    curl_setopt($ch, CURLOPT_USERPWD, $User.":".$Pw);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $Json);
    
    // $output contains the output string
    // 
    $output = curl_exec($ch);
    // close curl resource to free up system resources
    curl_close($ch);
    echo $output;
    and this will be called via an ajax-function by the client as follows:
    Code:
    $( ".LmsButton" ).click(function() {
    	var blub = $(this).attr('id');
    	$.ajax({
    		url: '/JsonRpc.inc.php',
    		type: 'POST',
    		dataType: 'json',
    		data: {p0: blub},
    		success: function(data) {
    		}
    	})	
    });
    Hope this will help somebody.


    But I have another question, which came into my mind. Is it possible to send more than one command to the LMS, like

    ["00:02:40:....", ["playlist", "add", "soundloud:....", "Falscher hase..."],["playlist", "add", "soundloud:....", "Guter Esel..."],["play"]];

  6. #16
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,793
    Yes, but you need to send complete commands, including the target player. Just add them to the array.
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  7. #17
    Junior Member
    Join Date
    Mar 2014
    Posts
    16
    Hi Pippin,

    I think I don't get it.

    What I tried
    Code:
    {"id":1,"method":"slim.request","params":[<playerid>,["mode","?"],<playerid>,["artist","?"],<playerid>",["title","?"]]}
    resulting in:
    Code:
    {"params":["00:04:20:1e:e1:11",["mode","?"],"00:04:20:1e:e1:11",["artist","?"],"00:04:20:1e:e1:11",["title","?"]],"method":"slim.request","id":1,"result":{"_mode":"pause"}}
    is obvious wrong, but I don't know how this should look like.

    Could you please post an example. Thx in advance.

  8. #18
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,793
    Yes, you need to send an array of complete JSON/RPC commands:
    Code:
    [
        {
            "id":1,
            "method":"slim.request",
            "params":[<playerid>,["mode","?"]]
        },
        {
            "id:2,
            "method":"slim.request",
            "params":[<playerid>,["artist","?"]]
        },...
    ]
    That said: I'm no longer 100% sure that this works with JSON/RPC, actually I believe I have never done it this way. I do it with cometd but that protocol explicitly allows for command arrays.
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  9. #19
    Junior Member
    Join Date
    Nov 2014
    Posts
    18
    Quote Originally Posted by mherger View Post
    Now the question is: do you really need to serve up that page from
    Apache? You could use LMS' built-in web server to provide that page instead.
    Hi

    Can you point me in the direction of how I might get LMS to serve up my HTML pages (where do I need to put them, etc)?

    Thanks

  10. #20
    Senior Member
    Join Date
    Jun 2017
    Posts
    732
    Quote Originally Posted by zmpo View Post
    Hi

    Can you point me in the direction of how I might get LMS to serve up my HTML pages (where do I need to put them, etc)?

    Thanks
    Try this thread:

    https://forums.slimdevices.com/showt...=1#post1036643
    Usually running latest beta LMS nightly on Raspberry Pi OS with virtual players (Squeezelite and Airplay bridge). Occasionally using SB Radio, Boom or Classic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •