[bug#8715] AutoPlaylists - Sort by Last Played

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

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: [bug#8715] AutoPlaylists - Sort by Last Played

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Thu Feb 09, 2012 3:59 am

It's a pleasure.

Can you keep an eye on this in the future. There are some other changes in the next release around this area and although my test environment now runs the Italian locale you're more likely to spot any regressional problems than I might.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by Silver » Thu Feb 02, 2012 6:08 am

Fixed. Thank you mark!

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Mon Jan 16, 2012 10:15 am

Build 2238 released to fix this.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Wed Jan 11, 2012 4:03 am

Ok, I've made some progress here. I manually set my decimal separator to ',' and the 1000s separator to '.'. Resultantly all sorts of exceptions popped out. The most obvious symptom was that the last played times were set to the date of last playing but time=00:00. This is what Silver reported - a secondary symptom was that the playlists were in the wrong order.

It would appear that MM wants the dates to ALWAYS have a '.' separator irrespective of it's locale or presentation settings. The new code looks like this.
Code: Select all
function MMdateToFloatStr(d:Tdatetime):WideString;
var
  s:string;
  diff:Tdatetime;
begin
  try
    diff:=d-datetime0;
    s:=QuotedStr(StringReplace(floatToStr(double(diff)),',','.',[]));
  except
    on e:exception do
    begin
      log.exception('MMdateToFloatStr',e);
      s:=QuotedStr('0.0');
    end;
  end;
  Result:=s;
end;

... and all seems well. I'm going to settle with this for now. So it will be in the next release.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Thu Jan 05, 2012 9:59 am

At startup the plugin code does a check to try and convert a '123.456' string to a float. If it works then it's going to use '.' as the separator. If it fails then it assumes it needs to be ','.
Code: Select all
  // see what localisation works
  decimalSymbol:='.';
  try
    f:=StrToFloat('123.456');
  except
    decimalSymbol:=',';
  end;
  log.text(2,'Decimal Symbol',decimalSymbol);

When reading from the DB a field such as LASTTIMEPLAYED is read as a string. Any occurrences of the wrong separator is converted to the right one. This makes the plugin tolerant to reading either type of separator.
Code: Select all
function replaceDecimalSymbol(s:WideString):WideString;
begin
  if decimalSymbol='.' then
    Result:=StringReplace(s,',','.',[])
  else
    Result:=StringReplace(s,'.',',',[]);
end;

Now, when the plugin writes to the DB the float is converted to a string by using MM's Localize function.
Code: Select all
function MMdateToFloatStr(d:Tdatetime):WideString;
var
  s:string;
  diff:Tdatetime;
begin
    diff:=d-datetime0;
    s:=QuotedStr(MMInterf.Localize(floatToStr(double(diff))));
    Result:=s;
end;

And I think that is where the fault lies. The reading is handled by my bespoke code whereas the writing is handled by the Localize function. The Localize function will use the display language and I'm using the locale.

In all cases that I know my users have the same display language as their locale (or the separators for the two are the same anyway). You have a mix of Italian and English which have difference separators.

As a test can you set your display language to Italian and see in the correct separator is written into the database?

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by Silver » Wed Dec 28, 2011 4:59 am

I'm currently using "Italian (Italy)" as the default locale in Windows.
I'm using English as display language for both Windows and MediaMonkey.
And yes, "," is the correct separator for the Italian locale.
The problem is that MM is actually using "." rather than "," for all values stored in the database. All values with a "," as a separator are displayed incorrectly.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Sat Dec 17, 2011 2:04 pm

So, please tell me what locale are you using and what is the separator used for decimals? The plugin will do a pre-check and it's determining that you use a ','. Is this incorrect?

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by Silver » Sat Dec 17, 2011 7:38 am

Song #99 is already correct, although with no decimal part it's displayed correctly in MM.
Incorrect songs are #1 to #12. Those songs were played on an iphone and synced back to MM.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Thu Dec 08, 2011 6:11 am

So, if you deliberately played (say) song #99 it would become corrected .... if this is true then I'd suggest that the plugin is working correctly. The code has been unchanged in my MM4 code since I branched to v4.

It should be possible to do a bit of SQL to remedy the comma separated entries. Unfortunately not my area of expertise.

If you're interested my code which converts a date into a string for the database is this .. (note the use of MMInterf.Localize)
Code: Select all
function MMdateToFloatStr(d:Tdatetime):WideString;
var
  s:string;
  diff:Tdatetime;
begin
  try
    diff:=d-datetime0;
    s:=QuotedStr(MMInterf.Localize(floatToStr(double(diff))));
  except
    on e:exception do
    begin
      log.exception('MMdateToFloatStr',e);
      s:=QuotedStr(MMInterf.Localize(dateTimeToStr(datetime0())));
    end;
  end;
  Result:=s;

end;

function MMfloatStrToDate(s:WideString):Tdatetime;
var
  f:double;
  d:Tdatetime;
begin
  try
    f:=StrToFloat(replaceDecimalSymbol(s));
    f:=f+double(datetime0);
    //dim dd : dd = datediff("s",cdate("1899 12 30" ),d )/86400
    d:=Tdatetime(f);
  except
    on e:exception do
    begin
      log.exception('MMfloatStrToDate',e);
      d:=datetime0();
    end;
  end;
  Result:=d;
end;

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by Silver » Wed Dec 07, 2011 1:54 pm

No, never changed my locale settings. :(
And yes, if I play the track in mediamonkey the date get changed to a correct value.

Here are the results using the SQL Viewer extension:
Code: Select all
SELECT SongTitle, LastTimePlayed FROM Songs ORDER BY LastTimePlayed DESC

Code: Select all
#    SONGTITLE                            LASTTIMEPLAYED
...
11   Stay Awake                           40860,6644444444
12   Deeply Disturbed (Infected Remix)    40853,9678819444
13   Cara catastrofe                      40884.77511235
14   When We Stand Together               40884.769127859
...
95   KARMA CHAMELEON                      40881.0
96   BORN IN THE U.S.A.                   40881.0
97   Never Let Me Down Again              40881.0
98   Raised On Rock                       40881.0
99   T.N.T.                               40881.0
...

Song #13 was played a while ago with MM and has the correct value.
I notice there are also many songs with a null decimal part, it's surely an incorrect value 'cause it's practically impossible playing nearly 20 tracks at the same time! :)

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Tue Dec 06, 2011 2:58 am

@Silver

From what I can see on your post there seems to be erroneous last played dates in the database. Dates are stored as a floating point number in the db. Numbers are stored with a ',' or '.' separator according to the locale set on the machine. I spent alot of time getting this right for various european users.

My suspicion is that you've changed locale at some point. Is this true?

If you play the track in question does the date get corrected? It should.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by nohitter151 » Thu Dec 01, 2011 12:39 pm

markstuartwalker wrote:Only an email point at http://www.ventismedia.com/mantis/view.php?id=8715

This part of the code is probably over 12 months old and I've have no other users reporting this problem so this is a very isolated case. Has it been demonstrated that the problem is repeatable? I've seen a screen shot showing data that I don't understand but nothing more.

I suggest somebody PMs me so we can look at this issue.

You'd have to ask the user in question. Supposedly the issue only occurs on systems where the windows regional settings have been changed to languages where , is used as a decimal separator.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Thu Dec 01, 2011 11:33 am

Only an email point at http://www.ventismedia.com/mantis/view.php?id=8715

This part of the code is probably over 12 months old and I've have no other users reporting this problem so this is a very isolated case. Has it been demonstrated that the problem is repeatable? I've seen a screen shot showing data that I don't understand but nothing more.

I suggest somebody PMs me so we can look at this issue.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by nohitter151 » Wed Nov 30, 2011 3:45 pm

markstuartwalker wrote:Did anything happen about this? I heard nothing more.

In the ticket Jiri said he contacted you since it couldn't be resolved on their end.

Re: [bug#8715] AutoPlaylists - Sort by Last Played

Post by markstuartwalker » Wed Nov 30, 2011 10:37 am

Did anything happen about this? I heard nothing more.

Top