HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: foxX on 2023-07-09 19:40:24

Title: foo_nowplaying2
Post by: foxX on 2023-07-09 19:40:24
I'm happy to announce my first foobar2000 plugin, foo_nowplaying2.

What it does is output a title-formatted string with the playback state to a user-configured file. That file can be consumed by software such as OBS Studio - Text (GDI+) source.
(https://i.imgur.com/NaF6xyu.png) (https://i.imgur.com/NaF6xyu)

Get it from github - https://github.com/foxx1337/foo_nowplaying2
Title: Re: foo_nowplaying2
Post by: Cannonaire on 2023-07-09 19:42:42
Thank you! I've been looking for a replacement for NP. I use it to overlay text of what's playing when I stream.

**EDIT**
When I click on Releases, it goes to a 404. I am logged into GitHub.
Title: Re: foo_nowplaying2
Post by: foxX on 2023-07-09 20:04:12
When I click on Releases, it goes to a 404. I am logged into GitHub.

The direct binary link - https://github.com/foxx1337/foo_nowplaying2/releases/download/v1.0/foo_nowplaying2.fb2k-component
Title: Re: foo_nowplaying2
Post by: sveakul on 2023-07-09 22:34:29
**EDIT**
When I click on Releases, it goes to a 404. I am logged into GitHub.
This will work:  https://github.com/foxx1337/foo_nowplaying2/releases (https://github.com/foxx1337/foo_nowplaying2/releases)
Title: Re: foo_nowplaying2
Post by: Cannonaire on 2023-07-09 22:37:08
Thank you!
Title: Re: foo_nowplaying2
Post by: sveakul on 2023-07-10 05:59:53
@foxX :  please add an option to limit the size of a log text file by specifying the maximum number of entries, after which new entries will make older ones "spool off."  Thanks for the 64-bit version!
Title: Re: foo_nowplaying2
Post by: foxX on 2023-09-09 15:58:39
Done, released as v2.0 - https://github.com/foxx1337/foo_nowplaying2/releases/tag/v2.0

(https://imgur.com/FlrtJ2R.png)
Title: Re: foo_nowplaying2
Post by: Air KEN on 2023-09-09 16:08:42
Now Playing 2 0.1 (foo_nowplaying2) (2023-09-09)
vearsion remains 0.1.

It was also v0.1 when I was in "Now Playing 2 0.1 (foo_nowplaying2) (2023-07-09)".
Title: Re: foo_nowplaying2
Post by: foxX on 2023-09-09 18:22:24
Oops.
Title: Re: foo_nowplaying2
Post by: tlesk on 2023-09-18 13:29:38
Hi! I was so happy to find your add-in! It works like a charm. I am using it to project info about the current playing track. One question or idea...

Would it also be possible to export in such a way data about THE NEXT track in a queue? I would need this to announce what is playing next while the current track is still playing.

tlesk
Title: Re: foo_nowplaying2
Post by: foxX on 2023-09-24 12:22:03
Would it also be possible to export in such a way data about THE NEXT track in a queue? I would need this to announce what is playing next while the current track is still playing.
I think I know how to do it.

Title: Re: foo_nowplaying2
Post by: Wolfbane on 2023-10-04 05:45:27
Hello, I used to use an old plugin called "AMIP Wrapper" to rename my songs, (last updated 2010, stopped working with Foobar 2.0)

So now Im here testing your plugin out, its recent made plugin and that's awesome that you took apon to do this.

Atm Im missing 1-2 huge feature and that is, what kind of change should happen to the text file when no song is being played.

So lets say I played a song, on stream I Stop the music to talk to viewers about something, then I would prefer not to have the song info still visible on my screen.

** 1 **
So basically "Stop = Change text" and if so to what... my preference would be " " (just space) but that could just be an empty field that can be customized by each person.
( I just realized that it does this by default, but still an option field to write whatever a person prefers on their own would be nice, maybe I want it to say "No Song playing atm" )
I also to my surprise found out that the text file gets re-written if I pause the song. To the exact same text as when song was playing, feels not necessary.


** 2 **
When song is playing sometimes people forget to read what the song was, and they ask at the end of the song, or even worse they ask in the next song, and with random shuffle, streaming I don't freaking remember...
So.... then it would be nice if the previous song possible to be saved in another txt file of my choice.


** 3 ** Is not needed but would be fancy...
Lets say when a song is changed, instead of instantly changing the text file, if it could to every 0.5 sec it would remove the last letter in the text file and save it.
Untill all letters are removed, then do the same but in oposit order when writing the new song. So type one letter each 0.5 sec, it would look like someone was typing the name.
Needed? Absolutely not, but it would be cool.
Title: Re: foo_nowplaying2
Post by: tlesk on 2023-10-05 12:39:28
Would it also be possible to export in such a way data about THE NEXT track in a queue? I would need this to announce what is playing next while the current track is still playing.
I think I know how to do it.

  • same file, or different file?
  • first n entries from the playback queue, OR, if queue is empty, first n entries after the current one in the playlist, if the playback order is "Default"?


For what I need it would be enough to get next playing track with the same format as for the now playing track in a separate file. If there is no next playing track, then the file is empty. But if it is easier for you, you can just add Include next playing track checkmark to the interface and put the next playing track as the last line in the file. Or you can auto create a file with a prefix next_<filename> and just write the next playing track with the same format to it. It would be really nice to have this. Thanks.
Title: Re: foo_nowplaying2
Post by: SushiKishi on 2023-10-28 09:13:39
The only thing I can't seem to replicate from foo_np_WhateverTheOriginalWasCalled is having it spit out something if Foobar is closed (it would set the output file before exiting) and/or when I click on stop.  I'm trying this as the Format but it's not outputting anything when I click on stop:

Code: [Select]
$if(
%isplaying%,
$if(%ispaused%,|| Paused ||,▶ Playing ▶)
$if2($trim(%title%),$trim(%filename%)) by
$if2(%artist%,Unknown Artist) on
$if2(%album%,Unknown Album),
ThisIsNotShowingIfIClickOnStop)
Title: Re: foo_nowplaying2
Post by: SushiKishi on 2023-10-28 09:23:23
** 2 **
When song is playing sometimes people forget to read what the song was, and they ask at the end of the song, or even worse they ask in the next song, and with random shuffle, streaming I don't freaking remember...
So.... then it would be nice if the previous song possible to be saved in another txt file of my choice.

The component does have a 'log mode' option that you can use to keep the last X number of songs in the file, though it will of course make the output file a multi-line file and you may need to adjust your stream layout in OBS to accomodate.  OBS text sources do a have a 'log' option as well but I'd have to play around with it a bit to know how to use it.

As far as getting the "previous song" information to your chatters, your chatbot should be able to open the text file and display more than one song as a response to a command, it might just need a little elbow grease to format it nicely (instead of outputting "Current Song - CurrentTitleLastSong - Last Title"). It would depend on your bot, though, but if you let me know your setup I might be able to walk you through it if you need a hand.
Title: Re: foo_nowplaying2
Post by: foxX on 2023-11-05 18:28:07
v3.0 is out https://github.com/foxx1337/foo_nowplaying2/releases/tag/v3.0

Added 2 new tabs, one for "next up", similar to the "now playing" functionality, working for queue and for the "Default" playback order.
The second tab is just for an infinite log of entries prefixed by timestamp, sort of like an offline last.fm database.

(https://i.imgur.com/YagGysv.png)

Also using Consolas for the code editors if possible.

What's the deal with writing something to the "Now Playing" file on stop?
Title: Re: foo_nowplaying2
Post by: Air KEN on 2023-11-06 02:44:18
Thanks for Update.
Title: Re: foo_nowplaying2
Post by: Air KEN on 2023-11-07 11:18:52
Hi.

Now Playing 2 3.0 (foo_nowplaying2) (2023-11-05):

\foobar2000\profile\configuration\foo_nowplaying2.dll.cfg

I don't have the configuration file that existed in previous versions, where is it saved?

foobar2000 v2.1 preview 2023-10-30  64-bit Portable installation
Title: Re: foo_nowplaying2
Post by: fbuser on 2023-11-07 11:30:36
I don't have the configuration file that existed in previous versions, where is it saved?

foobar2000 v2.1 preview 2023-10-30  64-bit Portable installation
In foobar2000 v2+ there aren't any cfg files anymore. All settings are stored in the config.sqlite database.
Title: Re: foo_nowplaying2
Post by: Air KEN on 2023-11-07 11:43:30
Thank you for your reply.

It was in "Now Playing 2 2.1 (2023-09-09)"
Other Components (.cfg) have also been updated.

For example, if you delete foo_run.dll.cfg (foo_run) and start foobar, foo_run will be in its initial state.
If you return it, it will return to normal.
Title: Re: foo_nowplaying2
Post by: fbuser on 2023-11-07 12:43:01
Actually, my answer was not completely correct. There isn't only any cfg file anymore, if the component is upgraded to use the new config system. This seems to be the case for the latest "Now Playing 2" version.
Title: Re: foo_nowplaying2
Post by: Air KEN on 2023-11-07 12:52:08
Thanks.
What if I want to use a specific configuration file for another foobar (Portable installation)?
Title: Re: foo_nowplaying2
Post by: marc2k3 on 2023-11-07 13:01:17
It'll be in config.sqlite. But this also stores all fb2k core settings and settings from other components that use this new storage mechanism.
Title: Re: foo_nowplaying2
Post by: Air KEN on 2023-11-07 13:17:35
@marc2k3
Thanks.
So, it seems impossible to extract only specific component settings?

If you need to edit config.sqlite, I can't do it.
Title: Re: foo_nowplaying2
Post by: foxX on 2023-11-07 17:59:42
v3.1 released: there was a bug with the monospace font scaling incorrectly on scaled displays.

https://github.com/foxx1337/foo_nowplaying2/releases/tag/v3.1

Since this is using a new SDK, make sure to back your fancy config strings up, they sometimes get reset on upgrade.
Title: Re: foo_nowplaying2
Post by: abracadadaniel on 2024-01-10 18:18:13
How could i make a tracklist using this? I'm trying out "%title% %length_seconds%" and then pasting into excel i can create list of tracks: 'Song "A" Start: xx:xx End: yy:yy'. But that only works if i don't pause tracks or dont change them. Is there more flexible way of doing this? Like fetching time when each song starts playing?
Title: Re: foo_nowplaying2
Post by: MGriffin on 2024-02-18 18:40:27
I would love to use this new component with OBS, but it won't write the needed text file. The Foobar console says:  "nowplaying2 failed to open "C:\Users\Mikel\Desktop\foobar2000_liveset\foobar2000-Nowplaying2.txt" for writing". The text file is there. What should I do?
Title: Re: foo_nowplaying2
Post by: marc2k3 on 2024-02-18 18:54:48
It's not disputing the file's existence. Look again

Quote
failed to open <snip> for writing

Seems like the file is locked by some other process and can't be written to.
Title: Re: foo_nowplaying2
Post by: MGriffin on 2024-02-18 19:40:28
Y
It's not disputing the file's existence. Look again

Quote
failed to open <snip> for writing

Seems like the file is locked by some other process and can't be written to.
Yes, you were right. And I looked at the security settings of the text file. All users were allowed to read or write. I changed the foobar settings to open the program as an administrator. It didn't work. But finally the Win11 Security settings - Exploits -> Program prefs did the trick. I allowed Foobar2000 everything. Now it works.
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-02-18 20:02:37
What would be nice is if this plugin had the ability to write playing artist/titles from radio streams containing that metadata, as the original foo_np_simple could/can used with foo_dyndec (unknown if the latter would be needed now).  I have a request put in at github that has been acknowedged by the developer, if anyone cares to give it a +1 over there:  https://github.com/foxx1337/foo_nowplaying2/issues/2 (https://github.com/foxx1337/foo_nowplaying2/issues/2)
Title: Re: foo_nowplaying2
Post by: marc2k3 on 2024-02-19 03:46:46
^ I've stuck my oar in with a few lines of code that would probably get it going. :P
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-02-19 08:56:14
Thanks, much appreciated!
Title: Re: foo_nowplaying2
Post by: foxX on 2024-03-30 12:24:58
Version 4.0 released - https://github.com/foxx1337/foo_nowplaying2/releases/tag/v4.0

@marc2k3  and @sveakul  - done.

It remains for me to figure out a cool way for adding an exit string, as per request by @SushiKishi.
Title: Re: foo_nowplaying2
Post by: Pollux88 on 2024-03-31 15:16:47
Version 4.0 released - https://github.com/foxx1337/foo_nowplaying2/releases/tag/v4.0

@marc2k3  and @sveakul  - done.

It remains for me to figure out a cool way for adding an exit string, as per request by @SushiKishi.

Cool, thanks! At first I thought it didn't work, because I was using the "log" tab, and apparently that one still doesn't work for streaming titles.

Another feature request🤭: append new entries to beginning of file in log mode
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-04-01 00:49:02
That the plugin now works with stream metadata is welcome, but I'm trying to figure out how to add a preceding date/time stamp to the On New Track event in Log Mode; %datetime% : %artist% - %title% does NOT work.  A log file isn't worth much without it.  So, that, and a +1 to Pollux88 on requesting that the last played song be on TOP of the list.
Title: Re: foo_nowplaying2
Post by: itsChris on 2024-04-06 09:25:04
first of all, many thanks for your hard work.

Is it possible to add a datetime stamp to the log?

so instead of

%artist% - %title%

which results in:

Bill Evans Trio - Some Other Time
Wynton Marsalis - Skylark
Tord Gustavsen Trio - Melted Matter

[%date%-%time%]%artist% - %title%

?

maybe this functionality is already given/present, but i wasn't able to figure that out.

thanks!

/itsChris
Title: Re: foo_nowplaying2
Post by: marc2k3 on 2024-04-06 13:44:32
Here's an alternative if anyone wants to try it...

https://jscript-panel.github.io/gallery/play-log/

This requires a panel in your layout so don't even click if you don't want that. :P
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-04-06 21:04:35
Here's an alternative if anyone wants to try it...

https://jscript-panel.github.io/gallery/play-log/

This requires a panel in your layout so don't even click if you don't want that. :P
Beautiful, marc2k3!  I see this is now included as a sample in the latest jscript3 download.

I have been using code contributed by you a while back to do "sort-of-the same-thing" but it requires using Text Reader as well to display the log in the GUI:
(https://i.imgur.com/yNimm8i.png)
It sure has stood the test of time though even without the "easy options".  Using it right now actually--until I grab Play Log that is!  Attached your original code below for "historical purposes"  :)
Title: Re: foo_nowplaying2
Post by: tlesk on 2024-04-21 10:40:03
Version 4.0 released - https://github.com/foxx1337/foo_nowplaying2/releases/tag/v4.0

@marc2k3  and @sveakul  - done.

It remains for me to figure out a cool way for adding an exit string, as per request by @SushiKishi.

This is just wonderful. Thank you!
Title: Re: foo_nowplaying2
Post by: foxX on 2024-04-21 14:51:44
Updated to v4.1 - https://github.com/foxx1337/foo_nowplaying2/releases/tag/v4.1

This one adds strings on exit and enables the dynamic stream info updates in the Log tab too.
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-04-23 06:48:48
Updated to v4.1 - https://github.com/foxx1337/foo_nowplaying2/releases/tag/v4.1

This one adds strings on exit and enables the dynamic stream info updates in the Log tab too.
The problems others have brought up recently still remain with this version--how can the log entries be date/time stamped (%datetime% is NOT recognized, unlike the original np_simple), and how can the entries be logged latest first instead of last??

The immediate solution for those with jscript panel3 is its Play Log sample as mentioned above, but it would be nice to see this plugin at least retain the functionality of its predecessor.
Title: Re: foo_nowplaying2
Post by: marc2k3 on 2024-04-23 07:26:47
Here's a bit of code for implementing %datetime%.

First you need this...

Code: [Select]
#include <pfc/filetimetools.h>

class TitleFormatHook : public titleformat_hook
{
public:
bool process_field(titleformat_text_out* out, const char* field, size_t, bool& found_flag) final
{
if (stricmp_utf8(field, "datetime") == 0)
{
const auto ts = pfc::fileTimeNow();
const auto str = pfc::format_filetimestamp(ts);
out->write(titleformat_inputtypes::unknown, str);

found_flag = true;
return true;
}

found_flag = false;
return false;
}

bool process_function(titleformat_text_out*, const char*, size_t, titleformat_hook_function_params*, bool& found_flag) final
{
found_flag = false;
return false;
}
};

Then to use it. existing code might look like this.

Code: [Select]
playback_control::get()->playback_format_title(nullptr, str, obj, nullptr, playback_control::display_level_all);

The first nullptr is the title format hook arg so it can be updated like this...

Code: [Select]
TitleFormatHook hook;
playback_control::get()->playback_format_title(&hook, str, obj, nullptr, playback_control::display_level_all);

Title: Re: foo_nowplaying2
Post by: foxX on 2024-04-24 23:04:31
4.2 is out with %datetime% support!
https://github.com/foxx1337/foo_nowplaying2/releases/tag/v4.2
Thanks for this new code snippet, @marc2k3, it never ceases to amaze how awesome the foobar2000 SDK is!

I'm considering whether to implement line reordering, it has the potential to destroy performance.
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-04-25 00:28:35
Sorry, but %datetime% support still broken in 4.2:  https://github.com/foxx1337/foo_nowplaying2/issues/6 (https://github.com/foxx1337/foo_nowplaying2/issues/6)
Title: Re: foo_nowplaying2
Post by: foxX on 2024-05-05 17:03:52
@sveakul - what's your usecase for logging the now playing data in reverse order (most recent song, first in the file)?

I'm considering not implementing this at all, and adding instead something better than some of the previous work - a new tab where one can enter arbitrary commands to run on "now playing", with the regular titleformatting, etc. Thoughts?
Title: Re: foo_nowplaying2
Post by: sveakul on 2024-05-06 09:26:38
@sveakul - what's your usecase for logging the now playing data in reverse order (most recent song, first in the file)?

I'm considering not implementing this at all, and adding instead something better than some of the previous work - a new tab where one can enter arbitrary commands to run on "now playing", with the regular titleformatting, etc. Thoughts?
My use case is that when scrolling through a text file log for a song reference it's usually for something heard recently, and therefore quicker to find when the most recent played are listed first (also requested by Pollux88 (https://hydrogenaud.io/index.php/topic,124427.msg1042051.html#msg1042051)).

I noticed that my issue reported above with version 4.2 still not showing %datetime% was closed last week as "completed"--does this mean you will be releasing a new version with the fix, or has the code change been implemented immediately without a version number change?  I can live without the ordering change, but it's unusable with a working %datetime% field.

As a "true confession" I must admit I'm already using marc2k3's Play Log which does everything I need, but for those who for whatever reason choose not to install jscript panel 3, your revised plugin is their only choice for 64-bit Foobar versions.