INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: GroupSummary Function: Last Played  (Read 1279 times)

tom9920

  • Recent member
  • *
  • Posts: 28
GroupSummary Function: Last Played
« on: June 04, 2020, 08:40:30 am »

Does the GroupSummary function operate correctly on the "Last Played" field?  It appears to return the value of the last file in the list rather than the average date for all files.

The reason for my question is that I was trying to replace a feature in MC21, which shows the average elapsed time since last played for all files in a group at the top of the tag pane.  So if there is a way to get there without trying to group on the "last played" field, using the "elapsed" date format, that would also be helpful.

Thanks!
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42382
  • Shoes gone again!
Re: GroupSummary Function: Last Played
« Reply #1 on: June 04, 2020, 09:16:31 am »

It should show the date for the last played file in the set.
Logged
Matt Ashland, JRiver Media Center

tom9920

  • Recent member
  • *
  • Posts: 28
Re: GroupSummary Function: Last Played
« Reply #2 on: June 05, 2020, 07:16:03 am »

Got it.  So in this case the value returned by the GroupSummary function is that of one of the members of the group. 

Is it possible to calculate the average elapsed time for a group of files using some other expression?

I tried, for example, starting with a math expression Now() - [Last played] (thinking I could then sum the values and divide by the count) but also did not get expected results .  Thanks in advance for any additional help.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: GroupSummary Function: Last Played
« Reply #3 on: June 05, 2020, 07:31:36 pm »

You have to use the raw data form of the [Last played] field to do that calculation, and you have to use the Math function. So;

Math(Now()-[Last played, 0])

There was recently some similar discussion happening over here: https://yabb.jriver.com/interact/index.php/topic,119385.msg870200.html#msg870200

I'm sure you've read this: https://wiki.jriver.com/index.php/Expression_Language

Search that page for "Raw" to find a description of using the raw data form. Important for data manipulations.


The reason for my question is that I was trying to replace a feature in MC21, which shows the average elapsed time since last played for all files in a group at the top of the tag pane.  So if there is a way to get there without trying to group on the "last played" field, using the "elapsed" date format, that would also be helpful.

Do you still have MC21 working?
Can you post a screenshot of what you used to have?
Is that functionality provided by an Expression or default functionality in MC?
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

tom9920

  • Recent member
  • *
  • Posts: 28
Re: GroupSummary Function: Last Played
« Reply #4 on: June 06, 2020, 09:36:26 am »

Attached (I hope) is a screenshot from MC21.

I started with the formula in your last reply, but then ran into issues with GroupSummary.  I will go back to that as a starting point and try to make progress without trying to use GroupSummary as a shortcut. I'll let you know if I succeed.

Logged

tom9920

  • Recent member
  • *
  • Posts: 28
Re: GroupSummary Function: Last Played
« Reply #5 on: June 06, 2020, 02:25:17 pm »

Here's a further update.

I have a screenshot showing three values:

Last Played = [Last Played]
Last Played (Elapsed) = FormatDate([Last Played,0],Elapsed)
Last Played (Calc) = Math((Now()-[Last played, 0])/365)

So the calculation works for a single track.  So far so good. 

But we need a sum in order to calculate the average for multiple tracks.  As we discussed in a previous post, GroupSummary doesn't work, but I don't see an alternative approach.

Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: GroupSummary Function: Last Played
« Reply #6 on: June 06, 2020, 09:34:21 pm »

TL;DR
The GroupSummary() function only takes two parameters. The field name, and a Mode of 0 or 1. Mode 0 is a formatted output and shows "avg", "total" etc as part of the output. Mode 1 just outputs the number. It can't take expressions as a parameter.
Create a calculated field that doesn't have a bracket ")" at the end of the name. GroupSummary() can't handle the trailing bracket. I used the field name [LPEcalc].
Give this new calculated field the expression "Math(Now()-[Last played, 0])&datatype=[number]".
Create an Expression Column in an Album View with the expression "GroupSummary(LPEcalc)" as a test. It should give you a formatted average time since [Last Played] for all selected files, taking into account only those files that have a value in [Last Played]. For example, the output might be "223.68 avg".
As you want to see this in the Tag Window, add an Expression item to the Tag Window, name it something like "Avg days since play", and give it the expression of "GroupSummary(LPEcalc)".

Done. See image for what I built.

PS: If you want to show the same data in an Expression Column in a View, but want MC to show the average time since played independently for each Album, use the expression "GroupSummaryQuery(Album,LPEcalc)".

======================================================


Ah yes, I had forgotten about that nice little summary at the top of the old Tag window.

The good news is that you can still use that version of the Tag window. Just hold the Shift key when you click "Tag" in the Action Window. That will toggle use to the old version of the window, and MC will keep using that until you Shift+Click again.

The bad news is that the old Tag window will probably go away at some stage, and may not be updated as time goes on. In fact, I don't think it has had any updates for some time.

Let's just look at the components of that information.

1. "1:17:26 total" is just the [Duration] field.
2. "333 MB total" is just the [File Size] field.
3. "70 plays total" is just the [Number Plays] field.
4. "207.5 days ago" is just "Math(trunc(Now()-[Last played, 0], 1)) days ago".

But all the above have had the MC magic of summarisation to a total because a group of files is selected. This magic of summarisation is not available for fields shown in the Tag window. MC will just show [Varies] there when multiple files are selected.

The equivalents using GroupSummary are.

1. GroupSummary(Duration)
2. GroupSummary(File Size)
3. GroupSummary(Number Plays)
4... So finally to your actual question. I've been playing with these functions and documenting as a went, so forgive the unnecessary discussion.  ;D

GroupSummary takes a field name as its only parameter. As in the above cases, the field names need to be "bare", with no [] brackets around them. It looks like you have created a new calculated field called "Last Played (Elapsed)" using the expression "FormatDate([Last Played,0],Elapsed)", which would mean that when used in GroupSummary the expression would be;
GroupSummary(Last Played (elapsed))

But that isn't going to work, as GroupSummary doesn't handle the field name ending with a ")" bracket.
Renaming the field to "Last Played elapsed" and using the expression GroupSummary(Last Played elapsed) doesn't work either, as it just results in the output of [Varies]. Not helpful. It isn't the spaces in the field names that is the issue either. Using a field named [LPE] and the expression GroupSummary(LPE) also gives the output of [Varies].

So it looks like maybe the GroupSummary function doesn't like using a custom field. But maybe it is the expression being used. Nope. Changing the expression to explicitly calculate the time since the files were last played using the expression "Math(Now()-[Last played, 0])" rather than the formatting in the expression "FormatDate([Last Played,0],Elapsed)" still gives an output of [Varies].

However, changing the field [LPE] so that it is no longer a calculated field, and then just setting its value to "=Math(Now()-[Last played, 0])" by editing the field, makes the expression GroupSummary(LPE) work correctly, outputting the average number of days since any tracks that have a value in [Last Played] have been played. The output was in the format "223.5 avg". Note that the LPE field must be a Decimal or Integer field for this to work. This is a big hint.

So an idea formed. I created a calculated field called [LPEcalc] and gave it the expression "Math(Now()-[Last played, 0])", then changed the [LPE] field to just expression to just "=[LPE]" and "=[LPE, 0], trying to get it to just copy across the value of LPEcalc. But GroupSummary(LPE) still gave the result of [Varies]. I also tried all of the above using GroupSummaryQuery(Album, LPE), with the same results as GroupSummary(LPE).  :(

But then, success! As documented at the top of this post.  :)
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: GroupSummary Function: Last Played
« Reply #7 on: June 06, 2020, 09:35:39 pm »

PPS: You will notice in the image above, the same treatment can be given to the Thumbnail text, if you wish. I was just testing there.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner
Pages: [1]   Go Up