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

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

Moderator: Gurus

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

Postby Thanasis » Sun Jul 22, 2012 3:22 am

Hi people.

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

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

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

Postby trixmoto » Sun Jul 22, 2012 9:04 pm

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
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

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

Postby Thanasis » Mon Jul 23, 2012 2:31 am

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 !!!
Thanasis
 
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

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

Postby trixmoto » Mon Jul 23, 2012 7:25 am

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.
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

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

Postby Thanasis » Mon Jul 23, 2012 2:15 pm

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...
Thanasis
 
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

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

Postby trixmoto » Mon Jul 23, 2012 6:48 pm

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).
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

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

Postby Thanasis » Tue Jul 24, 2012 3:09 pm

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

Man I don't know how to thank you........
Thanasis
 
Posts: 84
Joined: Sun Aug 28, 2011 2:53 am

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

Postby trixmoto » Tue Jul 24, 2012 6:24 pm

No worries, always glad to help out a fellow scripter :)
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

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

Postby Thanasis » Wed Jul 25, 2012 11:17 am

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


Return to Addons developer forum

Who is online

Users browsing this forum: No registered users and 1 guest