Sony Camera API with C# -


i have asked previous question on regards sony camera api , did still having problem. found following library https://github.com/kazyx/kz-remote-api made use sony camera api had make changes work wpf app optimized windows store apps.

i resorting myself unsure if need attach camera api file solution , if can find exact file because 1 api file downloaded has files android , ios in won't me.

i got thing working , tried put in such manner understandable. if sony library wrote please let me know tried kazyx library , didn't work me.

my code below.

    private string cameraurl;      private bool recmodeactive;      public void controlcamera(string cameraresp)     {         cameraurl = string.format("{0}/{1}", getcameraurl(cameraresp), getactiontype(cameraresp));     }      private string camerarequest(string cameraurl, string camerarequest)     {         uri urluri = new uri(cameraurl);          httpwebrequest camerareq = (httpwebrequest)webrequest.create(cameraurl);         camerareq.method = "post";         camerareq.allowwritestreambuffering = false;         camerareq.contenttype = "application/json; charset=utf-8";         camerareq.accept = "accept-application/json";         camerareq.contentlength = camerarequest.length;         using (var camerawrite = new streamwriter(camerareq.getrequeststream()))         {             camerawrite.write(camerarequest);         }         var cameraresp = (httpwebresponse)camerareq.getresponse();         stream camerastream = cameraresp.getresponsestream();         streamreader cameraread = new streamreader(camerastream);         string readcamera = cameraread.readtoend();          return readcamera;     }      public string getcameraurl(string cameraresp)     {         string[] cameraxml = cameraresp.split('\n');         string cameraurl = "";         foreach (string camerastring in cameraxml)         {             string getcameraurl = "";             if (camerastring.contains("<av:x_scalarwebapi_actionlist_url>"))             {                 getcameraurl = camerastring.substring(camerastring.indexof('>') + 1);                 cameraurl = getcameraurl.substring(0, getcameraurl.indexof('<'));             }         }         return cameraurl;     }      public string getactiontype(string cameraresp)     {         string[] cameraxml = cameraresp.split('\n');         string actiontype = "";         foreach (string camerastring in cameraxml)         {             string gettype = "";             if (camerastring.contains("<av:x_scalarwebapi_servicetype>"))             {                 gettype = camerastring.substring(camerastring.indexof('>') + 1);                 actiontype = gettype.substring(0, gettype.indexof('<'));                 if (actiontype == "camera")                 {                     break;                 }             }         }         return actiontype;     }      public string startrecmode()     {         string startrecmode = jsonconvert.serializeobject(new camera.camerasetup         {             method = "startrecmode",             @params = new list<string> { },             id = 1,             version = "1.0"         });          recmodeactive = true;          return camerarequest(cameraurl, startrecmode);     }      public string triggercamera()     {         string _triggercamera = jsonconvert.serializeobject(new camera.stillcapture         {             method = "acttakepicture",             @params = new list<string> { },             id = 1,             version = "1.0"         });          return camerarequest(cameraurl, _triggercamera);     }      public string echorequest()     {         string _echorequest = jsonconvert.serializeobject(new camera.testcameracomm         {             method = "getevent",             @params = new list<bool> { true },             id = 1,             version = "1.0"         });          return camerarequest(cameraurl, _echorequest);     }      public string stoprecmode()     {         string stoprecmode = jsonconvert.serializeobject(new camera.camerasetup         {             method = "stoprecmode",             @params = new list<string> { },             id = 1,             version = "1.0"         });          recmodeactive = false;          return camerarequest(cameraurl, stoprecmode);     }      public string setimagequality()     {         string qualityreq = jsonconvert.serializeobject(new camera.camerasetup         {             method = "setstillsize",             @params = new list<string> { "4:3", "20m"},             id = 1,             version = "1.0"         });          recmodeactive = false;          return camerarequest(cameraurl, qualityreq);     }` 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -