Help - Search - Members - Calendar
Full Version: static variables
Hydrogenaudio Forums > Hosted Forums > foobar2000 > General - (fb2k)
crazymad
hello, I am new to scripting, so excuse me, if this is to lame:

I am trying to build a function, that will tell me, when my track has been 'scobbled' in last.fm. to do so, I need know for how long I have been listening to a track. unlike the %playback_time% variable, my function should keep up counting the seconds normally, even if I jump around within the track.

I thought Id just compare two timestamps, one when I started listening and one with the current time in seconds, and determine for how long I have been listening.

so here is the problem: when I want to save the timestamp for when I started listening, foobar will always save the content of the variable dynamically. so with every second that passes, this timestamp will increase by one.

my question is, how can I save this number (this timestamp) so it 'freezes'/save it statically?

$put(timestamp, ... ) is useless I suppose....

thx for any help
foosion
You cannot store a value in such a way that it is available on later runs of the same formatting script.
crazymad
QUOTE(foosion @ Jan 25 2007, 16:14) *

You cannot store a value in such a way that it is available on later runs of the same formatting script.

so this means, I need a plugin to give me a variable %playback_start% with the date and time when it started playback. is there anything out there, or do I have to try and do it myself?

thx again, if anyone knows
Blippe
Use search, you will find a snippet of code which does just what you are after...

look if played time is higher than 30sec or half the playtime whichever is highest, there is no need to save any parameters between updates of the playlist, just plain if a is higher than b and a is higher than c.

The audioscrobbler plugin(s) should never report a song where you have jumped in before that time has passed.
crazymad
well it does. as long as playback is activated, you can jump around as much as you want and audioscrobbler will keep counting down the seconds until it hits song_playtime/2 or 4min.

if you mean I should use %playback_time%, then that wont be the same as what audioscrobbler does.

I guess Ill ask at the audioscrobbler topic if they can implement a boolean variable if the song has been scrobbled or not. that should be the easiest.
Raven.am0k
QUOTE(crazymad @ Jan 25 2007, 22:32) *

hello, I am new to scripting, so excuse me, if this is to lame:

I am trying to build a function, that will tell me, when my track has been 'scobbled' in last.fm. to do so.....



Here is a code that maybe help you.

CODE

$ifgreater(%length_seconds%,30,
$ifgreater(%playback_time_seconds%,%playback_time_remaining_seconds%,$rgb(0,165,244,0,165,244)Scrobbled,
$ifgreater(%playback_time_seconds%,240,$rgb(0,165,244,0,165,244)Scrobbled,Unscrobbled)),Unscrobbled)


greets Raven.am0k
crazymad
hey,
thx for your help, but unfortunately it doesnt work, the way I want it to:
the thing is, I could skip around within the song and suddenly have it saying scrobbled, even though it isnt scrobbled, because the song needs to be playing for a certain time and not be at a certain position. thats why I need a solution to refer to the 'song_playback_start'-time at all times and calculate the 'song_playback_past'-time (or something like that)
Yotsuya
Sorry this isn't a solid answer, however..

You might want to explore foo_custominfo. I don't have much experience with it so I cannot provide much detail but it is my impression that this component will allow you to store arbitrary tags for songs outside of the file itself. It should then be a simple matter to combine isplaying with playbacktime is 0 or 1, and then dump the current time into a custom tag. You can then compare the difference with that tag with the current time and look for your half total time or 30 seconds.

IMO a plugin like the audioscrobbler plugin should provide a global variable that indicates if the current song has been "scrobbled" or not.
crazymad
what would be the function to insert a value into a custom tag within titlescripting?
All I can seem to do with this plugin is insert a new value to a (new) custom tag by using the context menu.
another solution (makeing it a really dirty one) I could think of, would be to make a new context menu button to save the current system time formatted in seconds, assigning a shortcut to it, and then executing this shortcut somehow with a function in titleformating. but I couldnt find such a function, and I doubt it exsits. but maybe someone knows a plugin or something (maybe I just oversaw it ^^) and could point me to it, to do this.
hopefully, though, there is a way to insert a value into a custom tag using titleformating directly.

the other problem I have now, how do I know if the song really just started to play, or if someone just skipped back to the start of the song (which is speaking 'audioscrobbler' not the same thing). but since anyone rarely does this, its not big of a concern. I'd just love to get this to work.
nobody seems to answer in the audioscrobbler topic... sad.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.