PlayList.RemoveTrackNoConfirmation behavior?

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

Moderators: Gurus, Addon Administrators

Just Guessing
Posts: 64
Joined: Mon Sep 03, 2012 12:06 pm

PlayList.RemoveTrackNoConfirmation behavior?

Post by Just Guessing »

I have a playlist ("Test Playlist") and I want to remove a track (objSong) from it.

Experimenting with "RemoveTrackNoConfirmation" I find this will NOT work (unless certain challenging conditions are true):

Code: Select all

SDB.PlaylistByTitle("Test Playlist").RemoveTrackNoConfirmation objSong
it seems the argument for the method MUST be a playlist item, referenced as such. For example, this works:

Code: Select all

SDB.PlaylistByTitle("Test Playlist").RemoveTrackNoConfirmation  SDB.PlaylistByTitle("Test Playlist").Tracks.Item(0)
In fact, THIS WORKS (but removing track from the "Test Playlist" playlist only !!):

Code: Select all

SDB.PlaylistByTitle("A Completely Different Playlist").RemoveTrackNoConfirmation  SDB.PlaylistByTitle("Test Playlist").Tracks.Item(0)
Alright, a work around possibility (which will need a bunch of error avoidance code):

Code: Select all

for I = 0 To SDB.PlaylistByTitle("Test Playlist").Tracks.count - 1
	if objSong.ID = SDB.PlaylistByTitle("Test Playlist").Tracks.Item(i).ID Then match = i
next

SDB.PlaylistByTitle("Test Playlist").RemoveTrackNoConfirmation SDB.PlaylistByTitle("Test Playlist").Tracks.Item(match)
But... Am I missing something? This seems like very limited and/or buggy behavior.
Just Guessing
Posts: 64
Joined: Mon Sep 03, 2012 12:06 pm

Re: PlayList.RemoveTrackNoConfirmation behavior?

Post by Just Guessing »

well, came up with a sub one can use, in case the SDB method behavior isn't as friendly as it could be (if this is needed)

so I'd use this:
PlaylistTrackRemove "Test Playlist", objSong

to call this:

Code: Select all

sub PlaylistTrackRemove(PlaylistName, SongObject)
	Dim i, ThePlaylist, TrackCount
	Set ThePlaylist = SDB.PlaylistByTitle(PlaylistName)
	TrackCount = ThePlaylist.Tracks.Count
	
	if ThePlaylist.id > 0 And Not SongObject Is Nothing Then
		if TrackCount > 0 Then
			for i = TrackCount - 1 To 0 Step -1
				if SongObject.ID = ThePlaylist.Tracks.Item(i).ID Then 
					ThePlaylist.RemoveTrackNoConfirmation ThePlaylist.Tracks.Item(i)
				end if
			next
		end if
	end if
		
	SDB.MainTracksWindow.Refresh	
	Set ThePlaylist = Nothing
end sub
Peke
Posts: 17446
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: PlayList.RemoveTrackNoConfirmation behavior?

Post by Peke »

If I got you correctly you want to remove track by ID which is position in playlist?

I would suggest something like this:

Code: Select all

    sub PlaylistTrackRemove(PlaylistName, SongObject)
       Dim ThePlaylist, TrackCount
       Set ThePlaylist = SDB.PlaylistByTitle(PlaylistName).Tracks
       ThePlaylist.Delete(SongObject)
       ThePlaylist.UpdateAll
       SDB.MainTracksWindow.Refresh   
       Set ThePlaylist = Nothing
    end sub
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Just Guessing
Posts: 64
Joined: Mon Sep 03, 2012 12:06 pm

Re: PlayList.RemoveTrackNoConfirmation behavior?

Post by Just Guessing »

I get a type mismatch with that, unless I use "SongObject.ID".
But even though SongObject.ID gets no error, I don't find the track removed from the playlist.

example:
I want SDB.SelectedSongList.Item(0)
removed from playlist "Testing"

SDB.PlaylistByTitle("Testing").Tracks.Delete(SDB.SelectedSongList.Item(0).ID)

doesn't give error, but doesn't remove track from playlist... Nor does

SDB.PlaylistByTitle("Testing").RemoveTrackNoConfirmation( SDB.SelectedSongList.Item(0) )
Post Reply