INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: fieldnames from a textstring  (Read 1437 times)

Robert S

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 80
fieldnames from a textstring
« on: August 19, 2004, 09:40:56 am »

Sorrry if this seems confusing, it's partly because my english has seen better days. :-)

I'm writing a program that displays information from Media Center about songs in the playlist.

The information that will be displayed is written in a textstring that looks like this

"[Name][Album][Artist]" or "[Bitrate][Album]" etc etc.

I want it to be possible to show all field-information from MediaCenter, and the user must be able to shoose from all fields in any order he/she wants.

That part that searches for [] and get the fieldnames from the users textstring is easy. I don't need help with that. Its how to use the selected fields in the textstring to tell mediacenter to display just that field  that I ask about.

I've figured out a way to solve this, but I think there should be a better way. This is how I solved it:

Private Function ReturnInfo(sField As String) As String
    Select Case sField
        Case "AlbumArtist"
            ReturnInfo = playNow.GetFile(playNow.Position).AlbumArtist
        Case "Bitrate"
            ReturnInfo = playNow.GetFile(playNow.Position).Bitrate
        Case "Comment"
            ReturnInfo = playNow.GetFile(playNow.Position).Comment
        Case "Custom1"
            ReturnInfo = playNow.GetFile(playNow.Position).Custom1
        Case "Name"
            ReturnInfo = playNow.GetFile(playNow.Position).Name
        Case "Artist"
            ReturnInfo = playNow.GetFile(playNow.Position).Artist
        Case "Album"
            ReturnInfo = playNow.GetFile(playNow.Position).Album
        ..
        ..
        Case else
            'Not a valid field...
            ReturnInfo = ""        
    End Select
End Function

This list will be long if I include all fields from the playlist so did som cutting in the code there.

Anyone? I've seen one plugin that has a function like this, I think it was the plugin that wirtes information like this to a textfile on the disc. But they didn't release their code. I'd prefere an better solution in vb6, but any solution in any language would be great.

Thanks

Robert
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
Re:fieldnames from a textstring
« Reply #1 on: August 23, 2004, 03:01:51 am »

Try something like:

playNow.GetFile(playNow.Position).Get(sField,TRUE)


Here's what the documentation says about Get:

string Get(string strField, boolean bFormatted)

Description: generic function to get value for the specified field.
Parameters:

strField: name of the field (e.g. Artist, Album...)
bFormatted: determines whether the return value should be formated.


Return Value: value of the field

Logged

Robert S

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 80
Re:fieldnames from a textstring
« Reply #2 on: September 29, 2004, 04:42:43 am »

It's been a while and I had not time to test this up until today.

Thank you it works great. Easy does it!

/Robert

Logged
Pages: [1]   Go Up