Archive for the ‘Programming’ Category

A Community Directory

Saturday, December 24th, 2005

Yes, it is another day in Second Life. I have been working on my little project with detecting land owners. My detection has become stable enough that I’ve started to work on a neat little utility for it. This “hub” is a directory of all land owners. here is a list of features I would like it to have:

  • Navigate forward/backward through list of land owners
  • Display percent of land owned
  • Display owner ratings (behavior, appearance, building)
  • Status if owner is online.
  • Teleport to owners parcel.
  • Send IM to owner
  • Allow land owners to submit image to represent there avatar and land.
  • See when owner was first detected.
  • See how long owner has had an account with SL.

A few of these probably will not make it into the game. I’ve resorted to using pie charts for the ratings and land ownership in my mock-up. Hover-text is helpful, but I do not want to use it everywhere. I may end up having a button to just say the additional information if the end-user wants to hear it.

If it becomes popular, perhaps many Sims will have there own community directories.

Earlier in the day I was having problems making a concave cylinder. I’ve seen other objects in the world where the sides bend in the middle as a curve. Lynuor Richelieu came to the rescue and taught me how to make them. It turns out that you actually start out with a Torus. This is pretty much a shape that looks like a donut. You hollow it out and then cut the outside of it off. This way, you are left with just the center. These concave cylinders make for nice stands.

Detecting land owners

Friday, December 23rd, 2005

I got to work on my detection scripts today in Second Life. Last night, I had problems where it would estimate a run time of twelve minutes and thirty seconds. The script actually ended up taking over forty minutes. The only explanation that I could come up with was that there must be a bottle neck in my code.

I focused on the number of times I keep looping through my lists of items. This was being done every time I tried to see if an owner was previously found. I looked at a few of the methods available on the Second Life Scripting Wiki. I found a method called llListFindList. This internal function goes through the list much quicker and returns the position of the item that I’m looking for. As soon as I implemented this method, my script completed in 12 minutes and 53 seconds. Being off by 23 seconds is still a little problem, but I’m not as worried about it.

I changed a few things about the object. For one, the progress is displayed every 1 second, rather then every 10 percent. This helps with those long running queries. Also, I made the progress hover over top of the object rather then have the object talk. Who needs chat logs for that kind of stuff any way?

I tried looking into saving note cards for each region that I scan, but I didn’t run into any luck. I found that I can read note cards, but I can’t create or modify them. It also appears that I may be able to email the reports to an avatar rather then have the object talk out loud.

I need to do a few extra things such as only permitting the owner to start the detection process, checking to see if the region has changed, and stop the timers if the object is rezzed or enters a new state. Most of the work left is just cleaning up after myself and trying to handle any situation that may come up.

Second Life Land Owner Detector

I should be able to package this object on its own and sell it. I’m debating on selling different versions for how accurate you want to get with the detection. The standard being 10 square meters will run in one and a half minutes. A five square meter version will run in about five minutes. Three square meters runs in almost thirteen minutes. I would sell a detection script within one square meter, but that takes an hour and fifty minutes to run the scripts. I don’t want Second Life to be pegged with executions. How accurate do you really need to get? I’m still looking for ways to make this script run faster.

Detecting every 10 square meters is accurate enough to get a list of all land owners. 3 square meters will get you a list of land owners with a very close estimate of how much land they own in that region. After putting on the final touches, my next little project will be to make an online status indicator for all the land owners in the area. I’ve got some ideas to keep the prim count down.

I’ve noticed that we have lost two land owners (Thoth Mason and Pelagia Sieyes) since yesterday, so the kiosk will need to be able to update itself once or twice a day with the current list of owners. Perhaps it can send the owner of the kiosk a message when ownership of land on the Sim changes. That way we can invite and remove landowners from our landowners association group.

(Unresolved Name) - 3231 sq. m. (5%)
Governor Linden - 10701 sq. m. (17%)
Corben McGann - 558 sq. m. (1%)
Brigit Flasheart - 495 sq. m. (1%)
Spiritual Warrior - 12618 sq. m. (19%)
R0B0 Overlord - 495 sq. m. (1%)
Andreas Naumova - 522 sq. m. (1%)
Dinger Hartnell - 495 sq. m. (1%)
Aldaris Asturias - 495 sq. m. (1%)
jaz Dassin - 594 sq. m. (1%)
(Unresolved Name) - 2475 sq. m. (4%)
Deme Tuppakaka - 594 sq. m. (1%)
Cilae Trescothick - 594 sq. m. (1%)
Nids Ornitz - 540 sq. m. (1%)
Odile Liberty - 441 sq. m. (1%)
Vectron Unknown - 450 sq. m. (1%)
Persephone Menoptra - 990 sq. m. (2%)
Gabriel Montagne - 495 sq. m. (1%)
Berg Churchill - 567 sq. m. (1%)
Kody Bergson - 450 sq. m. (1%)
Maximillian Faust - 495 sq. m. (1%)
(Unresolved Name) - 9 sq. m. (1%)
Aspen Normandy - 495 sq. m. (1%)
Sammi Normandy - 495 sq. m. (1%)
Earnest Candour - 594 sq. m. (1%)
(Unresolved Name) - 594 sq. m. (1%)
Lampiasis Maginot - 495 sq. m. (1%)
(Unresolved Name) - 2178 sq. m. (4%)
Charlotte Menoptra - 531 sq. m. (1%)
markop Trenchmouth - 495 sq. m. (1%)
Maximillian Prudhomme - 1575 sq. m. (3%)
JaneSmith Gumshoe - 450 sq. m. (1%)
Chardonnay Mathys - 1089 sq. m. (2%)
Edmond Gavaskar - 495 sq. m. (1%)
Clark Liberty - 495 sq. m. (1%)
Arrai Lobo - 495 sq. m. (1%)
Melody Strauss - 495 sq. m. (1%)
Star Lewis - 540 sq. m. (1%)
(Unresolved Name) - 594 sq. m. (1%)
Ansuru Axon - 495 sq. m. (1%)
Aura Diamond - 450 sq. m. (1%)
Kate Mommsen - 495 sq. m. (1%)
Adrien Kuhr - 540 sq. m. (1%)
Sarah Davison - 450 sq. m. (1%)
Storm Reymont - 540 sq. m. (1%)
(Unresolved Name) - 450 sq. m. (1%)
(Unresolved Name) - 1062 sq. m. (2%)
Dedric Mauriac - 495 sq. m. (1%)
margera Bunin - 495 sq. m. (1%)
Foxknight Graff - 594 sq. m. (1%)
Brooke Boccara - 540 sq. m. (1%)
Dexter Overlord - 495 sq. m. (1%)
Pym Sartre - 495 sq. m. (1%)
Alika Bertone - 495 sq. m. (1%)
(Unresolved Name) - 594 sq. m. (1%)
Eblis Black - 495 sq. m. (1%)
Noir Maelstrom - 495 sq. m. (1%)
Cyndane Desmoulins - 495 sq. m. (1%)
Twisted Tardis - 2178 sq. m. (4%)
Ema Bessie - 495 sq. m. (1%)
Colleen Desmoulins - 495 sq. m. (1%)
Thaumata Strangelove - 594 sq. m. (1%)
KoL Maeterlinck - 594 sq. m. (1%)
Fenix Frua - 495 sq. m. (1%)
(Unresolved Name) - 540 sq. m. (1%)
Moriarty Augustus - 594 sq. m. (1%)

Scripting a name for myself

Friday, December 23rd, 2005

Second Life is still overtaking my first life. I started to build a lava lamp the other night at my lounge in the sky and showed it to one of my friends. She invited me to her shop and showed me 4 lamps that she had made. It just really put my lamp to shame. Hers were really to spec with the size, shape and color. Her textures were far better. On top of this, she was quite successful in selling them at 100 L$ each.

From that point own, I started building my own lava lamp. I looked at a few sites for reference and created a few textures. With just 4 primitive objects, I was able to put something together that looked very classy. I went through my entire library looking at free textures to use. I even found a sound of bubbles underwater that gives a nice mood to the lamp.

I started getting into scripting pretty heavy. I learned how to make one primitive within the group of objects talk to the others. From there, I was able to turn the light on and off when the end-user touched it. I also got the user-interface to change it’s text to say “Turn On” and “Turn Off”. When the light is off, the gradient fallout disappears, some of the faces toggle there full bright property, and the texture animation stops. When the light is turned back on, everything returns to the original state. The only difference is that the texture for the “lava” changes to the next image in the contents of the lamp.

I went ahead and started playing around even more with listeners. I have a special channel setup so that you can tell the light to change “moods” (textures), turn on/off, toggle the fallout, and list all available textures.

I bragged to my friend the next night about my little creation and she admitted that it put her lights to shame. We are talking about forming a group so that she can earn a commission selling my lamp with hers. Mine would go for a higher price since it is scripted. I’m estimating 250 L$.

Dedric poses in front of his Lava Lamps

She is also interested in using my scripting skills on group projects. Builders go hand-in-hand with scripters. My building skills are very limited. From the work that I have seen of hers, we could do some pretty cool things together along with another friend of ours (Twisted).

Today, Twisted and I formed a group for our sim (Dagger) called Dagger Landowners Association. The purpose is to get people together and get some kind of collaborative theme going. When simulators do this, it attracts more traffic to the region in general and builds a sense of community. One idea was to just have everyone make sidewalks connecting to each others property.

Twisted had an idea to build a script so that as he flew over parcels in the region, the script would build a list of names. I took on the challenge and started getting to work. I learned much about using timers, the data server, and lists (much like arrays). In the end, I found the following people owned some land in Dagger without having to fly over them:

Searching for land owners in Dagger every 3 sq. m.
Estimated time: 0 hours, 12 minutes, 26 seconds.
11% of land scanned.
22% of land scanned.
32% of land scanned.
43% of land scanned.
53% of land scanned.
64% of land scanned.
75% of land scanned.
85% of land scanned.
96% of land scanned.
Found 68 unique owners found within Dagger
10 owner names being ressolved.
(Unresolved Name) - 3231 sq. m. (5%)
Governor Linden - 10701 sq. m. (17%)
Corben McGann - 558 sq. m. (1%)
Brigit Flasheart - 495 sq. m. (1%)
Spiritual Warrior - 12618 sq. m. (19%)
R0B0 Overlord - 495 sq. m. (1%)
Andreas Naumova - 522 sq. m. (1%)
Dinger Hartnell - 495 sq. m. (1%)
Aldaris Asturias - 495 sq. m. (1%)
jaz Dassin - 594 sq. m. (1%)
(Unresolved Name) - 2025 sq. m. (4%)
Deme Tuppakaka - 594 sq. m. (1%)
Cilae Trescothick - 594 sq. m. (1%)
Nids Ornitz - 540 sq. m. (1%)
Odile Liberty - 441 sq. m. (1%)
Vectron Unknown - 450 sq. m. (1%)
Persephone Menoptra - 540 sq. m. (1%)
Thoth Mason - 450 sq. m. (1%)
Gabriel Montagne - 495 sq. m. (1%)
Berg Churchill - 567 sq. m. (1%)
Kody Bergson - 450 sq. m. (1%)
Maximillian Faust - 495 sq. m. (1%)
(Unresolved Name) - 9 sq. m. (1%)
Aspen Normandy - 495 sq. m. (1%)
Sammi Normandy - 495 sq. m. (1%)
Earnest Candour - 594 sq. m. (1%)
(Unresolved Name) - 594 sq. m. (1%)
Lampiasis Maginot - 495 sq. m. (1%)
(Unresolved Name) - 2178 sq. m. (4%)
Charlotte Menoptra - 531 sq. m. (1%)
markop Trenchmouth - 495 sq. m. (1%)
Pelagia Sieyes - 450 sq. m. (1%)
Maximillian Prudhomme - 1575 sq. m. (3%)
JaneSmith Gumshoe - 450 sq. m. (1%)
Chardonnay Mathys - 1089 sq. m. (2%)
Edmond Gavaskar - 495 sq. m. (1%)
Clark Liberty - 495 sq. m. (1%)
Arrai Lobo - 495 sq. m. (1%)
Melody Strauss - 495 sq. m. (1%)
Star Lewis - 540 sq. m. (1%)
(Unresolved Name) - 594 sq. m. (1%)
Ansuru Axon - 495 sq. m. (1%)
Aura Diamond - 450 sq. m. (1%)
Kate Mommsen - 495 sq. m. (1%)
Adrien Kuhr - 540 sq. m. (1%)
Sarah Davison - 450 sq. m. (1%)
Storm Reymont - 540 sq. m. (1%)
(Unresolved Name) - 450 sq. m. (1%)
(Unresolved Name) - 1062 sq. m. (2%)
Dedric Mauriac - 495 sq. m. (1%)
margera Bunin - 495 sq. m. (1%)
Foxknight Graff - 594 sq. m. (1%)
Brooke Boccara - 540 sq. m. (1%)
Dexter Overlord - 495 sq. m. (1%)
Pym Sartre - 495 sq. m. (1%)
Alika Bertone - 495 sq. m. (1%)
(Unresolved Name) - 594 sq. m. (1%)
Eblis Black - 495 sq. m. (1%)
Noir Maelstrom - 495 sq. m. (1%)
Cyndane Desmoulins - 495 sq. m. (1%)
Twisted Tardis - 2178 sq. m. (4%)
Ema Bessie - 495 sq. m. (1%)
Colleen Desmoulins - 495 sq. m. (1%)
Thaumata Strangelove - 594 sq. m. (1%)
KoL Maeterlinck - 594 sq. m. (1%)
Fenix Frua - 495 sq. m. (1%)
(Unresolved Name) - 540 sq. m. (1%)
Moriarty Augustus - 594 sq. m. (1%)

There are only 10 people that I can’t find the names for. I’ll have to look up the region of these folks and find out what the land properties say when I’m there. The numbers next to each name are the estimated number of square meters that the person owns. Since I’m searching every 3 meters, it thinks that I own 495 sq. m. when in fact, I own 512. Being off by 18 sq. m. doesn’t seem to be too bad for an estimate. There is also percentage next to it stating how much of the region they own. The details would get more accurate as I lower the number of square meters to scan.

The estimated time is way off. Rather then taking the estimated 12 minutes, this script took 40 minutes to complete. I need to take a look at what is causing the script to take about a half hour more then I expected. The script originally took a very long time to execute when jumping every 10 sq. m. It was such a long time to execute that I had to start breaking things up with timers. Many of my asynchronous events with the data server were not even being caught before I started using the timer events. This also helps to avoid lag on the sim.

People are starting to get impressed. I’ve got a load of ideas to expand this script, such as creating an online status board of the regions land owners.

Automagic Podcaster

Sunday, November 27th, 2005

Today I learned how to pull images out of my audio files. Woohoo! I also started using a free little program called ID3-TagIT to add meta data to my files. So far, everything is working like a charm.

So let me tell you a little bit about the reason I’m doing all of this. Podcasting! A few of you may have known about my Dreamy Audio podcast. Every now and then I wake up and speak into a voice recorder about what I had just dreamt about. Eventually, I get around to moving the files to my computer, editing them, and then uploading to the website.

There are many steps involved in this process. I’m aiming to take a few steps out by automating a few things. With the scripts that I have been setting up, you just upload an audio file into a directory and forget about it. The scripts read all of the meta data and build your feeds, a blog-like website, and it even has a flash audio player on the front page that lets visitors play the most recent audio files.

Once I had an edited file ready, I used to upload it to a separate site and tell that site to publish things over to my blog. I would have to enter data for a few things but was not pleased how it would strip away any meta data that I had already placed in the file.

The ID3-TagIT program is helping out very much as well. I am no longer limited to the fields that iTunes and Win amp permit me to use. ID3-TagIT lets you edit just about every known field. It does not yet support chapters though. You can visit the new podcast for Dreamy Audio or take a look at some of the details that I can pull out of an audio file.

I eventually want to package the script and let the community use it to make there own podcasts much easier.

Problem Solved

Saturday, November 26th, 2005

MP3 ID3v2 PHP CodeI solve problems for a living. It is the point of overcoming a difficult problem that gives me the most joy. I was trying to read MP3 files with a script so that I could determine the length of the audio playtime in seconds. I just broke through and got it to work.

So now comes the fun part. I get to clean up the code. I also have plenty of time to reflect why I didn’t catch on earlier. As the saying goes, “Hindsight is always 20/20″. All documentation over the MPEG format does not cover what to do in the case of ID3v2 tags. ID3v2 was added as meta data after MPEG became a standard, so it is no wonder why there isn’t any mention of it.

The answer was simple. If an MPEG audio file has the string “ID3″ as the first three characters in the file, then you just read the header to find out how large the ID3 tag is and skip past it. Once I did that, everything worked perfectly.

One benefit to solving this problem is that my code started to become optimized. I separated portions into smaller methods so that I could manage things easier and see the big picture. I even learned many ways to do the same thing. I’m still a little new to the PHP programming language, so this was a great exercise.

MP3 Playtime

Friday, November 25th, 2005

I’ve been at this problem for a while now. I’m trying to find out how many seconds are available in my MP3 files that I encode for my podcast. If I can find out how to get this information, then I can display that information along with other meta data on the web page that I’m building for it.

So far, I have figured out everything else under the sun. I am able to pull out ID3v1 and ID3v2 tags. I’m able to read header information such as the format, sample rate, bit rate, channels, CRC, copyright, padding, original, and more. From what I see, everything should work perfectly. From the bit rate and channels, I should be able to calculate the playtime based on the number of frames available.

The problem is that the files that I have don’t match the information that I am decoding. I’ve looked at the properties of my files through the file system, iTunes, and win amp. All three references report the same information, but my code seems to be off.

I’m scratching my head here. I’ve looked at samples from others and it appears that I’m doing roughly the same thing. I’ve reversed my bits in a vain attempt to make everything work. I decided to list out the bit masks of all of the MP3 headers in the file. What is odd is that some frames have different MPEG and Layer versions. I’ll be scratching my head for a while.

Uploading Stupid Videos

Sunday, November 20th, 2005

Angel watches many videos on Stupid Videos. The site seems to be very popular. For this reason, I was a little shocked when I received the following email:

I just tried uploading a video on stupidvideos.com

And it gave me this error message:

“Upload Without COM 3.0 error ‘8004000b’

Not enough free space available.[Need help? Contact Lewis Moten,
lewis@moten.com, http://www.lewismoten.com]

/include/clsField.asp, line 431″

It looks like the folks over at Stupid Videos ran out of disk space by the looks of this message.

I’ve uploaded many scripts over the years to an open-source community on the internet called Planet Source Code. The third generation of my upload files without COM script for ASP has been a contest winner and very popular. It brings a warm feeling in my heart to see that well known sites are picking up on the script as well.

Web services can be painful

Thursday, November 17th, 2005

Web services can be such a pain sometimes. Imagine this - someone gives you a WSDL file and says that you must build a client to interact with it. It sounds simple enough, because that is the whole purpose of a WSDL. You can simply emulate a web-service to test your client with and have them talk back and forth.

The problem came when I got hold of an existing client that interacts with that web service and pointed it over to my emulation of the web service. For an entire week I had been debugging my web service mucking around with name spaces, SOAP requests, SOAP headers, SOAP responses, XPath queries, XML serialization of objects, and just about everything else under the sun.

Dealing with existing web services are painful if you don’t have something to test them against. There are just too many unknowns. I don’t know what I would have done if I didn’t have an existing client to test out my emulated service. The easiest part was actually setting up the security using WSE to require certificates for authentication.

Using SOAP in Excel

Monday, October 17th, 2005

Ok, I feel like a million bucks rite now. A few weeks ago (or was it months?), I figured out how to use SOAP on web pages using JavaScript within both Microsoft Internet Explorer and Firefox. The use of communicating back and forth with a webserver and a web browser using XML and JavaScript is known as AJAX - Asychrounouse JavaScript and Xml. SOAP is another layer known as Simple Object Access Protocall written in XML and transferred through objects such as XmlHttp.

I figured out how to use SOAP with JavaScript a while back. This knowledge aided me to do the basics of communicating with my web services with Excel. This time I got the client working a bit better with how the message is formed and how I am able to parse data as it comes back. You got to love XML for making things easy on us programmers.

Anyhow, I had to scratch my head for a long time. From what I understand, SOAP is built into current versions of Microsoft Excel Applications. I don’t have that luxury so I had to make it backwards compatible. Think of it - most people have to worry about making web pages backwards compatible over multiple web browsers. I have to make macros backwards compatible with multiple versions of the Excel spreadsheet applications. Sheesh!

This is the best that I could come up with so far. I’ve tried to set it up as asynchronouse, but my version of Excel doesn’t support the GetRef method. The best that I could do was calling DoEvents.

    1 ‘ Variables that may help to identify the end-user
    2 ‘Debug.Print Environ(”USERNAME”)
    3 ‘Debug.Print Environ(”USERDOMAIN”)
    4 ‘Debug.Print Environ(”USERDNSDOMAIN”)
    5 ‘Debug.Print Environ(”COMPUTERNAME”)
    6 ‘Debug.Print Application.ProductCode
    7 
    8 Private WebClient As Object
    9 Private m_ActiveXPrefix As String
   10 Private m_ParameterNames() As String
   11 Private m_ParameterValues() As String
   12 Private m_MethodName As String
   13 Private m_XmlNamespace As String
   14 Private m_OnReadystateChange As String
   15 Private m_ParameterCount As Integer
   16 Private m_EndPoint As String
   17 
   18 Private Property Get ActiveXPrefix() As String
   19 If Not m_ActiveXPrefix = “” Then
   20 ActiveXPrefix = m_ActiveXPrefix
   21 Exit Property
   22 End If
   23 Dim Prefixes(4) As String
   24 Prefixes(0) = “Microsoft”
   25 Prefixes(1) = “MSXML”
   26 Prefixes(2) = “MSXML2″
   27 Prefixes(3) = “MSXML3″
   28 Dim test As Object
   29 On Error Resume Next
   30 For Each Prefix In Prefixes
   31 Set test = CreateObject(Prefix & “.XmlHttp”)
   32 If Not Err Then
   33 Set test = CreateObject(Prefix & “.XmlDom”)
   34 If Not Err Then
   35 m_ActiveXPrefix = Prefix
   36 ActiveXPrefix = Prefix
   37 Exit Property
   38 End If
   39 End If
   40 Err.Clear
   41 Next
   42 End Property
   43 
   44 Private Property Get ParameterIndex(name As String) As Integer
   45 For i = 0 To m_ParameterCount
   46 If m_ParameterNames(i) = name Then
   47 ParameterIndex = i
   48 Exit Property
   49 End If
   50 Next
   51 ParameterIndex = -1
   52 End Property
   53 
   54 Public Property Let Parameter(name As String, Value As String)
   55 Dim i As Integer
   56 i = ParameterIndex(name)
   57 If i = -1 Then
   58 AddParameter name, Value
   59 Else
   60 m_ParameterValues(i) = Value
   61 End If
   62 End Property
   63 
   64 Public Property Get Parameter(name As String) As String
   65 Dim i As Integer
   66 i = ParameterIndex(name)
   67 If i = -1 Then
   68 Parameter = “”
   69 Else
   70 Parameter = m_ParameterValues(i)
   71 End If
   72 End Property
   73 
   74 Public Sub AddParameter(name As String, Value As String)
   75 Dim i As Integer
   76 i = m_ParameterCount
   77 m_ParameterCount = m_ParameterCount + 1
   78 ReDim Preserve m_ParameterNames(m_ParameterCount)
   79 ReDim Preserve m_ParameterValues(m_ParameterCount)
   80 m_ParameterNames(i) = name
   81 m_ParameterValues(i) = Value
   82 End Sub
   83 
   84 Public Sub ClearParameters()
   85 ReDim m_ParameterNames(0)
   86 ReDim m_ParameterValues(0)
   87 m_ParameterCount = 0
   88 End Sub
   89 
   90 Public Property Get MethodName() As String
   91 MethodName = m_MethodName
   92 End Property
   93 
   94 Public Property Let MethodName(name As String)
   95 m_MethodName = name
   96 End Property
   97 
   98 Public Property Let XmlNamespace(uri As String)
   99 m_XmlNamespace = uri
  100 End Property
  101 
  102 Public Property Get XmlNamespace() As String
  103 XmlNamespace = m_XmlNamespace
  104 End Property
  105 
  106 Public Property Let OnReadystateChange(Method As String)
  107 m_OnReadystateChange = Method
  108 End Property
  109 
  110 Public Property Get OnReadystateChange() As String
  111 OnReadystateChange = m_OnReadystateChange
  112 End Property
  113 
  114 Public Property Get EndPoint() As String
  115 EndPoint = m_EndPoint
  116 End Property
  117 
  118 Public Property Let EndPoint(uri As String)
  119 m_EndPoint = uri
  120 End Property
  121 
  122 Public Function Query(Optional Asynch As Boolean = False) As Object
  123 Dim Envelope As Object
  124 Set Envelope = CreateEnvelope()
  125 WebClient.Open “POST”, Me.EndPoint, Asynch
  126 WebClient.setRequestHeader “SOAPAction”, “”"” & Me.XmlNamespace & Me.MethodName & “”"”
  127 WebClient.setRequestHeader “Content-Type”, “text/xml; charset=utf-8″
  128 WebClient.setRequestHeader “Content-Length”, CStr(Len(Envelope.xml))
  129 ‘Debug.Print Envelope.xml
  130 On Error GoTo ErrorTrap
  131 WebClient.send Envelope.xml
  132 On Error GoTo 0
  133 If Asynch Then
  134 While Not WebClient.readyState = 4
  135 DoEvents
  136 Wend
  137 End If
  138 ‘Debug.Print WebClient.ResponseText
  139 If Envelope.loadXML(WebClient.ResponseText) Then
  140 If Envelope.LastChild.FirstChild.FirstChild.nodeName = “soap:Fault” Then
  141 MsgBox “An error occured while communicating with the server.”
  142 Debug.Print Envelope.LastChild.FirstChild.FirstChild.FirstChild.nextSibling.text
  143 GoTo Reset
  144 End If
  145 Envelope.loadXML Envelope.LastChild.FirstChild.FirstChild.FirstChild.xml
  146 Set Query = Envelope
  147 End If
  148 GoTo Reset
  149 ErrorTrap:
  150 MsgBox Err.Description
  151 Reset:
  152 Me.ClearParameters
  153 End Function
  154 
  155 Private Function CreateEnvelope() As Object
  156 Dim Soap As Object
  157 Dim Envelope As Object
  158 Dim Body As Object
  159 Dim Method As Object
  160 Dim ParameterNode As Object
  161 Set Soap = CreateObject(ActiveXPrefix & “.XmlDom”)
  162 Soap.async = False
  163 Soap.appendChild (Soap.createProcessingInstruction(“xml”, “version=”"1.0″” encoding=”"utf-8″”"))
  164 Set Envelope = Soap.createElement(“soap:Envelope”)
  165 Envelope.setAttribute “xmlns:xsi”, “http://www.w3.org/2001/XMLSchema-instance”
  166 Envelope.setAttribute “xmlns:xsd”, “http://www.w3.org/2001/XMLSchema”
  167 Envelope.setAttribute “xmlns:soap”, “http://schemas.xmlsoap.org/soap/envelope/”
  168 Soap.appendChild Envelope
  169 Set Body = Soap.createElement(“soap:Body”)
  170 Envelope.appendChild Body
  171 Set Method = Soap.createElement(Me.MethodName)
  172 Body.appendChild Method
  173 Method.setAttribute “xmlns”, Me.XmlNamespace
  174 For i = 0 To m_ParameterCount - 1
  175 Set ParameterNode = Soap.createElement(m_ParameterNames(i))
  176 ParameterNode.text = m_ParameterValues(i)
  177 Method.appendChild ParameterNode
  178 Next
  179 Set CreateEnvelope = Soap
  180 End Function
  181 
  182 Private Sub Class_Initialize()
  183 Set WebClient = CreateObject(ActiveXPrefix & “.XmlHttp”)
  184 Me.ClearParameters
  185 End Sub
  186 
  187 Private Sub Class_Terminate()
  188 Set WebClient = Nothing
  189 End Sub

PHP and Dreamy Audio

Wednesday, October 12th, 2005

I’ve been working with my audio and video files from audioblogs. I’m mostly working on getting a script setup to list all files within the directory. This is simple enough, but I’m also trying to parse the meta data out of those files as well such as the title, comments, artist, play time, etcetra. You can temporarily see how far I have gotten so far over at my Dreamy Audio testing site. In the end, I’ll be able to simply upload a new MP3 file into the directory and everything else will be taken care of as long as I’ve properly edited the MP3’s meta data before doing so.

Most of the parsing is taken care of through an open-source library that I found on the internet. I’ll need to work on refining the RSS feed to sort in the same way. Next is to apply the same technique to my Flash Video files (FLV). I promised I would say something about that soon. I’ll try and get something posted before the end of the week.

For now, anyone playing with PHP and listing file sizes might find this small piece of code useful. It converts the bytes to KB, MB, GB, TB, or PB to make the file sizes more easier to read.

171 function calcBytes($bytes)
172 {
173 $unit = ‘bytes’;
174 while($bytes > 768)
175 {
176 switch($unit)
177 {
178 case ‘bytes’: $unit = ‘KB’;break;
179 case ‘KB’: $unit = ‘MB’;break;
180 case ‘MB’: $unit = ‘GB’;break;
181 case ‘GB’: $unit = ‘TB’;break;
182 case ‘TB’: $unit = ‘PB’;break;
183 default: continue 2;
184 }
185 $bytes = $bytes / 1024;
186 }
187 return round($bytes, 1).‘ ‘.$unit;
188 }