IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Seekbar with Dynamic text?
wy2sl0
post Feb 13 2013, 02:29
Post #1





Group: Members
Posts: 4
Joined: 13-February 13
Member No.: 106601



Hi there, sorry if this is in the wrong spot. I have been working on trying to find this answer searching for a few days now, but I can't find the code for it.

I use foobar for the frontend in my Car PC, so screen real estate at 800x480 is a premium. I am trying to make a seekbar that is like semi transparent like this gentlemen has done http://macarych.deviantart.com/art/foobar2...audio-332543558

I couldn't find out how to do it though. I just want %artist% and %title% to be displayed in the seekbar. Any help would be immensely appreciated, thank you.

This post has been edited by wy2sl0: Feb 13 2013, 02:30
Go to the top of the page
+Quote Post
ojdo
post Feb 13 2013, 10:38
Post #2





Group: Members
Posts: 894
Joined: 18-June 06
From: Germany
Member No.: 31980



Such panels can be realised with WSH Panel Mod. The download includes several examples. I take the liberty to link you to my collection of panel scripts. Another good ressource is the thread WSH Panel Mod script discussion/help in this forum.


--------------------
http://freemusi.cc/
Go to the top of the page
+Quote Post
EpicForever
post Feb 13 2013, 17:13
Post #3





Group: Members
Posts: 717
Joined: 14-September 11
From: Szczecin, PL
Member No.: 93712



Just look on that page - there's link to whole configuration (on the rigt side of the screen):

" Download File
ZIP download, 7.5 MB "

Here's the link:

http://www.deviantart.com/download/3325435...ych-d5hzk92.zip
Go to the top of the page
+Quote Post
wy2sl0
post Feb 13 2013, 20:35
Post #4





Group: Members
Posts: 4
Joined: 13-February 13
Member No.: 106601



QUOTE (EpicForever @ Feb 13 2013, 18:13) *
Just look on that page - there's link to whole configuration (on the rigt side of the screen):

" Download File
ZIP download, 7.5 MB "

Here's the link:

http://www.deviantart.com/download/3325435...ych-d5hzk92.zip

Yeah I did, I went through it. The gentleman is using a background that has the information on it (which I can't find the code for) and then he supercedes that information with a transparent seekbar. I don't know how to do that :-S
Go to the top of the page
+Quote Post
wy2sl0
post Feb 14 2013, 19:51
Post #5





Group: Members
Posts: 4
Joined: 13-February 13
Member No.: 106601



Got it working.



Thanks for everyone's help.

This post has been edited by wy2sl0: Feb 14 2013, 19:56
Go to the top of the page
+Quote Post
db1989
post Feb 14 2013, 19:53
Post #6





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



Good to hear! But its always nice to explain how, in case anyone else reads this in the future; Im sure youd have been glad if someone had already explained it. wink.gif
Go to the top of the page
+Quote Post
wy2sl0
post Feb 14 2013, 20:56
Post #7





Group: Members
Posts: 4
Joined: 13-February 13
Member No.: 106601



Absolutely!

Ok so for the Seekbar with track information, here is the code. In Bold [edited to green so it shows better tongue.gif] is colour adjustment, and text adjustment
CODE
var DT_CENTER = 0x00000001;

DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;

var g_font = gdi.Font("Segoe UI", 15, 0);
var g_drag = 0;
var g_bar_height = 15;
var g_cycles = 0;
var ww = 0,
wh = 0;
var top = 0;
var g_pos = 0;
var g_drag_seek = 0;
var g_timer, txt;

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

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

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, RGB(240,240,240));
gr.FillSolidRect(0, 0, ww, wh+2, RGB(67,90,203));

if(fb.IsPlaying) {
if(fb.PlaybackLength > 0) {
if(g_drag){
t = fb.PlaybackLength * g_drag_seek;
h = Math.floor(t/3600)
m = Math.floor((t-=h*3600)/60);
s = Math.floor(t-=m*60);
pos = ww * g_drag_seek;
txt = (h > 0 ? h + ":" + (m <10 ? "0" + m : m) : m) + ":" + (s < 10 ? "0" + s : s) + " / " + length;
} else {
pos = ww * (fb.PlaybackTime / fb.PlaybackLength);
txt = fb.IsPaused ? "Paused" : fb.titleformat("%artist% - %title%").Eval();
}
gr.FillSolidRect(0, 0, pos, wh+2, RGB(0,44,190));
} else if(fb.PlaybackTime > 0.1) {
txt = fb.IsPaused ? "Paused" : fb.titleformat("%playback_time%").Eval() + " /LIVE";
}
gr.GdiDrawtext(txt, g_font, RGB(255,255,255), 0, 3, ww-8, wh, DT_CENTER | DT_CALCRECT | DT_NOPREFIX);
}
gr.FillSolidRect(0, 0, ww, 0, RGB(50,52,133));
}

function on_mouse_lbtn_down(x,y){
if(fb.IsPlaying && fb.PlaybackLength > 0) g_drag = 1;
}

function on_mouse_lbtn_up(x,y){
if(g_drag) {
g_drag = 0;
g_drag_seek = x < 0 ? 0 : x > window.Width ? 1 : x / window.Width;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
}
}

function on_mouse_move(x,y){
if(y > wh) g_drag = 0;
if(g_drag) {
g_drag_seek = x < 0 ? 0 : x > window.Width ? 1 : x / window.Width;
window.Repaint();
}
}

function on_playback_new_track() {
length = fb.TitleFormat("%length%").Eval();
g_timer = window.CreateTimerInterval(100);
}

function on_playback_stop() {
if(g_timer) window.KillTimer(g_timer);
window.Repaint();
CollectGarbage();
}

function on_playback_seek(time){
window.Repaint();
}

function on_timer(id){
window.Repaint();
}

function on_mouse_wheel(delta) {
fb.PlaybackTime = fb.PlaybackTime + delta;
}

if(fb.isplaying) on_playback_new_track();

VOLUME BAR
CODE
// vi:set ft=javascript ff=dos ts=4 sts=4 sw=4 et:

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

// gdi.Font is changed, the last parameter is style flags
// FontStyleRegular = 0,
// FontStyleBold = 1,
// FontStyleItalic = 2,
// FontStyleBoldItalic = 3,
// FontStyleUnderline = 4,
// FontStyleStrikeout = 8
// Here is 0, means FontStyleRegular
var g_font = gdi.Font("Segoe UI", 15, 0);
var g_drag = 0;


function on_paint(gr) {
gr.SetTextRenderingHint(5);
var ww = window.Width;
var wh = window.Height;
var volume = fb.Volume;
var pos = window.Width * ((100 + volume) / 100);
var txt = (Math.ceil(volume)) + (" dB");
gr.FillSolidRect(0, 0, ww, wh+2, RGB(0,44,190))
gr.FillSolidRect (pos, 0, ww - pos, wh, RGB(67,90,203));
gr.DrawString(txt, g_font, RGB(255, 255, 255), 0, 0, ww, wh, 0x11005000);

}

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

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

function on_mouse_move(x, y) {
if (g_drag) {
var v = x / window.Width;
v = (v < 0) ? 0 : (v < 1) ? v : 1;
v = -100 * (1 - v);
if (fb.Volume != v) fb.Volume = v;
}
}

function on_mouse_wheel(delta) {
if (delta > 0) fb.VolumeUp();
else fb.VolumeDown();
}

function on_volume_change(val) {
window.Repaint();
}


This post has been edited by db1989: Feb 14 2013, 22:58
Go to the top of the page
+Quote Post
carpman
post Feb 14 2013, 22:23
Post #8





Group: Developer
Posts: 1334
Joined: 27-June 07
Member No.: 44789



My spider senses foresee a coming codebox edit. tongue.gif

C.


--------------------
TAK -p4m :: LossyWAV -q 6 | TAK :: Lame 3.98 -V 2
Go to the top of the page
+Quote Post
db1989
post Feb 14 2013, 22:59
Post #9





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



I was going to, but then I remembered that codeboxes don’t support formatting, so I didn’t, but then I remembered that I had misremembered, so I did. laugh.gif

Thanks for posting the code. Someone may find it useful!

This post has been edited by db1989: Feb 14 2013, 23:00
Go to the top of the page
+Quote Post
carpman
post Feb 15 2013, 10:14
Post #10





Group: Developer
Posts: 1334
Joined: 27-June 07
Member No.: 44789



QUOTE (db1989 @ Feb 14 2013, 21:59) *
Thanks for posting the code. Someone may find it useful!

Someone has found it useful. biggrin.gif

Thanks wy2sl0.

C.


--------------------
TAK -p4m :: LossyWAV -q 6 | TAK :: Lame 3.98 -V 2
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 28th November 2014 - 04:33