PlayList.RemoveTrackNoConfirmation behavior?

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: PlayList.RemoveTrackNoConfirmation behavior?

Re: PlayList.RemoveTrackNoConfirmation behavior?

by Just Guessing » Thu Sep 22, 2016 5:27 pm

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) )

Re: PlayList.RemoveTrackNoConfirmation behavior?

by Peke » Wed Sep 21, 2016 9:12 pm

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

Re: PlayList.RemoveTrackNoConfirmation behavior?

by Just Guessing » Tue Sep 20, 2016 3:13 pm

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

PlayList.RemoveTrackNoConfirmation behavior?

by Just Guessing » Tue Sep 20, 2016 9:33 am

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.

Top