Reply to thread

Just to give you an idea, the code is not usable alone like this, but at least you have the required json parameters needed.


You can find the needed params value in the ipimp code for your needs. I don't use radio or EPG so can"t help on this part.


It use Jayrock for the json handling.


[CODE]public JsonObject IPimpCommand(CommandInfoIPimp command)

        {

            var error = new JsonObject();

            error["result"] = false;


            if (command == null)

                return error;


            lock (Locker)

            {

                var args = new JsonObject();

                args["action"] = command.Action;

                args["filter"] = command.Filter;

                args["value"] = command.Value;

                args["start"] = command.Start;

                args["pagesize"] = command.PageSize;

                args["shuffle"] = command.Shuffle;

                args["enqueue"] = command.Enqueue;

                args["tracks"] = command.Tracks;


                if (command.Action != "ping" && command.Action != "nowplaying")

                    Log("COMMAND : " + args);

                else

                    Trace("COMMAND : " + args);


                var myCompleteMessage = "";


                var webRequest = WebRequest.Create(GetApiPath());

                webRequest.Method = "POST";


                var byteArray = Encoding.UTF8.GetBytes(args.ToString());

                webRequest.ContentType = "application/x-www-form-urlencoded";

                webRequest.ContentLength = byteArray.Length;


                try

                {

                    var datastream = webRequest.GetRequestStream();

                    {

                        datastream.Write(byteArray, 0, byteArray.Length);

                        datastream.Close();


                        var webResponse = webRequest.GetResponse();

                        if (webResponse != null)

                        {

                            using (var datastream2 = webResponse.GetResponseStream())

                            {

                                if (datastream2 != null)

                                {

                                    var reader = new StreamReader(datastream2);

                                    myCompleteMessage = reader.ReadToEnd();

                                }

                            }

                            webResponse.Close();

                        }

                    }

                }

                catch (Exception)

                {

                    if (command.Action != "ping" && command.Action != "nowplaying")

                        Log("ERROR - COMMAND : " + args);

                    else

                        Trace("ERROR - COMMAND : " + args);

                    myCompleteMessage = error.ToString();

                }


                Trace(myCompleteMessage);

                return (JsonObject)JsonConvert.Import(myCompleteMessage);

            }

        }[/CODE]


Top Bottom