UPNP client script 0.5 [MM3]
Hi, again,
I decided that I should go and use AsyncFind instead of FindByType. If done correctly, the script should be able to tell when a new device has come into play and when a device is gone. But I am stuck at something that is not obvious to me. Let me show you example code coming from MS:
This is the scripts.ini section:
If you try to use this code, the search function only works as long as the MsgBox is open. So, if you click on the MsgBox, then everything is gone.
What I believe is happening is related to this piece of info given by MS:
So the question is : does MM something similar as exiting the application when "End Sub" comes? What exactly is "exiting the application" in this context? What are the possible options to fix the AsyncFind?
The only option I see at the moment is to use an infinite loop in order not to end the funcion, so that the AsyncFind is still running. I hope there is a viable option. You know, it looks bad when you use code that says something like "while not doomsday" - just reminds me about my university years.
I expect v0.4 to have this kind of device finder method, as it makes everything easier, and the user should have a better experience (no waiting until search finishes).
Thanks for your time.
I decided that I should go and use AsyncFind instead of FindByType. If done correctly, the script should be able to tell when a new device has come into play and when a device is gone. But I am stuck at something that is not obvious to me. Let me show you example code coming from MS:
Code: Select all
Sub DeviceFinderCallback (device, UDN, calltype)
select case calltype
Case 0
output = "Found: " & vbCrLf
output = output & "DisplayName: " & device.FriendlyName & vbCrLf
output = output & "Type: " & device.Type & vbCrLf
output = output & "UDN: " & device.UniqueDeviceName & vbCrLf
MsgBox output
Case 1
MsgBox "device removed: " & UDN
Case 2
MsgBox "search complete"
end select
End Sub
Dim findData
Dim devicefinder
Set devicefinder = CreateObject("UPnP.UPnPDeviceFinder")
Sub StartFind()
findData = devicefinder.CreateAsyncFind("upnp:rootdevice", 0, _
GetRef("DeviceFinderCallback"))
devicefinder.StartAsyncFind(findData)
MsgBox "Searching for UPNP devices. Close this Message Box for stopping."
End Sub
Sub StopFind()
deviceFinder.CancelAsyncFind(findData)
End Sub
Code: Select all
[UPNP_SearchActivate]
FileName=AsyncUPNP_test.vbs
ProcName=StartFind
Order=50
DisplayName=Activate UPNP Async Search
Language=VBScript
ScriptType=0
[UPNP_SearchCancel]
FileName=AsyncUPNP_test.vbs
ProcName=StopFind
Order=51
DisplayName=Cancel UPNP Async Search
Language=VBScript
ScriptType=0
What I believe is happening is related to this piece of info given by MS:
This is what happens if I try to run the script from the command line - the application exits and so the AsyncFinds are gone.CancelAsyncFind
...
Remarks
Applications can keep asynchronous searches running until the application exits. Always cancel outstanding operations when exiting an application.
So the question is : does MM something similar as exiting the application when "End Sub" comes? What exactly is "exiting the application" in this context? What are the possible options to fix the AsyncFind?
The only option I see at the moment is to use an infinite loop in order not to end the funcion, so that the AsyncFind is still running. I hope there is a viable option. You know, it looks bad when you use code that says something like "while not doomsday" - just reminds me about my university years.
I expect v0.4 to have this kind of device finder method, as it makes everything easier, and the user should have a better experience (no waiting until search finishes).
Thanks for your time.
Hi, everyone.
I have upgraded MM to the latest version (v3.0.2 RC-1) with the debug option. Somehow, the script of the previous post began to work. I also checked the non-debug version, and it works. Do not know why, but hey, I will be working on new code with the Async Find. At the moment I only got the Device Discovery implemented, and I like it!
Regards.
I have upgraded MM to the latest version (v3.0.2 RC-1) with the debug option. Somehow, the script of the previous post began to work. I also checked the non-debug version, and it works. Do not know why, but hey, I will be working on new code with the Async Find. At the moment I only got the Device Discovery implemented, and I like it!
Regards.
Version 0.4
http://rapidshare.com/files/87168217/UP ... .mmip.html
Here you can find version 0.4. I worked a little bit in the Install/Uninstall script so that you are not forced to restart MM. I still fear that the Async search remains active after uninstall, though...
Now, for the good things:
* Async search is being used, focused on actual network status
* The UPNP server is being polled for every click on a node instead of download everything and then doing the job. This mimicks what my Roku does.
* There was support for administration webpages of devices, but it is gone in the release version... sorry about that.
* Users can easily add new services IDs. If your device does not show up in the list, it is likely to be because of this. Access the Options Pane in order to activate this option.
This is the list of things planned for the future:
* AlbumArt (maybe downloading them does the trick?)
* Device Icons (what MIME type should I choose for that function?)
Let me know if you find any trouble.
And thanks for testing.
Here you can find version 0.4. I worked a little bit in the Install/Uninstall script so that you are not forced to restart MM. I still fear that the Async search remains active after uninstall, though...
Now, for the good things:
* Async search is being used, focused on actual network status
* The UPNP server is being polled for every click on a node instead of download everything and then doing the job. This mimicks what my Roku does.
* There was support for administration webpages of devices, but it is gone in the release version... sorry about that.
* Users can easily add new services IDs. If your device does not show up in the list, it is likely to be because of this. Access the Options Pane in order to activate this option.
This is the list of things planned for the future:
* AlbumArt (maybe downloading them does the trick?)
* Device Icons (what MIME type should I choose for that function?)
Let me know if you find any trouble.
And thanks for testing.
By the way, I will be requesting something from you!
As far as I tested, these servers are supported:
I hope that the fields the script sets for the songs are right. If not, it could be possibly the server's fault. For example, SimpleCenter does not report Album Artist, as far as I have seen. WMP11 reports it as a "role", you can bet. If you want to mess with this, the best method is to use the DebugView program (you can download it from Microsoft). You also need the Debug version of MM for this to work. You will see that whenever the server is being polled, the resulting XML is being sent to the log.
That is all. Have fun listening to the music over the network.
As far as I tested, these servers are supported:
- Intel A/V server (as the spec)
TwonkyMedia (or at least was...)
Windows Media Player 11
SimpleCenter (No AlbumArtist support, popup shows an error but works)
- Philips Media Center (Use SimpleCenter instead)
On2Share
I hope that the fields the script sets for the songs are right. If not, it could be possibly the server's fault. For example, SimpleCenter does not report Album Artist, as far as I have seen. WMP11 reports it as a "role", you can bet. If you want to mess with this, the best method is to use the DebugView program (you can download it from Microsoft). You also need the Debug version of MM for this to work. You will see that whenever the server is being polled, the resulting XML is being sent to the log.
That is all. Have fun listening to the music over the network.
Version 0.5 released
Version 0.5 fixes the previous reported bug. You can grab it here.
http://www.mediafire.com/?6nj414v0zrg
As I like to write, I will tell you what happened (or what I believe that happened). Every time you click on a node, the client asks the server. As there was no limit of the number of items being reported by the server, the result variable got too big. So I limited the number of items being sent by the server to 50. Of course, the server has to be questioned many times now. I tested with a higher number and it failed, so I think 50 should be ok, although a little bit slow.
That is everything for today. Thanks.
http://www.mediafire.com/?6nj414v0zrg
As I like to write, I will tell you what happened (or what I believe that happened). Every time you click on a node, the client asks the server. As there was no limit of the number of items being reported by the server, the result variable got too big. So I limited the number of items being sent by the server to 50. Of course, the server has to be questioned many times now. I tested with a higher number and it failed, so I think 50 should be ok, although a little bit slow.
That is everything for today. Thanks.
-
- Posts: 4
- Joined: Fri May 04, 2007 1:58 pm
UPNP Script Error
I am getting the error #-2147220535 - File: "C:
...\Auto\UPNP.vbs", Line: 166, Column 2
If there is more I don't know as the message box cuts it off.
This happens on opening MM3(1134 build). I am running Vista ultimate and my server is the latest FreeNas build with UPNP enabled. The node does show up in the folders list--
Any ideas??
Thanx for the great work--
...\Auto\UPNP.vbs", Line: 166, Column 2
If there is more I don't know as the message box cuts it off.
This happens on opening MM3(1134 build). I am running Vista ultimate and my server is the latest FreeNas build with UPNP enabled. The node does show up in the folders list--
Any ideas??
Thanx for the great work--
Firstflyer
Firstflyer,
If I got you right, you got the "UPNP Servers" node and the NAS one. Then the script goes into initial directory filling, but it finds a problem with it. I suppose you have the version 0.5, as there was a problem with 0.4 if you had more than 100 songs/containers in one of the folders.
All of this means that you have the UPNP API installed and that you can use it properly. So it is not a Vista problem.
Actually, it fails in the "Browse" command. And I wonder why. Unfortunately, I haven't got any other computer so that I could install FreeNAS, or any other linux distro. The only way to test this is that you get Intel's Tools for UPNP Technology and try to issue the Browse command yourself. I will try to make it easy for anyone to follow. First, start up the Device Spy program. Then browse to your server, and look for the ContentDirectory service (sometimes called CDS). It should have a Browse action under it. At this stage you should get something similar to my first appshot. Right click on Browse and select Invoke. The second shot will appear. Fill in the details like I have done and click on Invoke.
If you got a response like myself, then there is something wrong with the way I stored the service object, or how I handle some things. I would appreciate if you could send as much info from Device Spy as possible. If the server fails (we hope not!), then there is something fishy going on with the server, but that shouldn't be the problem because you can use the UPNP server with other clients, don't you?
I realized that there are two things I should fix in the script:
a) No error handling from external API (like this one or the one I experiment with SimpleDevices UPNP server)
b) Script restores default settings every time
I know how to fix (b), but I wonder what to do with (a).
If you want to fix (b), then go into the script and edit line 461 so that it reads:, or change your MediaMonkey.ini file.
That is everything for today.
If I got you right, you got the "UPNP Servers" node and the NAS one. Then the script goes into initial directory filling, but it finds a problem with it. I suppose you have the version 0.5, as there was a problem with 0.4 if you had more than 100 songs/containers in one of the folders.
All of this means that you have the UPNP API installed and that you can use it properly. So it is not a Vista problem.
Actually, it fails in the "Browse" command. And I wonder why. Unfortunately, I haven't got any other computer so that I could install FreeNAS, or any other linux distro. The only way to test this is that you get Intel's Tools for UPNP Technology and try to issue the Browse command yourself. I will try to make it easy for anyone to follow. First, start up the Device Spy program. Then browse to your server, and look for the ContentDirectory service (sometimes called CDS). It should have a Browse action under it. At this stage you should get something similar to my first appshot. Right click on Browse and select Invoke. The second shot will appear. Fill in the details like I have done and click on Invoke.
If you got a response like myself, then there is something wrong with the way I stored the service object, or how I handle some things. I would appreciate if you could send as much info from Device Spy as possible. If the server fails (we hope not!), then there is something fishy going on with the server, but that shouldn't be the problem because you can use the UPNP server with other clients, don't you?
I realized that there are two things I should fix in the script:
a) No error handling from external API (like this one or the one I experiment with SimpleDevices UPNP server)
b) Script restores default settings every time
I know how to fix (b), but I wonder what to do with (a).
If you want to fix (b), then go into the script and edit line 461 so that it reads:
Code: Select all
.StringValue("UPNP_Client","Version") = "0.5"
That is everything for today.
I went to try this script tonite, but I get error:
error #-2147220223 -
file: J:\program files\mediamonkey3\scripts\auto\upnp.vbs, line 100, column 1
I was attempting to see if the script would see the UPNP server available within MusicIP Mixer. The UPNP used to be premium, I am not sure if it still does or not. I have a premium key and have used the UPNP in the past with a omnifi client, but not for a long time lately.
Also, if I might suggest, keep the first post updated with the link to most current version. And might try googlepages for hosting, you can direct download from there without having to go thru a hosting site.
error #-2147220223 -
file: J:\program files\mediamonkey3\scripts\auto\upnp.vbs, line 100, column 1
I was attempting to see if the script would see the UPNP server available within MusicIP Mixer. The UPNP used to be premium, I am not sure if it still does or not. I have a premium key and have used the UPNP in the past with a omnifi client, but not for a long time lately.
Also, if I might suggest, keep the first post updated with the link to most current version. And might try googlepages for hosting, you can direct download from there without having to go thru a hosting site.
New script: Last.FM Node Now with DJ Mode!
Last.fm + MediaMonkey = Scrobbler DJ!
Tag with MusicBrainz ~ Get Album Art!
Tweak the Monkey! ~ My Scripts Page
Last.fm + MediaMonkey = Scrobbler DJ!
Tag with MusicBrainz ~ Get Album Art!
Tweak the Monkey! ~ My Scripts Page
Thanks for the tips, I will try to put them into place later this evening.
As for now, I did a quick test and I observed that the same thing happens to me with the SimpleCenter media server. I put instead this simple loop:
And it fails, so I wonder what is happening. Unfortunately, I do not see any other way around. It would be best if there was a way to error catching in VBScript with anything else than "On Error Resume".
As for now, I did a quick test and I observed that the same thing happens to me with the SimpleCenter media server. I put instead this simple loop:
Code: Select all
For Each Service in Device.Services
Next
Re: UPNP Script Error
Hi, firstflyer, can you confirm what server are you using. I saw that in the freeNAS news that they changed UPNP servers in the last days. I wonder why.firstflyer wrote:I am getting the error #-2147220535 - File: "C:
...\Auto\UPNP.vbs", Line: 166, Column 2
If there is more I don't know as the message box cuts it off.
This happens on opening MM3(1134 build). I am running Vista ultimate and my server is the latest FreeNas build with UPNP enabled. The node does show up in the folders list--
Any ideas??
Thanx for the great work--
All right, I really tried for 10 minutes until I did not get any UPNP working. It does not show in the UPNP Device Spy, so I wonder what is happening here. I have seen many other people in their forums having trouble with MusicIP and UPNP. I gave it a try, but you know, I am working on another project, so I cannot spend too much time here.Teknojnky wrote:I went to try this script tonite, but I get error:
error #-2147220223 -
file: J:\program files\mediamonkey3\scripts\auto\upnp.vbs, line 100, column 1
I was attempting to see if the script would see the UPNP server available within MusicIP Mixer. The UPNP used to be premium, I am not sure if it still does or not. I have a premium key and have used the UPNP in the past with a omnifi client, but not for a long time lately.
Anyhow, I uploaded a fixed version of 0.5 with a bypass if the device is not being reported as a MediaServer. This fixed the problems I had with SimpleCenter, but I cannot be sure it can fix yours.