View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011085 | MMW v4 | Framework: Scripts/Extensions | public | 2013-07-21 09:48 | 2013-09-03 12:03 |
Reporter | zvezdan | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Summary | 0011085: IsntInDB always returns False, SongID and ID always return -1 for files in My Computer | ||||
Description | I know this is old stuff, since MM2, and maybe it would break many compatibilities in existing scripts if you change their behavior. However, I really don't understand why we have some property named IsntInDB which always returns the same False value, not matter if file is in DB or not. I tried even this: Dim oSongData Set oSongData = SDB.NewSongData oSongData.Path = "c:\blahblah.mp3" MsgBox oSongData.IsntInDB and I got the same False value, even when "c:\blahblah.mp3" doesn't exist. What is the point of such property then? SongID and ID properties are somewhat better, even if they return -1 for all files from My Computer, not matter if some belong to DB or not, but I suppose it would be time consuming to check DB existence for each file using some SQL filtering, so maybe it is better to leave that test to scripters. However, I am wondering why we have two properties that always return the same value, i.e. SongsID is equal to ID for each file that I tried. It is confusing and your Wiki description doesn't clarify that. | ||||
Tags | No tags attached. | ||||
Fixed in build | |||||
|
It is strange enough that SongID and ID properties return the real ID value for tracks that are already entered to the Library even when the tracklist displays some node from My Computer if you read them in the OnPlay event handler. Here is my (shortest) script, "Add to Library on Play", slightly modified: Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub OnStartup() Script.RegisterEvent SDB, "OnPlay", "OnPlay" End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub OnPlay() Dim oSongData Set oSongData = SDB.SelectedSongList.Item(0) ' Set oSongData = SDB.Player.CurrentSong If oSongData Is Nothing Then Exit Sub SDB.MessageBox oSongData.ID & vbCr & oSongData.SongID, _ mtInformation, Array(mbOK) If oSongData.IsntInDB Or oSongData.SongID = -1 Then oSongData.UpdateDB End If End Sub Steps to reproduce: - select some node from My Computer; - select some track in tracklist that is previously entered to the Library; - choose Play Now -> you will get the message telling the actual track ID. However, if you try this code: Option Explicit Sub OnStartUp Dim oMenuItem SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_NP, 1, 1 Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP, 1, 1) oMenuItem.IconIndex = 37 oMenuItem.Caption = "Add to the Library" oMenuItem.Enabled = True oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "AddToLibrary" SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_TrackList, 1, 1 Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList, 1, 1) oMenuItem.IconIndex = 37 oMenuItem.Caption = "Add to the Library" oMenuItem.Enabled = True oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "AddToLibrary" End Sub Sub AddToLibrary(oMenu) Dim oSonglist Dim oSongData Dim i Set oSonglist = SDB.SelectedSongList For i = 0 to oSonglist.Count-1 Set oSongData = oSonglist.Item(i) SDB.MessageBox oSongData.ID & vbCr & oSongData.SongID, _ mtInformation, Array(mbOK) If oSongData.IsntInDB Or oSongData.SongID = -1 Then oSongData.UpdateDB End If Next End Sub then with the next steps: - select some node from My Computer; - select some track that is previously entered to the Library; - choose Add to Library from popup menu -> you would get -1 for ID. By the way, IsntInDB is always False, in both cases. |