Skip to main content

Topic: WSH Panel Mod script discussion/help (Read 842470 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
WSH Panel Mod script discussion/help
Reply #25
Great job marc2003.
Just one thing. You know that biography view can get those info for you and cache them. As it works as a background process i suppose it also works with DUI.
i am using biograview tags to do what you do.


Yes, it can.  But it causes some minor pauses (for me at least) when switching tracks even when only running as a background process.  Not relying on the biography plugin seems to solve that problem.

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #26
Great job marc2003.
Just one thing. You know that biography view can get those info for you and cache them. As it works as a background process i suppose it also works with DUI.
i am using biograview tags to do what you do.


Yes, it can.  But it causes some minor pauses (for me at least) when switching tracks even when only running as a background process.  Not relying on the biography plugin seems to solve that problem.

Oh i didnt know that. Sorry

WSH Panel Mod script discussion/help
Reply #27
It might not be the case for CUI, but I can notice it on DUI.  If you use a crossfader (I do) or gapless playback, there's a small (yet noticeable) blip between tracks.  Additionally, this "blip" also freezes the UI display, so it effectively breaks the fading effect in your new album art script.

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #28
You know that biography view can get those info for you and cache them.


i didn't. but at least mine gives people a blank canvas to work with. it could easily be expanded to use the foobar artreader for images, adding backgrounds, styling, buttons, etc.

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #29
You know that biography view can get those info for you and cache them.


i didn't. but at least mine gives people a blank canvas to work with. it could easily be expanded to use the foobar artreader for images, adding backgrounds, styling, buttons, etc.

Yes you are right. Great job

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #30
an update on my bio panel. just a little bug fix.

Moderation: (Link removed by [a href='index.php?act=findpost&pid=682249']request[/a].)[/size]
  • Last Edit: 21 January, 2010, 06:01:20 PM by Yirkha

WSH Panel Mod script discussion/help
Reply #31
carmenm, be sure to post your similar artists script when you get to a point where you think it's stable, that looks amazing!

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #32
carmenm, be sure to post your similar artists script when you get to a point where you think it's stable, that looks amazing!

Thanks i will. But seeing problems people have with Biography view, i am writing a background script to do its caching job. All my other lastfm scripts will depend on it. Will post as soon as it is stable.

  • TomBarlow
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #33
I have a script to share, it's an album art/lyrics view. Also, I made a quick script to get the colours and font, name it getColoursFonts.js in your scripts directory: http://pastebin.com/f194f3496

Now here is my art viewer. It has the following features: double click to swap between prefer now playing and prefer focused track, middle click to swap between prefer art and prefer lyrics, and mouse scroll to change art type or to scroll lyrics. http://pastebin.com/f3d25a237

I haven't got a fade transition on the art, and I'm not sure the lyrics scroll quite right. It also doesn't handle synced lyrics, but it probably could be modified to.

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #34
thanks for those tom. can't believe i didn't think of using the mouse wheel to scroll my biography panel.   

updated version with scrolling support.

Moderation: (Link removed by [a href='index.php?act=findpost&pid=682249']request[/a].)[/size]

@tom, your script needs a little fixing. starting foobar with an empty playlist causes your panel to crash.
  • Last Edit: 21 January, 2010, 06:01:30 PM by Yirkha

WSH Panel Mod script discussion/help
Reply #35
Hey Marc, I don't want to discourage your efforts, but take a look at the biography view thread: http://www.hydrogenaudio.org/forums/index....5&start=225

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #36
oh well....

i hope ssenna ports over his other components to DUI. library tree and ELPlaylist would be amazing

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #37
Wow that s a great news.

I wanted to show what i managed to build with WSH panel Mod. Every panel is made with WSH.
I have no Biography View. There is a background wsh that download everything necessary from Lastfm. All the others are just triggered for new data.
I could use biography view to do so, but syncing with my panel would be hard and would still have to communicate with lastfm for love, etc ... And i prefer to limit the number of connections.
Moreover the back script does not only download data for the playing track, it also download small artist images for similar.
All images are cached.

For the similar artists, those are buttons that link to the lastfm page

I will released as soon as possible. I still need to debug and use an ini file for all panels.

Hope you like it


  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #38
my menu is better than yours....

  • Last Edit: 16 January, 2010, 03:02:00 PM by marc2003

  • TomBarlow
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #39
@tom, your script needs a little fixing. starting foobar with an empty playlist causes your panel to crash.

Thanks, I think I fixed it: http://pastebin.com/f1e4b9ee6

  • Andre69
  • [*]
WSH Panel Mod script discussion/help
Reply #40
here's another script. this is for DUI only. it allows you to create your own buttons of any size, using any images you like. by default it uses the DUI background colour (it changes colour as you change theme).

..ZIP..
I want to make a buttonpanel. I use your scripts.
I setup a run service to aktivate Album Art Downloader with the Artist and Title of the selected song.
If I press the button nothing happends. Only if I play the song the button will work.

Can I change this ?

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #41
you can add add this to your script.....

Code: [Select]
var g_metadb = fb.GetFocusItem();

function on_item_focus_change() {
if (g_metadb) window.UnwatchMetadb();
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}

function on_playlist_switch() {
   on_item_focus_change();
}

function on_metadb_changed() {
if(!g_metadb) return;
//you need to move your buttons declaration into here
Buttons = {
but1: new Button(0,0,bw,bh, {normal: images + "stop.png", hover: images + "stop_h.png"}, function(){fb.Stop();}, "Stop"),
but2: new Button(bw,0,bw,bh, {normal: images + "pause.png", hover: images + "pause_h.png"}, function(){fb.Pause();}, "Pause"),
but3: new Button(bw*2,0,bw,bh, {normal: images + "play.png", hover: images + "play_h.png"}, function(){fb.Play();}, "Play"),
but4: new Button(bw*3,0,bw,bh, {normal: images + "previous.png", hover: images + "previous_h.png"}, function(){fb.Prev();}, "Previous"),
but5: new Button(bw*4,0,bw,bh, {normal: images + "next.png", hover: images + "next_h.png"}, function(){fb.Next();}, "Next")
};
}

function on_playback_new_track() {
on_item_focus_change();
}

on_item_focus_change();

you need to use this as your function

Code: [Select]
fb.RunContextCommandWithMetadb("context menu command goes here", g_metadb);

also, be aware that WSH panel mod can only run commands on the selected/playing item only and not a selection.
  • Last Edit: 18 January, 2010, 01:03:54 PM by marc2003

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod script discussion/help
Reply #42
This is a simple demo that using GdiDrawText() with scroll (mouse):

EDIT: Improved
EDIT2: Improved again, now both mouse whell and mouse drag work.

http://pastebin.ca/1758754

Code: [Select]
var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;

String.prototype.repeat = function( num ) {
   return new Array( num + 1 ).join( this );
}

var g_font = gdi.Font("Tahoma", 12);
var g_text = ("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n" +
   "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n" +
   "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n" +
   "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\n").repeat(5);

var ww = 0, wh = 0;
var g_textcolor = 0xff000000;
var g_backcolor = 0xffffffff;
var g_need_calc = true;
var g_textheight = 0;
var g_offset = 0;
var g_drag = false;
var g_drag_y = 0;

// START
function on_size() {
   ww = window.Width;
   wh = window.Height;
   reset();
}

function on_paint(gr) {
   gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
  
   if (g_need_calc) {
       calc();
   } else {
       gr.GdiDrawText(g_text, g_font, g_textcolor, 0, g_offset, ww, wh - g_offset, DT_CENTER | DT_WORDBREAK | DT_NOPREFIX);
   }
}

function on_mouse_lbtn_down(x, y) {
   g_drag = true;
   g_drag_y = y;
}

function on_mouse_lbtn_up(x, y) {
   g_drag = false;
}

function on_mouse_move(x, y) {
   if (g_drag) {
       applyDelta(y - g_drag_y);
       g_drag_y = y;
   }
}

function on_mouse_wheel(step) {
   applyDelta(step * 20);
}

function calc() {
   // Using a temp IGdiGraphics interface
   var temp_bmp = gdi.CreateImage(1, 1);
   var temp_gr = temp_bmp.GetGraphics();
  
   // Calculate
   arr = temp_gr.GdiDrawText(g_text, g_font, g_textcolor, 0, 0, ww, wh, DT_VCENTER | DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX).toArray();
   g_textheight = arr[3] - arr[1];
   g_offset = wh / 2;
   g_need_calc = false;
  
   // Free the resources
   temp_bmp.ReleaseGraphics(temp_gr);
   temp_bmp.Dispose();
   temp_gr = null;
   temp_bmp = null;
   window.Repaint();
}

function applyDelta(delta) {
   var temp = g_offset + delta;
  
   if ((temp <= wh / 2) && (temp >= wh / 2 - g_textheight)) {
       g_offset = temp;
       window.Repaint();
   }
}

function reset() {
   g_need_calc = true;
   g_offset = 0;
}

  • Last Edit: 20 January, 2010, 06:10:58 AM by T.P Wang

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #43
It s faster than with the other method. I like it a lot.
Using it right now.

  • saivert
  • [*][*][*]
WSH Panel Mod script discussion/help
Reply #44
MediaInfo panel

Grab script: http://pastie.org/787344

Screenshot:


Requires:
MediaInfo CLI version

Notes:
Using the WshShell.Exec to grab output from a console application via STDOUT will throw up a console window for a fraction of a second. This is ugly so we have get the output from MediaInfo in a different manner. Instead I use WshShell.Run to run my app via CMD so I can redirect output to a text file and then read this text file back to a variable. This is a roundabout way because WshShell.Exec is badly implemented (should have hidden the console window).

Code: [Select]
function get_mediainfo() {
    if (!g_metadb) return;
    
    var tmp = fb.ProfilePath+"tmp.txt";
    //if (fso.FileExists(tmp)) fso.DeleteFile(tmp); // permission denied?
    var e = "cmd /C \"\"" + mediainfo_path + "\" \"" + g_metadb.Path + "\">\""+tmp+"\"\""; // Mind the quotes!
    //fb.trace(e);
    
    wsh.Run(e, 0, true); // Run hidden and wait for it

    var text = fso.OpenTextFile(tmp, 1, false);
    g_text = text.ReadAll();

}
  • Last Edit: 20 January, 2010, 05:57:29 PM by saivert
http://foobar2000.saivert.com - foobar2000 component repository

  • tedgo
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #45
I create a simple lyrics panel and have one question about how to remove the timestamps.

For now i use:
replace(/\[\d+:\d+.\d+\]/g,"")

This removes the timestamps, but not the info parts at the beginning of such timestamped lyrics files.
Has anybody an idea how i can remove all "squared brackets" parts?
So [ar:Peter Gabriel] and [01:56.32] for instance will be removed completely?
Is there any "wildcard" in jscript so i could use something like: replace(/\[*\]/g,"")
Thanks.

  • fbuser
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod script discussion/help
Reply #46
Try replace(/\[.*\]/g,"")

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #47
Code: [Select]
replace(/\[.+\]/g,"")


maybe?

  • tedgo
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #48
Thanks
I knew it must be something easy...

Seems to work both.
Where are the differences?

EDIT: Nevermind, i found it. Thanks again
  • Last Edit: 21 January, 2010, 04:13:59 PM by tedgo

  • TomBarlow
  • [*][*][*][*][*]
WSH Panel Mod script discussion/help
Reply #49
Hi guys, I am currently trying to make some buttons that act more like the main menu, that is, you click once to open the menu and click again to close it. The problem is my buttons at the moment only open the menu. I can't figure out how to stop it from opening in a way that doesn't break it. Here is a simplified script , the red rectangle is the button to open the menu:

Code: [Select]
var colour = 0xffff0000;
var menu_on = false;

function menu()
{
var basemenu = window.CreatePopupMenu();
basemenu.AppendMenuItem(0x00000000, 1, "Hi");
  
menu_on = true;
ret = basemenu.TrackPopupMenu(20, 60);
  menu_on = false;
  
if(ret) fb.trace("Hello there");
  
basemenu.Dispose();
}

function on_paint(gr)
{
gr.FillSolidRect(0,0,window.Width,window.Height,0xffffffff);
gr.FillSolidRect(20,20,40,40,colour);
}

function on_mouse_lbtn_down(x,y)
{
   if(x>=20 && x<=60 && y>=20 && y<=60)
       colour = 0xff0000ff;

   window.Repaint();
}

function on_mouse_move(x, y)
{
if(x>=20 && x<=60 && y>=20 && y<=60)
colour = 0xff00ff00;
else
colour = 0xffff0000;
      
window.Repaint();
}

function on_mouse_lbtn_up(x, y)
{
   if(x>=20 && x<=60 && y>=20 && y<=60)
{
       menu();
       colour = 0xff00ff00;
   }
window.Repaint();
}

function on_mouse_leave()
{
if(!menu_on)
colour = 0xffff0000;
window.Repaint();
}
If anyone could suggest anything I'd really appreciate it