The following script copies the tracks currently on the "Now Playing"-List to a newly created playlist. I found 3 different ways to do this, but the 2 most obvious and fastest ways (using AddTracks) always crashes.
Code: Select all
Option Explicit
' Creates a "Recycle"-button in the Standard-Toolbar
Sub OnStartup
Dim Mix_Menu
Set Mix_Menu=SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard, 0, 1)
Mix_Menu.Caption=SDB.Localize("Mix Playlists")
Mix_Menu.IconIndex=6
Mix_Menu.UseScript=Script.ScriptPath
Mix_Menu.OnClickFunc="MixPlaylists"
End Sub
Sub MixPlaylists(o)
Dim Playlist, SongList, choice, i
Set Playlist = SDB.PlaylistByTitle("").CreateChildPlaylist("__test__")
Playlist.Clear
If SDB.Player.CurrentSongList.Count < 1 Then
choice= SDB.MessageBox("ERROR: Playlist 'Now Playing' is empty!", mtError, Array(mbOk))
Exit Sub
End If
choice= SDB.MessageBox(_
"(1) YES = Add track by track" & vbNewLine &_
"(2) NO = Add all tracks at once (CRASHES immediately)" & vbNewLine &_
"(3) CANCEL = Add all tracks at once (CRASHES at the end, MM needs to be restarted!)" _
, mtCustom, Array(mbYes, mbNo, mbCancel))
Select Case choice
Case mrYes
' (1) This works fine
For i = 0 to SDB.Player.CurrentSongList.Count-1
Playlist.AddTrack(SDB.Player.CurrentSongList.item(i))
Next
Case mrNo
' (2) Tracks are copied but will crash immediately
Playlist.AddTracks(SDB.Player.CurrentSongList)
Case mrCancel
' (3) Tracks are copied but will cause a crash at THE END of the script
' After this EVERY Script crashes, MM needs to be restartet
Set SongList = SDB.Player.CurrentSongList
Playlist.AddTracks(SongList)
End Select
choice= SDB.MessageBox("Everything's fine... (or seems to be)", mtInformation, Array(mbOk))
End Sub
When choosing (2) or (3) I always get errors like:
- Error happened during script execution:
Access violation at address xxx. Read of Address xxx - Error happened during script execution:
Access violation at address xxx in module 'MediaMonkey.exe'. Write of Address yyy - Error happened during script execution:
Privileged instruction - Error happened during script execution:
Access violation at address xxx in module 'MediaMonkey.exe'. Read of Address yyy
- Varient or safe array is locked
Thanks for any help!
e-r-n-i-e