Maybe i'm blind but i can't find a simple example how to connect to a UPnP server.
All i'm looking for is a code to list all songs in it's library. Later on i want to stream a song. But for the moment i would be happy to see code to connect to a server and simply list all songs. Or is that way harder than i think at the moment?
Java preferred, but any other language would do.
thanks!
MrM
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are two different UPNP devices. One is a content server and the other something else, I don't remember - see the upnp A/V specification.
Anyways, here's some very messy test code of mine, in Scala and Java - look at the bottom. It basically finds a TVersity server in my home network and starts browsing its content.
I looked at it and remembered what's going on. The relevant piece of code is this:
def Browse(ObjectId: String , BrowseFlag:String, StartingIndex:String, RequestedCount:String) = {
val directory = actual.services.filter (_.serviceType == "urn:schemas-upnp-org:service:ContentDirectory:1").head
val action = directory.actions.filter (_.name == "Browse").head
action.inArgs.setAttr("ObjectID", ObjectId, "BrowseFlag", BrowseFlag, "StartingIndex", StartingIndex, "RequestedCount", RequestedCount)
action.execute
val aa = action.outArgs
action
}
in the device, you'll find services and they have actions - all from cyber link's library - I had some Scala wrappers to make it easy. Find the "Browse" action and just invoke it…
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Connection & Browsing works perfectly now!
Anyone a tutorial how to get streaming kicking in? I just need audio streaming. Do i need to set up my own MediaRenderer Device for that or is it possible without (i don't need to remote remote control it etc.)?
Thanks
MrM
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
Maybe i'm blind but i can't find a simple example how to connect to a UPnP server.
All i'm looking for is a code to list all songs in it's library. Later on i want to stream a song. But for the moment i would be happy to see code to connect to a server and simply list all songs. Or is that way harder than i think at the moment?
Java preferred, but any other language would do.
thanks!
MrM
There are two different UPNP devices. One is a content server and the other something else, I don't remember - see the upnp A/V specification.
Anyways, here's some very messy test code of mine, in Scala and Java - look at the bottom. It basically finds a TVersity server in my home network and starts browsing its content.
http://github.com/razie/razupnp/blob/master/src/razie/upnp/UpnpInventory.scala
Sorry about the mess - I left it in testing stage and I don't know when I'll come back to it.
I looked at it and remembered what's going on. The relevant piece of code is this:
def Browse(ObjectId: String , BrowseFlag:String, StartingIndex:String, RequestedCount:String) = {
val directory = actual.services.filter (_.serviceType == "urn:schemas-upnp-org:service:ContentDirectory:1").head
val action = directory.actions.filter (_.name == "Browse").head
action.inArgs.setAttr("ObjectID", ObjectId, "BrowseFlag", BrowseFlag, "StartingIndex", StartingIndex, "RequestedCount", RequestedCount)
action.execute
val aa = action.outArgs
action
}
in the device, you'll find services and they have actions - all from cyber link's library - I had some Scala wrappers to make it easy. Find the "Browse" action and just invoke it…
Hi!
Didn't know Scala until now :]
This code is perfectly what i was looking for! Thanks! Works like a charm.
Now i only have to find out why my XBMC just shows a empty library (Does the same in all other UPnP controlpoints except the XBMC remote).
Thanks a lot!
MrM
Ok!
Connection & Browsing works perfectly now!
Anyone a tutorial how to get streaming kicking in? I just need audio streaming. Do i need to set up my own MediaRenderer Device for that or is it possible without (i don't need to remote remote control it etc.)?
Thanks
MrM