"Item.SongID > -1" isn't the same as "Not

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

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

Topic review
   

Expand view Topic review: "Item.SongID > -1" isn't the same as "Not

by jiri » Fri Mar 10, 2006 9:19 am

Let me try to give you an example:

1. You add a track to Now Playing with SongID=-1, IsntInDB=false, Path=C:\music\x.mp3
2. MM starts a thread and so _later_ it finds out whether this track is in DB:
2a. Track is in DB => SongID=n (n>0), IsntInDB=false
2b. Track isn't in DB => SongID=-1, IsntInDB=true

In other words:
IsntInDB = true: We are sure that this track isn't stored in Library, i.e. we have already made an SQL query and it wasn't there.
IsntInDB = false: If SongID>0 then track is clearly in Library, if SongID=-1 then we don't know anything yet.

I can also add that device plug-ins use this property to Set (i.e. they don't read it) that a track isn't in library and thus make MM operations faster - MM doesn't need to execute a SQL query about such a track.

Jiri

by Steegy » Fri Mar 10, 2006 7:39 am

Ok, but the track that I add to the playlist is an external track (added using a new SongData object and filled the path, artist and title), that is not in the library/database. So shouldn't the 'IsntInDB' property be true then?

Adding external tracks to the Now Playing list (by drag&drop) sets the IsntInDB property to true.
However, if I add them through code (new SongData, without using UpdateDB or so), then the IsntInDB property is not true.

There are no songs with ID = -1 (or without ID) in my Songs table, and I haven't found any occurence of these external tracks in the library.

BTW: This is about the "SaveAndRestoreNowPlaying" script, that I pm'ed you about some time ago.
SongID can be -1 even if track is in database, but MM doesn't know about it yet.
When would this be then?

Anyway, that part of the code works now, but it can be useful to fully understand why this behaviour of MM is happening.

Thanks
Steegy

by jiri » Fri Mar 10, 2006 6:56 am

No, 'IsntInDB' is true only if MM checked Path of track and found that it isnt' in database. SongID can be -1 even if track is in database, but MM doesn't know about it yet.

Jiri

"Item.SongID > -1" isn't the same as "Not

by Steegy » Fri Mar 10, 2006 6:10 am

Hello

I had a scripting problem and I didn't understand why it wasn't working. After testing several things, I saw that when adding a new SongData to the Player's playlist (using SDB.NewSongData, without adding to the library) for an external audio file, the SongID is -1 as it should be, but IsntInDB is wrong (either false, or some similar value, definitely not true).

When I change "Not Item.IsntInDB" by "Item.SongID > -1", it works fine.
Normally these 2 things should be identical, no?

Cheers
Steegy

Top