BUG(?): Playlist.AddTracks crashes

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

e-r-n-i-e
Posts: 3
Joined: Tue Oct 12, 2004 2:30 am
Location: Germany

BUG(?): Playlist.AddTracks crashes

Post by e-r-n-i-e »

I'm totally new to VB-Script, so I'm posting this bug(?) here first:

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
(Copy this script to MediaMonkey\Scripts\Auto)

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
followed by:
  • Varient or safe array is locked
Is this a (known) bug or what? Any ideas?

Thanks for any help!
e-r-n-i-e
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Is this a (known) bug...?
Probably. I think it's the same bug I have been breaking my head on with the TweakMonkey script (creates Access Violations using AddTrack and AddTracks when it shuts down...). Hopefully it's fixed in MM3. Maybe you can try an MM3 alpha version to see if it works there.
(I can do the same, but it's 1:41 now... a bit too late/early in the morning to try... I'm going to bed instead)
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

I think you're trying to copy songs before MM has actually created objects from them. Your best bet is probably to set this off with a timer that delays for about 5 secs, that way MM's got some time to get itself sorted before you try to copy anything. Make sense?
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.
jiri
Posts: 5419
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

I can confirm the bug, it will be fixed in the next MM 3.0 release. Also its description was added to Wiki.

Thanks,
Jiri
Post Reply