Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JavaScript Control Point UPnP Media Server Access Code
07-07-2011, 08:25 AM
Post: #1
JavaScript Control Point UPnP Media Server Access Code
I know it's not strictly ohNet but would 'the team' be interested in the JavaScript I use (In Konductor) to access a media server? I'd be happy to extract it from Konductor & apply an appropriate licence (probably BSD) to it.

It would take me a week or so to properly component'ise it and it could do with some Doxygen comments added.

Ideally I should move it to using 'your' SOAP model (+ jQuery) as apposed to it existing hand rolled code.

Rik
Find all posts by this user
07-07-2011, 01:20 PM
Post: #2
RE: JavaScript Control Point UPnP Media Server Access Code
Hi rik,

What would it offer beyond:
https://github.com/openhome/ohNet/blob/m...ectory1.js

Graham
Find all posts by this user
07-07-2011, 01:37 PM
Post: #3
RE: JavaScript Control Point UPnP Media Server Access Code
Hi,

What you have so far would just provide a result along the lines of:

<container id="1$14$1415865445$1415865724$1415865797" parentID="1$14$1415865445$1415865724" restricted="1" ><dc:title>Faithless</dc:title><upnp:class>object.container.storageFolder</upnp:class></container><container id="1$14$1415865445$1415865724$1415865725" parentID="1$14$1415865445$1415865724" restricted="1" ><dc:title>Fatboy Slim</dc:title><upnp:class>object.container.storageFolder</upnp:class></container><container id="1$14$1415865445$1415865724$1415865728" parentID="1$14$1415865445$1415865724" restricted="1" ><dc:title>Faultline</dc:title><upnp:class>object.container.storageFolder</upnp:class></container><container id="1$14$1415865445$1415865724$1415865730" parentID="1$14$1415865445$1415865724" restricted="1" ><dc:title>Faure</dc:title><upnp:class>object.container.storageFolder</upnp:class></container>

i.e. a while load of XML

What I have takes this & converts it to JSON so you would get more like this:

[
{id: "1$14$1415865445$1415865724$1415865795",
parentID: "1$14$1415865445$1415865724",
title: "Fairground Attraction",
UPnPclass: "object.container.storageFolder",
},
{id: "1$14$1415865445$1415865724$1415865797",
...
Find all posts by this user
07-07-2011, 02:36 PM
Post: #4
RE: JavaScript Control Point UPnP Media Server Access Code
Was just wondering why you would not just parse the XML directly, rather than convert to JSON and then parse the JSON?

Graham
Find all posts by this user
07-07-2011, 02:44 PM (This post was last modified: 07-07-2011 02:44 PM by rik.)
Post: #5
RE: JavaScript Control Point UPnP Media Server Access Code
Hi,

Parsing XML in JavaScript is a right pain (& quite slow) - bespoke regexps to create a JS (or JSON) object are much faster (x10 at least). Probably would just return the object and not JSON - but if you ever get JSON then you can do a one line:

myObject = eval('{"some": "json"}'); // Obvious security issues if untrusted.

In general JavaScript programmers (& their programs!) would prefer JSON (Or just objects).

Rik
Find all posts by this user
07-07-2011, 04:12 PM
Post: #6
RE: JavaScript Control Point UPnP Media Server Access Code
Ok, so, yes, a DIDL-Lite to JSON conversion function and a JSON to DIDL-Lite conversion function would be welcome. Maybe you could then convert your stuff over to use the ohNet JS code.

Graham
Find all posts by this user
07-07-2011, 04:43 PM
Post: #7
RE: JavaScript Control Point UPnP Media Server Access Code
I'll do that. Won't happen for a week or so as I want to get the next release of Konductor out. But I will do it.

Rik
Find all posts by this user


Forum Jump: