Search This Blog

Wednesday, November 12, 2014

Dipping a Toe into a New Adventure Pool

I've increasingly become interested in programming. No, I don't want to sit and write code for software all day, but writing code for doing what I want to do automatically has increased its appeal. For example, I started out being interested in finding a way to find out if I'm missing songs in the CD reconversion. The first thing I thought about is finding a way to flag a directory if I have files like this:


where I'm missing 02_MP3_File.mp3. I talked to my friend Chris about it and he brought up some logical points regarding how - we referred to it as "the thing" - the thing would know how many songs should be there. I had started with the idea that the thing would count down from 99 through 0 and if it found a missing number, it would spit out the directory into a log file of some sort.

Eventually that evolved into a way to extract the Windows Media Player (WMP) database into an Excel file. There is supposed to be a way to do so, using a Microsoft "Winter Fun" package from 2003, but in order to install it on Windows 7, which I have on my work laptop as well as at home, you have to delete a specific folder in a specific path. I haven't been successful in being able to do that on either device.

The other day, I sent this email to Chris:

Is there a way to take this code and bring over ‘all’ of the columns that are in a WMP database?

I got the original code here & tried to do it, but I’m lost.
Set objPlayer = CreateObject("WMPlayer.OCX" )

Set objMediaCollection = objPlayer.MediaCollection
Set colSongList = objMediaCollection.getByAttribute("MediaType", "Audio")

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)

objWorksheet.Cells(1,1) = "Track Number"
objWorksheet.Cells(1,2) = "Title"
objWorksheet.Cells(1,3) = "Artist"
objWorksheet.Cells(1,4) = "Album"
objWorksheet.Cells(1,5) = "Length"
objWorksheet.Cells(1,6) = "Genre"
objWorksheet.Cells(1,7) = "Times Played"
objWorksheet.Cells(1,8) = "Contributing Artist"

j = 2

For i = 0 to colSongList.Count - 1
Set objSong = colSongList.Item(i)
objWorksheet.Cells(j,1) = objSong.getItemInfo("WM/TrackNumber")
objWorksheet.Cells(j,2) = objSong.getItemInfo("Name")
objWorksheet.Cells(j,3) = objSong.getItemInfo("WM/AlbumArtist")
objWorksheet.Cells(j,4) = objSong.getItemInfo("WM/AlbumTitle")
objWorksheet.Cells(j,5) = objSong.durationString
objWorksheet.Cells(j,6) = objSong.getItemInfo("Genre")
objWorksheet.Cells(j,7) = objSong.getItemInfo("UserPlayCount")
objWorksheet.Cells(j,8) = objSong.getItemInfo("WM/ContributingArtist")

j = j + 1

Set objRange = objWorksheet.UsedRange

And he just wrote back this:

Yeah, the manual of how is here:

So you would first call getAttributeCount() to get the count, then pass the numbers in to the function that tells you the names, then use those names to fill in the lines you have below such as objSong.getItemInfo("Name”) where “Name” would be replaced with the names you got back from the function.

Hopefully that makes sense.

It's 6:30 AM and my Mountain Dew is just beginning to hit my system. It doesn't make sense yet!

No comments:

Game Show