@marc2003
I tried to to build a now playing script with with last fm play count sync button
I added the relevant function calls separately
But when i add ps.metadb_changed(); in function on_metadb_changed() methored i got this error:
Error: WSH Panel Mod (Thumbs by marc2003): Microsoft JScript runtime error:
'ps' is null or not an object
File: <main>
Ln: 148, Col: 5
<source text only available at compile time>
This is my full script:
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common8.js"
// @name "Thumbs"
// @author "marc2003"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
//the track info section displays 3 lines of title formatted text. you can customise that here/////////////////////////////////////////////
var line1 = {
text: "", //leave this blank
tf: "%artist%", //enter any title formatting
font: gdi.Font("Segoe UI", 36, 1), //font name, size, style. 1 means bold and 0 is normal.
colour: RGB(240, 240, 240), //colour
y: 0 //change this value to move text up or down.
}
var line2 = {
text: "",
tf: "%title%",
font: gdi.Font("Segoe UI", 28, 1),
colour: RGB(210, 210, 210),
y: 38
}
var line3 = {
text: "",
tf: "[%album%]",
font: gdi.Font("Segoe UI", 20, 1),
colour: RGB(180, 180, 180),
y: 70
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var p = new panel("Thumbs", ["metadb", "remap", "custom_background"]);
window.SetProperty("2k3.musicbrainz_releases", false);
var li = new list("musicbrainz", 0, 0, 0, 0);
var th = new thumbs();
var r = new rating(0, 4, 24);
var bt = new buttons("playback");
var b = new buttons();
var bs = 32; //button size
var c = new cd(0, 0, p.w, p.h);
p.item_focus_change();
var l = new lastfm();
//function takes 3 values: x, y, size. see on_size function if you want to update these relative to panel width/height
var ps = new playcount_sync(3, 0, 32);
if (fb.IsPlaying) ps.playback_new_track();
else if (p.metadb) p.item_focus_change();
else ps.update_button();
bt.update = function() {
bt.buttons = {
stop: new button((p.w - bs*6) , p.h-bs*3, bs, bs, {normal: this.images.stop}, function() { fb.Stop(); }, "Stop"),
play: new button((p.w - bs*6)+bs, p.h-bs*3, bs, bs, {normal: !fb.IsPlaying || fb.IsPaused ? this.images.play : this.images.pause}, function() { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause"),
previous: new button((p.w - bs*6)+bs * 2, p.h-bs*3, bs, bs, {normal: this.images.previous}, function() { fb.Prev(); }, "Previous"),
next: new button((p.w - bs*6)+bs * 3, p.h-bs*3, bs, bs, {normal: this.images.next}, function() { fb.Next(); }, "Next")
}
window.Repaint();
}
bt.update();
function on_playback_time() {
ps.playback_time();
}
function on_playback_time(time) {
th.playback_time(time);
}
function on_size() {
p.size();
pos_x = 0;
pos_y = p.h-15;
th.size();
bt.update();
r.x = p.w - 125;
r.y = p.h - 25;
c.w = 200;
c.h = 200;
c.x=0;
c.y=p.h-200;
ps.x = p.w - 220;
ps.y = p.h - 95;
ps.update_button();
}
function on_paint(gr) {
p.draw_background(gr);
th.draw(gr);
r.draw(gr);
for (var i = 0; i < li.items; i++) {
p.draw_image(gr, li.musicbrainz_images[li.images[i]], pos_x + (i * 20), pos_y, 16, 16);
}
gr.FillSolidRect(0, p.h-150, p.w, 110, RGBA(0, 0, 0, 196));
p.left_text(gr, line1.text, line1.font, line1.colour, 210, p.h-150, 500, line1.font.Height);
p.left_text(gr, line2.text, line2.font, line2.colour, 210, p.h-150+ line2.y, 500, line2.font.Height);
p.left_text(gr, line3.text, line3.font, line3.colour, 210, p.h-150 + line3.y, 500, line3.font.Height);
c.draw(gr);
bt.draw(gr);
b.draw(gr);
}
function on_playback_stop() {
bt.update();
}
function on_playback_pause() {
bt.update();
}
function on_playback_starting() {
bt.update();
}
function on_metadb_changed() {
th.metadb_changed();
r.metadb_changed();
li.metadb_changed();
c.metadb_changed();
line1.text = p.eval(line1.tf);
line2.text = p.eval(line2.tf);
line3.text = p.eval(line3.tf);
ps.metadb_changed();
}
function on_playback_new_track() {
ps.playback_new_track();
}
function on_playback_edited() {
ps.playback_edited();
}
function on_get_album_art_done(metadb, art_id, im, ip) {
c.get_album_art_done(ip);
}
function on_mouse_wheel(step) {
th.wheel(step);
}
function on_mouse_move(x, y) {
p.move(x, y);
th.move(x, y);
bt.move(x, y);
r.move(x,y);
//c.move(x, y);
if (x > pos_x && x < pos_x + (li.items * 20) && y > pos_y && y < pos_y + 20) p.tt(li.urls[Math.floor((x - pos_x) / 20)]);
else p.ttd();
b.move(x, y);
}
function on_mouse_lbtn_up(x, y) {
th.lbtn_up(x, y);
r.lbtn_up(x,y);
bt.lbtn_up(x, y);
if (x > pos_x && x < pos_x + (li.items * 20) && y > pos_y && y < pos_y + 20) p.browser(li.urls[Math.floor((x - pos_x) / 20)]);
b.lbtn_up(x, y);
}
function on_mouse_lbtn_dblclk(x, y) {
th.lbtn_dblclk(x, y);
r.lbtn_dblclk(x, y);
c.lbtn_dblclk(x, y);
}