More > JRiver Media Center 21 for Windows

How To: Build A Custom Watched Field for Media Center

(1/8) > >>

glynor:
This tutorial will show you how I build my custom [Watched Percent] field, which I use throughout Media Center for display of Watched/Not-Watched Status.  It displays it using a combination of checkmarks (for fully watched files) and percentages watched, using custom percentage ranges.  Now that we can easily change [Number Plays] (as of MC 19.0.90), it is easy to reset this special Watched status indicator, by simply clearing [Number Plays].

For a discussion of why this logic was used, and how it was built, see this thread:
http://yabb.jriver.com/interact/index.php?topic=85906.0

It requires two custom fields: [Bookmark Percent] and [Watched Percent].  They're configured like so:

[Bookmark Percent]

This outputs a numeric percentage for any file indicating the percentage "complete" it was last played.  Interestingly, this works even for files that don't use automatic bookmarking (Music, for example).  The bookmark is ignored, but MC tracks it.

Expression:

--- Code: ---PadNumber(Math(round(([Bookmark] / ([Duration, 0] * 1000)) * 100)),2)
--- End code ---



You can use whatever you'd like in the Display fields when setting it up.  That's what it will be called if you add it as a column, or to Theater View directly.  This is mostly for utility, so it doesn't much matter if you won't use it in a column.

[Watched Percent]

Outputs either a checkmark, blank, or the percentage watched, depending on the status of [Number Plays] and [Bookmark Percent].

If [Bookmark Percent] is between 10 and 89%, then it outputs the percentage (formatted like "76%").
If [Bookmark Percent] is 90% or more, then it outputs a checkmark.
If [Bookmark Percent] is less than 10%, then
   If [Number Plays] is zero, it outputs nothing at all (null text).
   If [Number Plays] is greater than zero, it outputs a checkmark.

The last check is because when file has played all the way through, MC will reset the [Bookmark] to zero, and "automatically reset" the bookmark.  We still want to mark these as Watched.

Expression:

--- Code: ---If(IsRange([Bookmark Percent], 0-9),
If(Compare([Number Plays],<,1),,✔),
If(IsRange([Bookmark Percent], 10-89),[Bookmark Percent]%, ✔))
--- End code ---



There is one other, optional, custom calculated field you can make that I also use and find handy.  This isn't required or used by the [Watched Percent] expression, but I think it compliments it well.

[Plays]

Outputs a nicely formatted version of [Number Plays], including text about the [Last Played] date.

If the file was never played, it outputs "never played'.
If [Last Played] was greater than 1 year ago, then it outputs in the form: [Number Plays] (last [Last Played - Year Only])
If [Last Played] was less than 1 year ago, then it outputs in the form: [Number Plays] (last [Last Played - Short Date])

Expression:

--- Code: ---if(isEmpty([Number Plays]), never played, [Number Plays] plays (last if(compare(math(now() - [Last Played, 0]), <, 365), FormatDate([Last Played, 0], MMM dd, unknown)/), FormatDate([Last Played, 0], yyyy, unknown)/)))
--- End code ---



Standard View Use:

If you set these fields up, you can use them for Columns, which results in:



You can see the different results in that screenshot.

1. Many episodes are watched to 90% or greater, and they're all marked with a checkmark.
2. Episode 11, 12, 16 of Season 3, are each marked with a checkmark, even though their % Complete is low, because they have at least one "Play" (meaning, you've played it through to the 1/2 point at least once, causing MC to count it as a Play).
3. Episode 3 in Season 4 is listed as 40%, because it falls in the "middle percentages" (between 10 - 89).
4. Episodes 7 and 8 of Season 4 have no output at all because I haven't watched them.  (Seriously, I haven't.  No spoilers.)  Even though Episode 7 has a tiny percentage played (checking the file, introductory commercials, etc), it still outputs blank.

Theater View Use:

You can also use it in Theater View's File Info panels.  You set it up as such:



And use them in file captions:

Movie Template:
Regular Caption:

--- Code: ---[Name]Delimit([Watched Percent], , / )
--- End code ---
Expanded Caption:

--- Code: ---[Name]
ListBuild(1, / • , [Year], [Duration], [MPAA Rating], RatingStars(),[Plays], [Watched Percent])
--- End code ---

Search:

--- Code: ---[Media Type]=[Video] [Media Sub Type]=[Movie]
--- End code ---



TV Shows Template:
Regular Caption:

--- Code: ---If([AllSameSeries], <font alpha="50">Delimit(TVInfo(SeasonEpisode))<//font>[Name]Delimit(<font alpha="50">[Watched Percent]<//font>, , / ), TVInfo(NameDisplay)Delimit(<font alpha="50">[Watched Percent]<//font>, , / )) <font alpha="50">If([AllSameSeries],,TVInfo(SeasonEpisode)/ )TVInfo(DateNoTime)<//font>
--- End code ---
Expanded Caption:

--- Code: ---If([AllSameSeries], <font alpha="50">Delimit(TVInfo(SeasonEpisode))<//font>[Name]Delimit(, , / ), TVInfo(NameDisplay))
<font alpha="50">ListBuild(1, / • , If([AllSameSeries],,TVInfo(SeasonEpisode))TVInfo(DateNoTime),[Plays],[Watched Percent])<//font>
--- End code ---

Search:

--- Code: ---[Media Type]=[Video] [Media Sub Type]=[TV Show]
--- End code ---



And it results in:











glynor:
Note:  Because some of the expression above contain returns, it is best to paste them in using the Expression Editor.  If you use the single-line editor, some of the expression might get truncated off when you paste it in.

glynor:
Please Note:  The following section is no longer required because Hendrik implemented a nice Library Tools > Mark as Played/Mark as Not Played system in current versions of MC19.  (Thanks Hendrik, you rock!)

The new system works beautifully with the stuff above.  Unfortunately, you can't quickly (yet, I hope) do these toggles from inside Theater View, but if you need to reset the status of episodes (or songs or whatever) you can do it in Standard View by simply selecting the files and Right Click > Library Tools now.

To Quickly Reset Watched Status

When using this system, you may occasionally find the need to toggle or adjust the [Watched Percent] status (to clear a checkmark or add one).  This can be challenging to do with the built in Watched() system, but now that we can directly edit [Number Plays], it is fairly painless to do from Standard View.  I'll note, unfortunately, I still don't have a good way to do this from Theater View.

To do this:
1. Add these columns to a View in Standard View: [Watched Percent], [Bookmark], [Number Plays]

2. Open the Tag Action Window, and make sure Show Tags in Current View is enabled.



3. In the same place, choose Also Show > Number Plays and make sure it has a checkmark.


This is needed because MC uses [Number Plays] in the header, and doesn't show it in the Tag Action Window even if you have it as a column.

4. Select a file or files in the file list that you'd like to tweak.  In either the Tag Action Window, or inline in the Columns, you can:

For a file that is showing a percentage, like 74%, that should be fully played (it has a lot of credits, maybe, or you re-watched part of it).  As long as [Number Plays] is at least one (which it usually will be if you watched it), then you just need to reset the [Bookmark] field.  MC doesn't let you type in a value for [Bookmark], but you can clear it.

For a file that you watched using a separate application or device that couldn't update MC's Library (so it is showing as "never played" when it has been), simply increment [Number Plays].  You can now do this directly and type in whatever number you wish (requires MC 19.0.90 or later).  Reset the [Bookmark] value if needed to get the checkmarks instead of percentages.

For a file that has a checkmark that shouldn't (because you "checked through" more than half of the file, causing it to get counted as a "play"), simply reset [Number Plays] to zero.  If needed, you can also reset the [Bookmark] (but you won't have to if you rewind when you're done checking whatever you're checking in the file that causes it in the first place).

Demo:


Click to watch: MC19 - Custom Watched Percent: Resetting Demo

Other Media Types:

I should also mention that this stuff will all basically work equally well for Podcasts and Audiobooks.  You may want to change the name of the [Watched Percent] field when you display it for this purpose.  For this, you can just wrap it in an expression and add that as a Column or Field in Theater View.

6233638:
This seems to take care of the case where a file is being played for the first time, but has not yet hit 50% to be marked as played, so watched(0) does not return the progress. (it would be easier if watched(0) returned the progress even if it's not marked as played)
 
Rather than all your compare() statements, is it easier to use isrange() ?
 

--- Code: ---if(isrange([Bookmark Percent], 0-9),
if(isequal([Number Plays],0,2),,✔),
if(isrange([Bookmark Percent], 10-89),[Bookmark Percent]%, ✔))
--- End code ---

It seems like that would be easier to change if someone wants to use a different range for their markers.
 
 
Strangely, I have a file which shows 35% using [Bookmark Percent] and 34% with Watched(0). Any idea why that would be the case?

glynor:

--- Quote from: 6233638 on December 15, 2013, 05:23:47 am ---This seems to take care of the case where a file is being played for the first time, but has not yet hit 50% to be marked as played, so watched(0) does not return the progress. (it would be easier if watched(0) returned the progress even if it's not marked as played)

--- End quote ---

Exactly.  That was the goal.  To make a smarter Watched().  The one issue with this that I haven't yet quite figured out is how to use it for a boolean "Is Watched" test.  But I don't know that I need it, because [Number Plays] could solve that.


--- Quote from: 6233638 on December 15, 2013, 05:23:47 am ---Rather than all your compare() statements, is it easier to use isrange() ?
 

--- Code: ---if(isrange([Bookmark Percent], 0-9),
if(isequal([Number Plays],0,2),,✔),
if(isrange([Bookmark Percent], 10-89),[Bookmark Percent]%, ✔)
--- End code ---

It seems like that would be easier to change if someone wants to use a different range for their markers.

--- End quote ---

You see, I was led astray by MrC's clever concatenating trick, which works but if you flip it on end like this, that is much more readable.  You forgot a parenthesis there though.  This seems to work as a replacement for my [Percent Watched] expression.  I'll do a bit more edge case testing, and then update my original post, but it looks right:


--- Code: ---if(isrange([Bookmark Percent], 0-9),
if(isequal([Number Plays],0,2),,✔),
if(isrange([Bookmark Percent], 10-89),[Bookmark Percent]%, ✔))
--- End code ---

Thanks!

I don't know about the 1 percentage difference.  I'd guess the internal Watched() uses a different degree of accuracy, so it rounds differently.  Or maybe it just truncates instead of rounding?

Navigation

[0] Message Index

[#] Next page

Go to full version