INTERACT FORUM

Please login or register.

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

Author Topic: What fields, records, playlists, etc. does After Playback expression affect  (Read 360 times)

rbmjr

  • World Citizen
  • ***
  • Posts: 143

The After Playback expression is a mystery. I have tried coding expressions only to find that they don't do what I thought they would.

Could you please explain what fields, records, playlists, etc are touched when After Playback expression executes?

I expected After Playback to touch the the item in the queue that just finished playing to be the recipient of the After Playback expression, but it does not appear to be so.

I have another issue that I just posted about, where when sending a playlist to a Zone the Last Played field does not get updated.

I thought that I could write an After Playback expression to fix this until I discovered that Last Played seems to be locked from being changed by an expression

I then wrote several versions of an After Playback expression to place either a Yes/No value into a User defined library field and that does not always work either.

Code: [Select]
If( IsEqual( [Media Type], Audio )
,
If( IsPlaying()
,
If( IsEqual( [IsPlaying], Yes , 1 )
,
SetField( WSXtra, YEP )
,
Setfield( WSXtra, Nope )
)
,
)
,
)

Can you help me understand what After Playback expression does, when it executes, and what it affects?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2829

AfterPlayback executes with the context of the file that has just finished playing.

That "if(isPlaying()" is likely introducing a race condition - it may be true sometimes but false otherwise, depending on the exact timing of the expression evaluation. Technically is should always be 'FALSE' at the time the 'AfterPlayback' expression is executed because... it's already after playback after all. So, remove it.

Likewise, what's that [IsPlaying] field? That's non standard, and if it's something that your code sets elsewhere, it may already be 'no' at this point, so untrustworthy.

In effect, you only need:
If( IsEqual( [Media Type], Audio ), SetField( WSXtra, YEP ),)
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2829

Looks like [LastPlayed,0] returns a timestamp in the internal XDate format (like now(), which is 45680.984), but when setting it it needs an Epoch value (like now(1) = 1737671917). This is an inconsistency in the internal MC API, also present in a few other Date fields. You can use human-readable dates.

So, setfield(last played, now()) actually sets the field to 1970-01-01. But setfield(last played, now(1)) works fine.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 143

That is so cool. Thanks, I'll give it a try!
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 143

Sorry to bother, I tried coding using the Epoch way: SetField( Last Played, Now(1) ) however Now(1) still returned the same 1970 date.

Did I miss something or perhaps there is a setting somewhere that I need to change?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2829

Epoch support with Now(1) was added in v33.0.55 - what version are you running?

For older versions, with can calculate the epoch value with:
Math((now()-25569)*86400)

You may need to add a timezone offset to get the hours right. For instance for a GMT-6 offset:
Math((now()-25569)*86400-6*3600)

You can check in Zelda with:
FormatDate(Math((now()-25569)*86400-6*3600),%c)

Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 143

Seems I am on 33.0 30.

I noticed this Feature Request https://yabb.jriver.com/interact/index.php?topic=140319.0

Is there a reason that the Epoch date being requested as a feature addition? I am certainly happy for it, however, why doesn't Now() in it's original format work?
Logged

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 8078
  • Long cold Winter...
Logged
I don't work for JRiver... I help keep the forums safe from "male enhancements" and other sources of sketchy pharmaceuticals.

Windows 11 24H2 Update 64-bit + Ubuntu 24.10 Oracular Oriole 64-bit | Windows 11 24H2 Update 64-bit (Intel N305 Fanless NUC 16GB RAM/500GB M.2 NVMe SSD)
JRiver Media Center 33 (Windows + Linux) | iFi ZEN DAC 3 | JBL 306P MkII Studio Monitors | Audio-Technica ATH-M50x Headphones

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2829

Is there a reason that the Epoch date being requested as a feature addition? I am certainly happy for it, however, why doesn't Now() in it's original format work?

It's just useful now and then for calculations, and some fields like [Last Played] still need it, as you've found out. There are a few other places in MC that also work with Epoch dates, and it's also the most common time format for linux/mac machines. Having both now() and now(1) avoids having to do timestamp conversions in some scenarios.

Please install v33.0.60 to have now(1) working.
Logged
Pages: [1]   Go Up