Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod script discussion/help (Read 1371056 times) previous topic - next topic
0 Members and 4 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #1700
@Brett (from Brett)

my contrib extracted from by fooRazor config as a stand alone panel, here is a more elaborated button than combine playback order button with Stop After Current button,

just copy/paste this script in a WSH panel, grab it here:

http://pastebin.com/gv0sWFq5


WSH Panel Mod script discussion/help

Reply #1701
The reason it won't work is that you need access to the gr object in order to call the function gr.SetTextRenderingHint(...). This access is granted by gr being provided to the on_paint function as a parameter.

I see.... So I can't put "SetTextRenderingHint(5);" instead to make it a global setting either I take it?

WSH Panel Mod script discussion/help

Reply #1702
I see.... So I can't put "SetTextRenderingHint(5);" instead to make it a global setting either I take it?

Nope, that function would fail because it doesn't exist. What are you trying to avoid by not calling gr.SetTextRenderingHint inside on_paint?

WSH Panel Mod script discussion/help

Reply #1703
Nope, that function would fail because it doesn't exist. What are you trying to avoid by not calling gr.SetTextRenderingHint inside on_paint?

Nothing. Just learning.

WSH Panel Mod script discussion/help

Reply #1704
Hi!

Is there a way, in a WSH panel, to get information (%title%, %album%...) about  the song to be played next in the playing playlist (assuming the playback order is default, of course) ?

I'm trying to write a panel for a "Stop after Album" button but for now all I can do is to compare the track number of the playing track with the %totaltracks% defined for the track that was playing when I triggered the button (sorry if I'm not clear)

Most of the time it works but sometimes no: if there is no %totaltracks% defined or if, in my playlist, the last song from one certain album to be played (before playing another track from another album) is not the actual last track of this album (for with %tracknumber% ==  %totaltracks%)

Thanks in advance
Decalicatan Decalicatan

WSH Panel Mod script discussion/help

Reply #1705
I've got two themes, one of which I'd like to disable the toolbar in.

I added fb.RunMainMenuCommand("View/Show Toolbars") to my on_init which works great, but there's no way to determine whether the toolbars were toggled on or off. It always just returns true. I'm assuming the answer is no, but is there any way to get the check state of the menu command first?

WSH Panel Mod script discussion/help

Reply #1706
I have a row of buttons in a WSH panel.

One of the buttons is for opening the containing folder, and this is the line in the script:
Code: [Select]
but8: new Button((bw*7) + left_margin,top_margin,bw,bh, {normal: images_path + "open-folder.png", hover: images_path + "open-folder_h.png"}, function(){fb.RunContextCommand("Open containing folder");}, "Show the NOW PLAYING item's containing folder")


My problem is the above button ONLY works with the now-playing item in the playlist, but I also want a button which will work with my selection(s).

That is, if I select item(s) in the playlist I would like to click a button which will open the containing folder of the selected items AND NOT the playing item.

Does anybody know the right code for this 'other' containing folder action? thanks.


WSH Panel Mod script discussion/help

Reply #1708
@bulletproof2k
Post #1686 was your question. Post #1611 is your answer, read it to find what you are looking for.

 


WSH Panel Mod script discussion/help

Reply #1711
WSH_Browser : first alpha

Hello. This time i'm not here for another stupid noob question  . I have finally been able to get my WSH_browser to a working state.
This is a "graphical" (well, not really for now but it will become) library browser component for WSH panel mod.
) is the most efficient way to browse the library. It works but there might be something more elegent (such as working with an autoplaylist, but then i would have to get metadbhandles several times later).
@Fallstaff i would be really happy to know what you think of my approach as you have experience with sorting lots of tracks in WSH. I had a look at your CoverFlow but didn't really understood how you are storing the handles in groups. I was unable to store handles directly in an array so i had to create several IFbMetadbHandleList objects.

Here is the script on pastebin
You will also need two additional files : Constructors.js and Helpers.js

WSH Panel Mod script discussion/help

Reply #1712
@r0k

good to see such project!

but ... first try, it doesn't work ==> foobar2000 not responding (for 5 minutes now....), my libray is big (~40k trks), i suspect your script is not for large library, but what's its maximum size to make it work?

before checking a script, i'd like to see it running well, if not, i'm not interrested ... other stuff is waiting, so i'll wait a next version of your script maybe with some restrcitions info in comments to indicate in which way somebody can test it

EDIT: hmm, works better on another try, lag just the time to populate the WSH playlist... i'll check your script asap. Careful, mousewheel make content disapear...

WSH Panel Mod script discussion/help

Reply #1713
I made a small piece of code, use it as WSH panel on its own or place it into your other script. Clicking on the panel will toggle SACT mode and inform you what is going on.

Code: [Select]
var font_1 = gdi.Font("Tahoma",10,1);
var color_1 = RGB(235,235,235);
var DT_LEFT = 0x00000000;

function on_paint(gr){
    var ww,wh;
    ww = window.Width;
    wh = window.Height;
    gr.FillSolidRect(0, 0, ww, wh, RGB(0,0,0));
    
    if(fb.IsPlaying){
        text = (fb.IsPlaying && fb.StopAfterCurrent) ? "SACT" : "NO SACT";
        gr.GdiDrawText(text, font_1, color_1, 0, 0, 60, 10, DT_LEFT);
    }
}

function RGB(r, g, b){
return (0xff000000 | (r << 16) | (g << 8) | (b));
}

function on_mouse_lbtn_down(x, y, mask){
    if(!fb.IsPlaying) return;
    fb.RunMainMenuCommand("Playback/Stop After Current");
}

function on_playlist_stop_after_current_changed(state){
        window.Repaint();
}



Wow! Thanks for the speedy replies! Unfortunately for me, I have no scripting knowledge and do not fully comprehend the WSH Panel Mod.
I have a specific UI Layout and settings that never change on my player. I need to keep this layout and settings while adding the described option in this old post of mine...
** My only issue with foobar2000 is that I don't have visual notification when I have activated a "Stop After Current" command.

In my use, I have playback follows cursor. It would be great to have the highlighted cursor able to change color to red when stop after current is selected. **


If someone out there is willing to create a script for me, and walk me through the setup, I would be more than happy to make a donation for their services to their PayPal account. Please send a PM if interested.
Thanks.

WSH Panel Mod script discussion/help

Reply #1714
Has anyone written a media library browser such as an expandable tree view in wsh panel mod?

WSH Panel Mod script discussion/help

Reply #1715
Not possible, because we cant get media library MetadbHandleList to WSH panel mod.

I hope this feature is added in the future.

WSH Panel Mod script discussion/help

Reply #1716
Not possible, because we cant get media library MetadbHandleList to WSH panel mod.

you can't say that. It's possible through another way based on a playlist that contains the library, but for sure this method is not perfect because this playlist has to be populated before being available for the script.

I hope this feature is added in the future.

yep, let's hope it's possible for T.P Wang

as we have:

    // Get all items into an instance of IFbMetadbHandleList from specified playlist
    IFbMetadbHandleList GetPlaylistItems(playlistIndex);

we'd like to have too something like this:

    // Get all items into of IFbMetadbHandleList from Media Library
    IFbMetadbHandleList GetMediaLibraryItems();


WSH Panel Mod script discussion/help

Reply #1717
@r0k

good to see such project!

but  ... first try, it doesn't work ==> foobar2000 not responding (for 5  minutes now....), my libray is big (~40k trks), i suspect your script is  not for large library, but what's its maximum size to make it work?

Not sure what the maximum size is. My library is about 4500 tracks so much smaller than yours and this script has only been tested on my computer so far. Well, that's a feedback on it's own so i know i need to improve the way i gather handles.
Quote
before  checking a script, i'd like to see it running well, if not, i'm not  interrested ... other stuff is waiting, so i'll wait a next version of  your script maybe with some restrcitions info in comments to indicate in  which way somebody can test it

EDIT: hmm, works better on  another try, lag just the time to populate the WSH playlist... i'll  check your script asap. Careful, mousewheel make content disapear...

I understand. I'll be improving it anyway. As stated i consider it an alpha, not even a beta, but i posted it anyway because a single experienced hint might improve the script more than one week of my noob work
In the current script, i have a check to prevent mousewheel from scrolling before line 1 but nothing to prevent it from scrolling past last line (this one has to be calculated first). Scrolling up should bring content back if you go too far. This will be added by the time i release the first "beta".
Not possible, because we cant get media library MetadbHandleList to WSH panel mod.

you can't say that. It's possible through another way based on a playlist that contains the library, but for sure this method is not perfect because this playlist has to be populated before being available for the script.

That's exactly the workaroud i used to gather the MetadbHandleList in my browser above. Actually, here is what i did (so you don't have to look at my code).

I have defined a MetaDB custom object constructor. In my script i create such an object. It has the following properties :
  • ownId : this is simply it's name so i can refer it in console output.
  • query : the query used to retrieve tracks. By default it's a single dot (.) that will get everything.
  • sortBy  : how to sort tracks
  • groupBy : how to group tracks (eg : by genre)
  • groups : an object containing group names based on groupBy (eg. Rock) and metaHandles sub-lists (those are full IFbMetadbHandleLists objects as i wasn't able to store metaHandles in simple jscript arrays).

The following methods are available :
  • doListHandles : will retreive MetadbHandles from the library matching the query. Actually it will create a temporary auto-playlist with said query. Get all MetadbHandles then remove the auto-pl. It's quite an ugly workaround but it works, at least on small to medium libraries . MetadbHandles are stored twice, one as a "working" set and one as a "backup" set. I'm not sure how this impacts memory use and performances with big libraries. According to Falstaff's tests it's not working very well.
  • doResetHandles : will reset the "working" set to match the "backup" set
  • doFilterHandles : will filter the "working" set to exclude MetadbHandles not matching a filter passed as argument.
  • doGroups : will sort the MetadbHandles from the "working" set and store copies of them in the groups object (MetadbHandles are thus stored three times, i hope they are not big memory eaters:unsure:)
  • getGroups : will return the names of the groups to the script so they can be used to get the tracks in other statements.
I'm quite sure i can improve this, and of course it would be nice to skip the playlist step altogether (a probable cause of some delay with big libraries).

My browser could probably be modified to show a tree view. I might add it later, but it's currently an early alpha and i won't add features until it's working smoothly on bigger libraries and the current features and interface are polished enough.


WSH Panel Mod script discussion/help

Reply #1719
WSH_Browser : first alpha


In my system (core2duo E7400 2GB ram winxp) and with my 57000 tracks library, it works from the first run. There is a lag of about 5 seconds switching from alphabetic and genre view, like that switching in ColumnsUI filters; only facets in DUI is faster. I like your project because i need a simple interface to easily control with a 7" touchscreen monitor, but i'm not a programmer and my last one

) is very slow and not much user-friendly...
I can't help you in programming, but if you need a beta-tester with a large library... I'm here 
Good work 
Fabio

WSH Panel Mod script discussion/help

Reply #1720
Thanks for the encouragement and feedback.
Actually, i didn't even think about touchscreens but i can see how a simple visual interface can be useful for those. I'll try to keep them in mind for further developpment.
"Beta test" will be open, so you are free to participate 

Well, speaking of my script, i'm running into a bad hang currently. I'm trying to get the path that's common to all items in a group, in order to search this path for artwok to show (artist picture, album cover ...) and avoid the need to keep a copy of every artwork inside the artwok folder where non-path related artwork (eg genres will be kept). However my code is making foobar2000 hang idefinitely (like i'm running an endless loop  )

I've narrowed the hang to this part of the code :
Code: [Select]
        // Search for a common path to all items in the group.
            __path = __hnd.Path;
            if (this.groups[__groupName].path) { // if true there is already a path stored, find common path
                __path = __path.split("\\"); // Split into an array of folder names.
                __pathOld = this.groups[__groupName].path.split("\\");
                for (var i = (__path.length-1); i>=0; i--) { // Check every item, starting by the end
                    if (i >= __pathOld.length) { // if current path is longer than stored path
                        void __path.pop(); // remove last item from current path
                        continue; // begin next iteration
                    } else if (__path[i] == __pathOld[i]) { // compare last item of stored and current path
                        this.groups[__groupName].path = __pathOld.join("\\");
                        break; // break the loop and keep the path as it is now
                    } else {
                    void __path.pop(); // reduce the path one level towards the root
                    void __pathOld.pop();
                    }
                }
            } else this.groups[__groupName].path = __path; // store path of the first track

And more precisely, the for loop part. It shouldn't loop forever, i'm decresing i at each loop and the condition is i>=0.
Can someone tell me what noobish mistake i made?

WSH Panel Mod script discussion/help

Reply #1721
Can someone tell me what noobish mistake i made?

From a quick glance I can't see an obvious problem, however you could try using a reverse while-loop instead (as you're already decrementing). Something like:

Code: [Select]
var i = __path.length - 1;
while (i--) {
   // (The stuff that was in the for loop goes here)
}

Replacing the loop should prove whether or not the problem is the loop (and a reverse while may be more efficient anyway).

WSH Panel Mod script discussion/help

Reply #1722
adding fb.trace("i = "+i) in the loop may help you to find what's wrong with your loop ...

WSH Panel Mod script discussion/help

Reply #1723
re: while loop
I try to stay away from while loops as they seem more prone to endless loop (they are easier to code badly  ) but i see the logic behind your example. I wouldn't have thought of grouping the condition and the increment/decrement. Thanks.

@Falstaff
I already have some console output, thought not at this place. But i can't look at the console as fb2k itself will hang, not just the panel 
EDIT : never mind, just found the "write log" checkbox in the console.
EDIT 2 : nay, even with  "write log" checked, i don't get any console output at all when hangs occur. Not even output from statements that are executed before the loop goes crazy  (actually : write log is not kept when fb2k restarts.

I tried to compare strings directly with what looks like simpler code, but i still have an endless hang. Got it working!

FINAL EDIT
OK, i got it working, but can someone explain me why :
Code: [Select]
        var i=0;
        do {
            if (__path.charAt(i) != __pathOld.charAt(i)) break; // path no longer common, break the loop
        } while(i++ < __pathLen);
        __path = __path.substr(0,i); // keep only the common part
        __path = __path.substr(0,__path.lastIndexOf("\\")); // don't consider path after the last backslash
        ...
Does not work, but
Code: [Select]
        var __totoIsBack=0;
        do {
            if (__path.charAt(__totoIsBack) != __pathOld.charAt(__totoIsBack)) break; // path no longer common, break the loop
        } while(__totoIsBack++ < __pathLen);
        __path = __path.substr(0,__totoIsBack); // keep only the common part
        __path = __path.substr(0,__path.lastIndexOf("\\")); // don't consider path after the last backslash
        ...

does

WSH Panel Mod script discussion/help

Reply #1724
Hi!

Is there a way, in a WSH panel, to get information (%title%, %album%...) about  the song to be played next in the playing playlist (assuming the playback order is default, of course) ?

I've used the following function to add a stop-after-album feature. The important parts are plman.GetPlaylistItems(plman.PlayingPlaylist), which give you the playlist's tracks in order, and plman.GetPlayingItemLocation().PlaylistItemIndex, which gives the index of the current track.

Code: [Select]
function on_playback_new_track(current_track) {
    var next_track = current_track;
    // get next track
    if (plman.IsPlaybackQueueActive()) {
        // check first item in queue
        next_track = plman.GetPlaybackQueueContents().toArray()[0].Handle;
    } else {
        var i = plman.GetPlayingItemLocation().PlaylistItemIndex;
        var pl_items = plman.GetPlaylistItems(plman.PlayingPlaylist);
        if (i + 1 == pl_items.Count) {
            // current_track is the last item in playlist
        } else if (i > pl_items.Count) {
            // current_track is no longer in the playlist
            fb.StopAfterCurrent = true;
            return;
        } else {
            next_track = pl_items.Item(i+1);
        }
    }
   
    // ALBUM_TF is something like fb.TitleFormat(window.GetProperty("ALBUM TF", "%album artist% %album%"));
    if (ALBUM_TF.EvalWithMetadb(current_track) != ALBUM_TF.EvalWithMetadb(next_track)) {
        fb.StopAfterCurrent = true;
    } else {
        fb.StopAfterCurrent = false;
    }
}