.vbs to Add a File into NowPlaying List (from Path)

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

.vbs to Add a File into NowPlaying List (from Path)

Post by Thanasis »

Hi people.

I am looking for a .vbs command that adds a Path/File.mp3 into the Now Playing List.

Thank you
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by trixmoto »

You have a few options, depending on what exactly it is that you're trying to do...

- SDB.Player.PlaylistAddTrack(objSongData)
- SDB.Player.PlaylistAddTracks(objSongList)
- SDB.Player.PlaylistInsertTrack(objSongData)
- SDB.Player.PlaylistInsertTracks(objSongList)

... all of which are documented on the wiki in SDB.Player
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by Thanasis »

Thank you very much trixmoto, BUT

the big question is how I get that objSongData object from a path like e.g. "c:\folder\myfile.mp3" .....

Thanks in advance !!!
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by trixmoto »

Ah right, I see. Well in that case I'd recommend SDB.Database.QuerySongs, something like...

Code: Select all

Dim path : path = "c:\folder\myfile.mp3"
Dim iter : Set iter = SDB.Database.QuerySongs("SongPath='"&Mid(path,2)&"'")
If Not iter.EOF Then
  SDB.Player.PlaylistAddTrack(iter.Item)
End If
Notice that I have excluded the drive letter, this is because MM holds this in a separate table. If you need to ensure the drive letter is correct as well then the sql segment will need to be amended to link to the Medias table, which complicates things a little.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by Thanasis »

Thank you trixmoto but what about if file is not scanned in database? Just like when you drag it from the explorer to now playing list......but programmatically,,,

Thanks for your time...
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by trixmoto »

Ok, in that case you need to create an entry in the database, so that you can add it to the now playing list, something like this...

Code: Select all

Dim itm : Set itm = SDB.NewSongData
itm.Path = "c:\folder\myfile.mp3"
itm.ReadTags
itm.UpdateDB
If itm.Title = "" Then
  itm.MetadataFromFilename
  itm.UpdateDB            
End If
itm.UpdateArtist
itm.UpdateAlbum
SDB.Player.PlaylistAddTrack(itm)
This first tries to get the metadata from the tags stored in the file (using ReadTags) and then if that fails, it tries to get it from the filename itself (using MetadataFromFilename).
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by Thanasis »

Thanks very much !!!! You spent so much time for me ?

Man I don't know how to thank you........
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by trixmoto »

No worries, always glad to help out a fellow scripter :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Thanasis
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

Re: .vbs to Add a File into NowPlaying List (from Path)

Post by Thanasis »

:D
Post Reply