Подскажите как исправить данную проблему? раньше при перезапуске плеера это окошко восстанавливалось, теперь уже постоянная ошибка.
Windows 10 Pro x64. S8e (foobar v1.3.10).
Скрин
- Спойлер
JScript
- Спойлер
- // Maxim Terpilovsky's script
// Track Info Panel
// Updated 26-03-2013
// ==PREPROCESSOR==
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
var string_height, string_number, min_width, column_number, max_elements, rating_view, btns_ready, updated;
var Buttons = [];
var btn;
var hover_button = null;
MF_STRING = 0x00000000;
DT_TOP = 0x00000000;
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_VCENTER = 0x00000004;
DT_BOTTOM = 0x00000008;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
DT_EDITCONTROL = 0x00002000;
DT_END_ELLIPSIS = 0x00008000;
try { var folder = gdi.Image(fb.FoobarPath + "s7e_files\\images\\big_folder.png"); }
catch(e) {var folder = false; }
try { var empty_selection = gdi.Image(fb.FoobarPath + "s7e_files\\images\\empty_selection.png"); }
catch(e) {var empty_selection = false; }
try { var checked_star = gdi.Image(fb.FoobarPath + "s7e_files\\images\\star.png"); }
catch(e) { var checked_star = false;}
try { var empty_star = gdi.Image(fb.FoobarPath + "s7e_files\\images\\star_grey.png"); }
catch(e) { var empty_star = false;}
if ( utils.CheckFont( "Segoe UI" ) ) {
var font = gdi.Font("Segoe UI", 12, 0);
var font_p1 = gdi.Font("Segoe UI", 13, 0);
var font_p1_under = gdi.Font("Segoe UI", 13, 4);
var font_big = gdi.Font("Segoe UI", 80, 1);
var font_bold = gdi.Font("Segoe UI", 12, 1);
var font_under = gdi.Font("Segoe UI", 12, 4);
} else {
var font = gdi.Font("Tahoma", 11, 0);
var font_p1 = gdi.Font("Tahoma", 12, 0);
var font_p1_under = gdi.Font("Tahoma", 11, 4);
var font_big = gdi.Font("Segoe UI", 80, 1);
var font_bold = gdi.Font("Tahoma", 11, 1);
var font_under = gdi.Font("Tahoma", 11, 4);
}
fso = new ActiveXObject("Scripting.FileSystemObject");
ini_tag_write = parseInt( utils.ReadINI(fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'write-rating-to-tag', 0) );
mode = parseInt( utils.ReadINI(fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'track-info-mode', 1) );
rects = parseInt( utils.ReadINI(fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'rectangular-backs', 0) );
valign = parseInt( utils.ReadINI(fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'vertical-align', 0) );
show_cover_instead = parseInt( utils.ReadINI(fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'show-cover-instead', 0) );
function RGBA(r, g, b, a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
function RGB(r, g, b) { return (0xff000000 | (r << 16) | (g << 8) | (b)); }
function TimeFmt(t){
var zpad = function(n){
var str = n.toString();
return (str.length<2) ? "0"+str : str;
}
var h = Math.floor(t/3600); t-=h*3600;
var m = Math.floor(t/60); t-=m*60;
var s = Math.floor(t);
if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
return m.toString()+":"+zpad(s);
}
function isArray(input){
return typeof(input)=='object'&&(input instanceof Array);
}
unique = function(arr) {
var o = {}, i, l = arr.length, r = [];
for(i=0; i<l;i+=1) o[arr[i]] = arr[i];
for(i in o) r.push(o[i]);
return r;
};
max = function(arr) {
return Math.max.apply(null, arr)
}
min = function(arr) {
return Math.min.apply(null, arr)
}
indexOf = function(value, arr, start) {
var i;
if (!start) {
start = 0;
}
for(i=start; i<arr.length; i++) {
if(arr[i] == value) {
return i;
}
}
return -1;
}
function trim(string)
{
return string.replace(/(^\s+)|(\s+$)/g, "");
}
function calculate_dims() {
string_height = font.Height + 5;
string_number = Math.floor( window.Height / string_height );
min_width = 200;
column_number = Math.floor( ( window.Width - window.Height - 6 ) / min_width );
max_elements = column_number * string_number;
//fb.trace('max_elements ' + max_elements);
}
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += " ";
if(typeof(arr) == 'object') { //Array/Hashes/Objects
for(var item in arr) {
var value = arr[item];
if(typeof(value) == 'object') { //If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
dumped_text += dump(value,level+1);
} else {
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
} else { //Stings/Chars/Numbers etc.
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}
function Button(x, y, w, h, label_size, update, name, hover, func) {
this.name = name;
this.func = func;
this.hover = hover;
this.update = update;
this.traceMouse = function(x, y) {
var b = (this.left <= x) && (x <= this.right) && (this.top <= y) && (y <= this.bottom);
return b;
};
this.onHover = function( x, y) {
this.hover && this.hover( x, y, this.left, this.label_size );
};
this.onClick = function( x, y ) {
this.func && this.func( x, y, this.left, this.label_size );
};
}
function ClearButtonCoords() {
for ( var n=Buttons.length; n--; ) {
Buttons[n].x = 0;
Buttons[n].y = 0;
Buttons[n].w = 0;
Buttons[n].h = 0;
Buttons[n].left = 0;
Buttons[n].top = 0;
Buttons[n].right = 0;
Buttons[n].bottom = 0;
Buttons[n].label_size = 0;
}
}
function OnFilename() { window.SetCursor(32649); }
function Filename() {
try { fb.RunMainMenuCommand('View/Columns playlist/Activate now playing' ); }
catch(e) { }
}
function OnTitle() { window.SetCursor(32649); }
function Title() {
try { fb.RunContextCommandWithMetadb('Tagging/Discogs/Write Tags...', ItemInfo.CachedMetadb ); }
catch(e) { }
}
function OnTags() { window.SetCursor(32649); }
function Tags() {
try { fb.RunContextCommandWithMetadb('Tagging/MP3 tag types...', ItemInfo.CachedMetadb ); }
catch(e) { }
}
function OnCue() { window.SetCursor(32649); }
function Cue() {
try { fb.RunContextCommandWithMetadb('Utilities/Edit cuesheet', ItemInfo.CachedMetadb ); }
catch(e) { }
}
function OnArtist() { window.SetCursor(32649); }
function Artist() {
try { fb.RunContextCommandWithMetadb('Quicksearch for same/Artist', ItemInfo.OutputMetadb(true) ); }
catch(e) { }
}
function OnAlbum() { window.SetCursor(32649); }
function Album() {
try { fb.RunContextCommandWithMetadb('Quicksearch for same/Album', ItemInfo.OutputMetadb(true) ); }
catch(e) { }
}
function OnPath() { window.SetCursor(32649); }
function Path() {
try { fb.RunContextCommandWithMetadb('Open containing folder', ItemInfo.OutputMetadb(true) ); }
catch(e) { }
}
function ViewRating(x, y, left, label_size) {
var meta = ItemInfo.OutputMetadb();
if ( meta ) {
x -= left + label_size;
if ( x < 90 && x > 0 ) {
rating_view = Math.min(5,Math.floor( x / (90/5) ) + 1);
window.SetCursor(32649);
}
else {
rating_view = 0;
window.SetCursor( 32512 );
}
}
}
GetRating = function() {
var meta = ItemInfo.OutputMetadb();
if ( meta ) {
if ( meta.Count != null ) {
rating = 0;
for ( i = 0; i < meta.Count; i++ ) {
var item = meta.Item( i );
rating += parseInt( fb.TitleFormat("$if3(%rating%,%rating_sql%,0)").EvalWithMetadb( item ) );
}
rating = rating / meta.Count;
}
else if ( meta ) {
//fb.trace( meta.Path );
rating = fb.TitleFormat("$if3(%rating%,%rating_sql%,0)").EvalWithMetadb( meta );
if ( isNaN ( rating ) ) rating = 0;
}
return rating;
}
}
function SetRating(x, y, left, label_size) {
x -= left + label_size;
//fb.trace(x+ y+ left+ label_size);
if ( x < 90 && x > 0 ) {
var rating_current = GetRating();
rating_view = Math.min(5, Math.floor( x / (90/5) ) + 1);
if ( rating_current == rating_view ) rating_view = 0;
meta = ItemInfo.OutputMetadb();
if ( meta ) {
if ( utils.CheckComponent("foo_customdb", true) ) {
fb.RunContextCommandWithMetadb("Legacy Commands (unsorted)/Set Rating " + rating_view, meta);
ItemInfo.Update();
}
else if ( utils.CheckComponent("foo_playcount", true) ) {
fb.RunContextCommandWithMetadb("Playback Statistics/Rating/" + (rating_view == 0 ? '<not set>' : rating_view), meta);
ItemInfo.Update();
}
else {
if ( ini_tag_write == 1 ) {
if ( meta.Count != null ) {
for ( i = 0; i < meta.Count; i++ ) {
var item = meta.Item( i );
item.UpdateFileInfoSimple('Rating', rating_view);
}
}
else {
meta.UpdateFileInfoSimple('Rating', rating_view);
}
ItemInfo.Update();
}
}
}
rating_view = 0;
}
}
buttons = {
filename: new Button(0,0,0,0,0,0, "Filename", OnFilename, Filename ),
codec: new Button(0,0,0,0,0,0, "Codec", false, false ),
artist: new Button(0,0,0,0,0,0, "Artist", OnArtist, Artist ),
album: new Button(0,0,0,0,0,0, "Album", OnAlbum, Album ),
title: new Button(0,0,0,0,0,0, "Title", OnTitle, Title ),
date: new Button(0,0,0,0,0,0, "Date", false, false ),
rating: new Button(0,0,0,0,0,1, "Rating", ViewRating, SetRating ),
played: new Button(0,0,0,0,0,0, "Played", false, false ),
genre: new Button(0,0,0,0,0,0, "Genre", false, false ),
filesize: new Button(0,0,0,0,0,0, "File size", false, false ),
duration: new Button(0,0,0,0,0,0, "Duration", false, false ),
firstplayed: new Button(0,0,0,0,0,0, "First played", false, false ),
lastplayed: new Button(0,0,0,0,0,0, "Last played", false, false ),
path: new Button(0,0,0,0,0,0, "Path", OnPath, Path ),
lastmodified: new Button(0,0,0,0,0,0, "Last Modified", false, false ),
cuesheet: new Button(0,0,0,0,0,0, "Cuesheet", OnCue, Cue ),
tagtype: new Button(0,0,0,0,0,0, "Tag Type", OnTags, Tags )
}
for (var i in buttons ) {
Buttons.push(buttons[i]);
}
function ClearButtonsVars() {
rating_view = 0;
window.SetCursor(32512);
}
// fb.trace( dump(Buttons) );
function inArray(arr, val) {
var i = arr.length;
while (i--) {
if (a[i] === val) return true;
}
return false;
}
function ItemInfo() {
this.Selection = 0;
this.ButtonsReady = 0;
this.Info = false;
this.Labels = false;
this.CachedMetadb = undefined;
this.Extension = '';
this.OutputMetadb = function( force ) {
force = force ? force : false;
if ( force ) {
if ( mode == 2 ) return fb.GetFocusItem(true);
else return ( fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem() );
}
else {
//if ( mode == 2 ) return (( fb.GetSelections().Count > 1 && fb.GetSelectionType() ) ? fb.GetSelections() : fb.GetFocusItem(true) );
//else return ( fb.IsPlaying ? ( ( fb.GetSelections().Count > 1 && fb.GetSelectionType() ) ? fb.GetSelections() : fb.GetNowPlaying() ) : ( fb.GetFocusItem() && fb.GetSelectionType() && fb.GetSelections().Count > 1 ? fb.GetSelections() : (fb.GetFocusItem() ? fb.GetFocusItem() : false) ));
if ( mode == 2 ) return (( fb.GetSelections().Count > 1 ) ? fb.GetSelections() : fb.GetFocusItem(true) );
else return ( fb.IsPlaying ? ( ( fb.GetSelections().Count > 1 ) ? fb.GetSelections() : fb.GetNowPlaying() ) : ( fb.GetSelections().Count > 1 ? fb.GetSelections() : (fb.GetFocusItem(true) ? fb.GetFocusItem(true) : false) ));
}
}
this.GetInfo = function( metadb ) {
//fb.trace('GetInfo called');
if ( metadb ) {
labels = [];
general = [];
if ( metadb.Count != null && metadb.Count > 0 ) {
//d = new Date();
//t = d.getTime();
// Constant values
//var first_played = '(multiple values)';
//var last_played = '(multiple values)';
//var last_modified = '(multiple values)';
this.Extension = [];
var count = metadb.Count;
if ( count > 100 ) {
var rating = false;
var playcount = false;
}
else {
var rating = 0;
var playcount = new Number();
}
var duration = 0;
var filesize = 0;
var bitrate = 0;
var date_max = 0;
var date_min = 10000;
var filename = '';
var path = false;
var artist = [];
var album = [];
var codec = [];
var genre = [];
var style = [];
var cue_embedded = [];
var tagtype = [];
var extensions = [];
//this.Extension = new Array('fpl', 'fpl');
var title = count + ' titles';
function iterate( item ) {
var info = item.GetFileInfo();
var artist_current = info.MetaValue( info.MetaFind('artist'), 0);
if ( artist_current ) artist.push( artist_current );
var album_current = info.MetaValue( info.MetaFind('album'), 0);
if ( album_current ) album.push( album_current );
var codec_current = info.InfoValue( info.InfoFind('codec') );
if ( codec_current ) codec.push( codec_current );
var style_current = fb.Titleformat("[%style%]").EvalWithMetadb(item);
if ( style_current ) style.push( style_current );
var genre_current = fb.Titleformat("[%genre%]").EvalWithMetadb(item);
if ( genre_current ) genre.push( genre_current );
var date_current = parseInt( info.MetaValue( info.MetaFind('date'), 0) );
if ( date_current && date_current > date_max ) date_max = date_current;
if ( date_current && date_current < date_min ) date_min = date_current;
var tagtype_current = fb.Titleformat("[%__tagtype%]").EvalWithMetadb(item);
tagtype_current = tagtype_current.toUpperCase();
tagtype_current = tagtype_current.replace(/\|/g,',');
if ( tagtype_current ) tagtype.push( tagtype_current );
var cue_current = info.InfoValue( info.InfoFind('cue_embedded') );
if ( cue_current ) cue_embedded.push( cue_current );
var bit_cur = info.InfoValue( info.InfoFind('bitrate' ) );
bitrate += bit_cur ? parseInt( bit_cur ) : 0;
if ( rating !== false ) rating += parseInt( fb.TitleFormat("$if3(%rating%,%rating_sql%,0)").EvalWithMetadb( item ) );
if ( playcount ) playcount += parseInt( fb.TitleFormat("$if3($meta(play_count),%play_count%,%play_count_sql%,0)").EvalWithMetadb( item ) );
var dur_cur = item.Length;
duration += parseInt( dur_cur );
filesize += bit_cur / 8 * 1024 * dur_cur;
extensions.push( item.RawPath.replace(/.*\.(\w+)$/,"$1") );
}
function duff(iterations) {
var i = iterations % 8;
var n = 0;
if( i>0 ) {
do {
var item = metadb.Item( n++ );
iterate(item);
}
while(--i);
}
i = parseInt( iterations / 8 );
if( i>0 ) {
do {
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
var item = metadb.Item( n++ );
iterate(item);
}
while(--i);
}
}
duff( metadb.Count );
if ( duration > 86400 ) {
x = duration;
seconds = parseInt( x % 60 );
x /= 60;
minutes = parseInt( x % 60 );
x /= 60;
hours = parseInt( x % 24 );
x /= 24;
days = parseInt( x );
seconds += seconds > 1 ? ' seconds ' : ' second ';
minutes += minutes > 1 ? ' minutes ' : ' minute ';
hours += hours > 1 ? ' hours ' : ' hour ';
days += days > 1 ? ' days ' : ' day ';
duration = days + hours + minutes + seconds;
}
else {
duration = TimeFmt(duration);
}
//fb.trace(rating);
if ( rating ) rating = rating / metadb.Count;
if ( playcount ) playcount = Math.round(playcount / metadb.Count);
bitrate = Math.round(bitrate / metadb.Count);
//fb.trace( 'playcount==' + playcount );
if ( filesize >= 1073741824 ) filesize = Math.round(filesize / 1073741824 * 100)/100 + "GB";
else if ( filesize >= 1048576 ) filesize = Math.round(filesize / 1048576 * 100)/100 + "MB";
else if ( filesize >= 1024 ) filesize = Math.round(filesize / 1024 * 100)/100 + "KB";
else filesize += 'B';
artist = unique(artist);
if ( artist.length > 2 ) artist = artist.length + ' artists';
else {
artist = artist.join(", ");
}
album = unique(album);
if ( album.length > 2 ) album = album.length + ' albums';
else {
album = album.join(", ");
}
codec = unique(codec);
if ( codec.length > 2 ) codec = codec.length + ' codecs';
else {
codec = codec.join(", ");
}
codec = '≈ ' + bitrate + ' kbps, ' + codec;
if ( genre.length > 1 ) {
genre = genre.join(',');
genre = genre.replace(/\&\//g,',');
genre = genre.split(',');
genre = unique(genre);
}
if ( style.length > 1) {
style = style.join(',');
style = style.split(',');
style = unique(style);
}
if ( style.length > 2 ) style = style.length + ' styles';
else {
style.sort();
style = style.join(", ");
}
if ( genre.length > 2 ) genre = genre.length + ' genres';
else {
genre.sort();
genre = genre.join(", ");
}
if ( style && genre ) genre += ' / ' + style;
var date = date_min != date_max ? (date_min != 10000 ? (date_min + '…') : '') + (date_max ? date_max : '') : date_max;
tagtype = tagtype.join(',');
tagtype = tagtype.split(',');
tagtype = unique(tagtype);
tagtype.sort();
tagtype = tagtype.join(', ');
cue_embedded = unique(cue_embedded);
cue_embedded = cue_embedded.length > 1 ? 'Yes, partly' : cue_embedded[0];
filename = 'Selection (' + metadb.Count + ' items)';
this.Extension = unique(extensions);
if ( filename ) { general.push(filename); labels.push("Filename");}
if ( codec ) { general.push(codec); labels.push("Codec");}
if ( artist ) { general.push(artist); labels.push("Artist");}
if ( album ) { general.push(album); labels.push("Album");}
if ( title ) { general.push(title); labels.push("Title");}
if ( date ) { general.push(date); labels.push("Date");}
if ( genre ) { general.push(genre); labels.push("Genre");}
if ( typeof rating == 'number' ) { general.push(rating); labels.push("Rating"); }
if ( playcount ) {
playcount = ( playcount > 1 ? '≈ ' + playcount + ' times played each' : playcount > 0 ? 'Each once played' : 'Never played');
general.push(playcount);
labels.push("Played");
}
if ( filesize ) { general.push(filesize ); labels.push("File size");}
if ( duration ) { general.push(duration); labels.push("Duration");}
if ( cue_embedded ) { general.push(cue_embedded ); labels.push("Cuesheet");}
if ( tagtype ) { general.push(tagtype); labels.push("Tag Type");}
this.Info = general.join("|||");
this.Labels = labels.join("\n");
//fb.trace(rating);
//d = new Date();
//t2 = d.getTime();
//fb.trace( (t2 - t) + ' ms');
}
else {
//d = new Date();
//t = d.getTime();
//fb.trace('this.GetInfo else called');
this.Extension = '';
this.Extension = fb.Titleformat("$ext(%filename_ext%)").EvalWithMetadb(metadb);
var filename = fb.Titleformat("[%filename_ext%]").EvalWithMetadb(metadb);
var artist = fb.Titleformat("[%album artist%][ / %track artist%]").EvalWithMetadb(metadb);
var codec = fb.Titleformat("[$codec()][', '%codec_profile%][', '$info(bitrate) kbps][', '%samplerate% Hz][ '('$info(tool2)')']").EvalWithMetadb(metadb);
var album = fb.Titleformat("[%album%]").EvalWithMetadb(metadb);
var title = fb.Titleformat("[$meta(title)]").EvalWithMetadb(metadb);
var date = fb.Titleformat("[%date%]").EvalWithMetadb(metadb);
var rating = fb.Titleformat("$if3(%rating%,%rating_sql%,0)").EvalWithMetadb(metadb);
var play_count = fb.Titleformat("$if3(%play_count%,%play_count_sql%,)").EvalWithMetadb(metadb);
var genre = fb.Titleformat("[%genre%]").EvalWithMetadb(metadb);
var style = fb.Titleformat("[%style%]").EvalWithMetadb(metadb);
if ( genre && style ) genre += ' / ' + style;
var filesize = fb.Titleformat("$if($strcmp($info(cue_embedded),yes),$div($mul($div($info(bitrate),8),%length_seconds%),1024) MB / )[%filesize_natural%]").EvalWithMetadb(metadb);
var duration = fb.Titleformat("[%length%]").EvalWithMetadb(metadb);
var first_played = fb.Titleformat("$if3(%first_played%,%first_played_sql%,)").EvalWithMetadb(metadb);
var last_played = fb.Titleformat("$if3(%last_played%,%last_played_sql%,)").EvalWithMetadb(metadb);
var path = fb.Titleformat("$replace(%path%,%filename_ext%,)").EvalWithMetadb(metadb);
var last_modified = fb.Titleformat("[%last_modified%]").EvalWithMetadb(metadb);
var cue_embedded = fb.Titleformat("$if2($caps(%__cue_embedded%),No)").EvalWithMetadb(metadb);
var tagtype = fb.Titleformat("[$replace($upper(%__tagtype%),V,v,|,', ')]").EvalWithMetadb(metadb);
if ( filename ) { general.push(filename); labels.push("Filename");}
if ( codec ) { general.push(codec); labels.push("Codec");}
if ( artist ) { general.push(artist); labels.push("Artist");}
if ( album ) { general.push(album); labels.push("Album");}
if ( title ) { general.push(title); labels.push("Title");}
if ( date ) { general.push(date); labels.push("Date");}
if ( genre ) { general.push(genre); labels.push("Genre");}
general.push(rating); labels.push("Rating");
if ( play_count ) {
play_count = ( play_count > 1 ? play_count + ' times played' : play_count > 0 ? 'Once played' : 'Never played');
general.push(play_count);
labels.push("Played");
}
if ( filesize ) { general.push(filesize ); labels.push("File size");}
if ( duration ) { general.push(duration); labels.push("Duration");}
if ( last_played ) { general.push(last_played); labels.push("Last played");}
if ( first_played != first_played )
{ general.push(first_played); labels.push("First played");}
if ( last_modified ) { general.push(last_modified); labels.push("Last Modified");}
if ( path ) { general.push(path); labels.push("Path");}
if ( cue_embedded ) { general.push(cue_embedded ); labels.push("Cuesheet");}
if ( tagtype ) { general.push(tagtype); labels.push("Tag Type");}
this.Info = general.join("|||");
this.Labels = labels.join("\n");
//d = new Date();
//t2 = d.getTime();
//fb.trace( (t2 - t) + ' ms');
}
window.Repaint();
}
else { this.Info = false; this.Labels = false; window.Repaint(); }
}
this.Update = function( metadb ) {
metadb = metadb ? metadb : this.OutputMetadb();
if ( metadb ) {
try { var a = this.CachedMetadb.Path ? this.CachedMetadb.Path : ' '; }
catch(e) { var a = ' '; }
try { var b = metadb.Path ? metadb.Path : ' '; }
catch(e) { var b = ' '; }
try { if ( metadb.Count ) var c = true; }
catch(e) { var c = false; }
//fb.trace( typeof a + typeof b + typeof c);
//fb.trace( a + '/' + b + '/' + c);
if ( a.replace(/(.*)\\(.*)\.(.*)$/,'$1') != b.replace(/(.*)\\(.*)\.(.*)$/,'$1') && !c ) {
utils.GetAlbumArtAsync(window.ID, metadb, 0, false);
this.Cover = false;
}
else if ( c ) this.Cover = false;
this.CachedMetadb = metadb;
this.Info = false;
this.Labels = false;
this.SelectionString = fb.GetSelectionType() + ' ' + fb.GetSelections().Count;
this.Selection = fb.GetSelections().Count;
//fb.trace('Update = ' + this.Selection);
this.ButtonsReady = 0;
ClearButtonCoords();
this.GetInfo( metadb );
}
else {
this.Info = false;
this.Labels = false;
this.CachedMetadb = false;
window.Repaint();
}
}
this.Update();
}
ItemInfo = new ItemInfo();
function on_paint(gr) {
//var start = new Date().getMilliseconds();
//fb.trace( 'on_paint()' );
var ww = window.Width;
var wh = window.Height;
gr.SetTextRenderingHint(7);
gr.SetSmoothingMode(4);
gr.SetInterpolationMode(7);
//gr.FillSolidRect(0,0, ww, wh,RGB(240,245,250));
//gr.FillGradRect(0,-2, ww, 5, 90, RGB(240,245,250), RGB(205,220,235), 0.1);
gr.DrawRect( 0, 0, ww, 1, 1, RGB(218,219,220) );
if ( ItemInfo.Info ) {
var Infos = ItemInfo.Info.split("|||");
var Labels = ItemInfo.Labels.split("\n");
// PLAYED TRICK
var idx = indexOf('Played', Labels);
if(idx!=-1) {
var played = Infos[idx];
Labels.splice(idx, 1);
Infos.splice(idx, 1);
}
else var played = false;
var c = 1;
var s = 1;
var max_label = 0;
var current_label = 0;
var label_widths = [];
if ( valign == 1 ) string_height = wh / string_number;
Labels.splice(max_elements,Labels.length-max_elements)
column_number = Math.ceil( Labels.length / string_number );
var column_width = ( ww - wh ) / column_number;
var a = 0, b = Labels.length;
//for ( a = 0; a < Labels.length; a++ ) {
while ( a<b ) {
var t = a % string_number;
if ( !t ) {
label_widths.push( max_label + 2 );
max_label = 0;
}
current_label = Math.round( gr.MeasureString(Labels[a] + ':', font, 0, 0, ww, 0).Width );
max_label = current_label > max_label ? current_label : max_label;
if ( a + 1 == Labels.length ) {
label_widths.push( max_label + 2 );
max_label = 0;
}
a++;
//fb.trace( Labels[a] + ' / current_label = ' + current_label + ' / max_label = ' + max_label + ' / column_number = ' + column_number );
}
label_widths.splice(0, 1);
c = 1;
s = 1;
try {
if ( ItemInfo.CachedMetadb.Count > 1 ) gr.GdiDrawText( ItemInfo.CachedMetadb.Count, font_big, RGB( 205,220,235), 0, -5, ww-10,wh, DT_RIGHT | DT_VCENTER | DT_CALCRECT);
} catch(e) {}
//label_widths.reverse();
//var a = Labels.length;
for ( a = 0; a < Labels.length; a++ ) {
//while ( a-- ) {
if ( s > string_number && (s % string_number == 1 ) ) { c++; s = 1; }
// LABEL
var current_label_width = (Labels[a] == 'Filename' || Labels[a] == 'Codec' ) ? 0 : label_widths[c-1];
if ( ItemInfo.ButtonsReady == 0 ) {
var n = Buttons.length;
while ( n-- ) {
if ( Buttons[n].name == Labels[a] ) {
Buttons[n].x = (wh ) + ( (c - 1) * column_width);
Buttons[n].y = (wh - string_number * string_height)/2 + (s - 1) * string_height;
Buttons[n].w = column_width;
Buttons[n].h = string_height;
Buttons[n].left = Buttons[n].x;
Buttons[n].top = Buttons[n].y;
Buttons[n].right = Buttons[n].x + column_width;
Buttons[n].bottom = Buttons[n].y + string_height;
Buttons[n].label_size = current_label_width;
} else continue;
}
}
// RECT
if ( rects ) gr.FillRoundRect( wh + ( (c - 1) * column_width), 1 + (wh - string_number * string_height)/2 + (s - 1) * string_height, column_width - 2, string_height - 2, 4, 4, (s % 2 == 0) ? RGBA(225,235,245,100) : RGBA(200,225,235,100));
// LABELS
gr.GdiDrawText( (Labels[a] == 'Filename' || Labels[a] == 'Codec' ) ? '' : Labels[a] + ':', font, RGB( 120,120,120), wh + ( (c - 1) * column_width), ( wh - string_number * string_height)/2 + (s - 1) * string_height, current_label_width, string_height, DT_RIGHT | DT_VCENTER | DT_CALCRECT);
// RATING
if ( Labels[a] == 'Rating' ) {
var rating_rounded = Math.ceil( Infos[a] );
var rating_rest = 1;
try {
var star_w = checked_star.Width;
var star_h = checked_star.Height > string_height ? string_height : checked_star.Width;
}
catch (e) { }
var rating_rest = Number(Infos[a]).toPrecision(3);
rating_rest = "0." + parseInt( rating_rest.replace(/(\d+)\.(\d+)/i,"$2") );
var star_wr = 0;
if ( !rating_view ) limit = rating_rounded;
else limit = rating_view;
//fb.trace( 'rating_rest = ' + rating_rest );
//limit = rating_view > rating_rounded ? rating_view : rating_rounded;
var nc = limit - 1 > -1 ? (rating_view ? limit : limit - 1) : 0;
for ( n = nc; n < 5; n++ ) {
if ( empty_star ) gr.DrawImage( n == nc && !rating_view && rating_rest != 0 ? checked_star : empty_star, wh + 5 + current_label_width + ( (c - 1) * column_width) + n*star_w, (wh - string_number * string_height)/2 + (s - 1) * string_height + (string_height - star_h)/2, star_w, star_h, 0, 0, star_w, star_h, 0, n == nc && !rating_view && rating_rest != 0 ? 100 : 255); // i > rating_view
}
//fb.trace('limit = ' + limit);
for ( i = 0; i < limit; i++ ) {
if ( !rating_view && i == Math.floor(Infos[a]) ) star_wr = rating_rest * star_w;
else star_wr = false;
if ( checked_star ) gr.DrawImage(checked_star, wh + 5 + current_label_width + ( (c - 1) * column_width) + i*star_w, (wh - string_number * string_height)/2 + (s - 1) * string_height + (string_height - star_h)/2, star_wr ? star_wr : star_w, star_h, 0, 0, star_wr ? star_wr : star_w, star_h, 0, 255);
}
if ( played ) {
gr.GdiDrawText( played, font, RGB( 90, 103, 121), wh + 5 + current_label_width + ((c - 1) * column_width) + star_w * 5 + 10, (wh - string_number * string_height)/2 + (s - 1) * string_height, column_width - ( current_label_width + star_w*5 + 15 ), string_height, DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT);
}
}
else {
if ( btn != null ) {
if ( btn.name == Labels[a] && btn.func ) var font_this = (Labels[a] == 'Filename') ? font_p1_under : font_under;
else var font_this = (Labels[a] == 'Filename') ? font_p1 : font;
}
else { var font_this = (Labels[a] == 'Filename') ? font_p1 : font; }
var color = (Labels[a] == 'Codec') ? RGB( 120,120,120) : (Labels[a] == 'Filename') ? RGB( 0, 0, 0) : RGB( 60, 60, 60);
gr.GdiDrawText( Infos[a], font_this, color, wh + 5 + ( Labels[a] ? current_label_width : 0 ) + ((c - 1) * column_width), (wh - string_number * string_height)/2 + (s - 1) * string_height, ( ww - wh ) / column_number - ( Labels[a] ? current_label_width + 5 : 5 ), string_height, DT_NOPREFIX | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS | DT_CALCRECT);
}
s++;
if ( a == max_elements - 1 ) break;
}
// BUTTONS FORMED
ItemInfo.ButtonsReady = 1;
// COVER
if ( ItemInfo.Cover && show_cover_instead ) {
var img = ItemInfo.Cover;
var iw = ItemInfo.Cover.Width;
var ih = ItemInfo.Cover.Height;
var x = (iw < ih) ? ((iw < wh - 10) ? ((wh - iw)/2) : 5 ) : ((iw >= wh - 10) ? 5 : ((wh - iw)/2));
var y = (iw > ih) ? ((ih < wh - 10) ? ((wh - ih)/2) : 5 ) : ((ih >= wh - 10) ? 5 : ((wh - ih)/2));
gr.DrawImage(img, x, y + 1, iw, ih, 0, 0, img.Width, img.Height, 0, 255);
gr.DrawRect( x, y + 1, iw, ih, 1, RGB(200,200,200));
}
else if ( ItemInfo.Extension != undefined ) {
if ( isArray( ItemInfo.Extension ) ) {
ItemInfo.Extension.sort();
var arr = ItemInfo.Extension;
var idx = indexOf('cue', arr);
if(idx!=-1) {
arr.splice(idx, 1);
arr.unshift('cue');
}
ItemInfo.Extension = arr;
if ( ItemInfo.Extension.length == 1 ) {
var max = Math.min(fb.GetSelections().Count,10);
while ( max-- ) {
ItemInfo.Extension.push(ItemInfo.Extension[0]);
}
}
f = ItemInfo.Extension.length;
while ( f-- ) {
var ext = ItemInfo.Extension[f];
ext = ext.toLowerCase();
try {
var icon = ( fso.FileExists( fb.FoobarPath + '\\s7e_files\\formats\\' + ext + '.png' ) ) ? gdi.Image( fb.FoobarPath + '\\s7e_files\\formats\\' + ext + '.png' ) : gdi.Image( fb.FoobarPath + '\\s7e_files\\formats\\generic.png' );
var ih = icon.Height > wh ? ( wh - 3 - ItemInfo.Extension.length/2 ) : icon.Height;
var iw = icon.Width / ( icon.Height / ( wh - 3 - ItemInfo.Extension.length/2 ) );
icon = icon.Resize(iw,ih);
} catch(e) { var icon = false; }
if ( icon ) gr.DrawImage(icon, 3 + ItemInfo.Extension.length/2 - f, (wh - ih ) / 2 + ItemInfo.Extension.length/2 - f, iw, ih, 0, 0, iw, ih, 0, 255);
}
}
else {
var ext = ItemInfo.Extension;
ext = ext.toLowerCase();
try {
var icon = ( fso.FileExists( fb.FoobarPath + '\\s7e_files\\formats\\' + ext + '.png' ) ) ? gdi.Image( fb.FoobarPath + '\\s7e_files\\formats\\' + ext + '.png' ) : gdi.Image( fb.FoobarPath + '\\s7e_files\\formats\\generic.png' );
var ih = icon.Height > wh ? wh - 4 : icon.Height;
var iw = icon.Width / ( icon.Width / (wh - 4) );
var icon_r = icon.Resize(iw,ih);
} catch(e) { var icon = false; }
if ( icon ) gr.DrawImage(icon_r, 3, 2, iw, ih, 0, 0, iw, ih, 0, 255);
}
}
else {
if ( folder ) gr.DrawImage(folder, 3, 2, folder.Width / ( folder.Height / (wh - 6) ), wh - 6, 0, 0, folder.Width, folder.Height, 0, 255);
}
}
else {
if ( fb.PlaylistItemCount(fb.ActivePlaylist) == 0 ) {
if ( folder ) gr.DrawImage(folder, 3, 2, folder.Width / ( folder.Height / (wh - 4) ), wh - 4, 0, 0, folder.Width, folder.Height, 0, 255);
gr.GdiDrawText( 'Empty playlist', font_p1, RGB( 30, 57, 91), folder ? ((wh ) + 5) : 5, 5, ww - (wh ) - 5, wh, DT_LEFT | DT_TOP | DT_CALCRECT);
}
//else { ItemInfo.Update(); }
}
//var end = new Date().getMilliseconds();
//fb.trace('onpaint = ' + ( end - start ) + ' ms' );
}
function on_get_album_art_done( metadb, art_id, image, image_path) {
var wh = window.Height;
var ww = window.Width;
if ( image ) {
var img = image.Clone(0,0,image.Width,image.Height);
if ( img.Width > wh - 10 || img.Height > wh - 10 ) {
if ( img.Width / img.Height > (wh - 10) / (wh - 10) ) {
var iw = wh - 10;
var ih = img.Height / ( img.Width / (wh - 10) );
var img = img.Resize( iw, ih);
}
else {
var ih = wh - 10;
var iw = img.Width / ( img.Height / (wh - 10) );
var img = img.Resize( iw, ih);
}
}
ItemInfo.Cover = img;
window.Repaint();
}
}
function trackbuttons(x,y){
var i = Buttons.length;
while ( i-- ) {
if ( Buttons[i].traceMouse(x, y) ) {
var temp = Buttons[i];
break;
}
else {
var temp = false;
}
}
if ( temp && ( btn != temp || temp.update == 1 ) ) {
ClearButtonsVars();
btn = temp;
btn.onHover(x,y);
window.Repaint();
}
else if (!temp) {
btn = false;
ClearButtonsVars();
window.Repaint();
}
return btn;
}
function on_mouse_move(x, y) {
g_move = 1;
hover_button = trackbuttons(x, y);
}
function on_mouse_lbtn_down(x,y){
g_button_down = null;
if (hover_button) {
hover_button.onClick(x, y);
}
window.Repaint();
}
function on_metadb_changed(metadb) {
ItemInfo.Update();
}
function on_size() {
calculate_dims();
}
function on_playback_new_track(metadb) {
var selection_metadb = metadb;
var selection_temp = selection_metadb.RawPath != undefined ? selection_metadb.RawPath + '' + selection_metadb.SubSong : 'undefinedundefined';
var cached_temp = ItemInfo.CachedMetadb ? (ItemInfo.CachedMetadb.RawPath + '' + ItemInfo.CachedMetadb.SubSong) : 'undefinedundefined';
if ( selection_temp != cached_temp ) ItemInfo.Update( metadb );
}
function on_playback_stop( Reason ) {
if ( Reason == 0 ) on_item_focus_change();
}
function on_item_focus_change() {
//fb.trace( 'on_item_focus: seltype = ' + fb.GetSelectionType() + ' count = ' + fb.GetSelections().Count + ' ??? = ' + ((!fb.IsPlaying || mode == 2)) );
if ( (!fb.IsPlaying || mode == 2) && fb.GetSelections().Count < 2 ) {
//fb.trace( 'on_item_focus_change()' );
ItemInfo.Update();
}
}
function on_selection_changed(metadb) {
var selection_metadb = ItemInfo.OutputMetadb();
var selection_temp = selection_metadb ? selection_metadb.RawPath + '' + selection_metadb.SubSong : 'undefinedundefined';
var cached_temp = ItemInfo.CachedMetadb ? (ItemInfo.CachedMetadb.RawPath + '' + ItemInfo.CachedMetadb.SubSong) : 'undefinedundefined';
var selection_string_temp = fb.GetSelectionType() + ' ' + fb.GetSelections().Count;
var sel = fb.GetSelectionType();
//fb.trace( '\nnull: selection_string_temp = ' + selection_string_temp + ' / ItemInfo.SelectionString = ' + ItemInfo.SelectionString );
//fb.trace( 'null: selection_temp = ' + selection_temp + ' / cached_temp = ' + cached_temp );
//fb.trace( ItemInfo.SelectionString != selection_string_temp );
//fb.trace( selection_temp != cached_temp );
//fb.trace( ( (sel == 0 && fb.GetSelections().Count >= 2 ) || ( ( sel == 1 || sel == 4 ) && fb.GetSelections().Count >= 1 ) ) );
//fb.trace( '1 ' + ( ( sel == 0 && fb.GetSelections().Count >= 2 ) || ( sel == 0 && ItemInfo.Selection > 1 ) ) );
//fb.trace( '2 ' + ( ( sel == 1 || sel == 4 ) && fb.GetSelections().Count >= 1 ) );
//fb.trace( 'on_selection_changed: seltype = ' + fb.GetSelectionType() + ' count = ' + fb.GetSelections().Count );
//if ( ( ( ( sel == 0 && fb.GetSelections().Count >= 2 ) || ( sel == 0 && ItemInfo.Selection > 1 ) ) || ( ( sel == 1 || sel == 4 ) && fb.GetSelections().Count >= 1 ) ) && ( ItemInfo.SelectionString != selection_string_temp || selection_temp != cached_temp ) ) {
if ( ( ( ( sel == 0 && fb.GetSelections().Count >= 2 ) || ( sel == 0 && ItemInfo.Selection > 1 ) ) || ( ( sel == 1 ) && fb.GetSelections().Count >= 1 ) ) && ( ItemInfo.SelectionString != selection_string_temp || selection_temp ^ cached_temp ) ) {
//fb.trace( 'if: seltype = ' + fb.GetSelectionType() + ' / count = ' + fb.GetSelections().Count + ' / ItemInfo.Selection = ' + ItemInfo.Selection );
ItemInfo.Update();
}
//else if ( fb.GetSelectionType() == 0 ) ItemInfo.Selection = 0;
}
//function on_playback_edited() { ItemInfo.Update(); }
function on_playlist_switch() {
if ( !fb.IsPlaying || mode == 2 ) {
ItemInfo.Update();
}
}
function on_playlist_items_added(playlist) {
if ( (!fb.IsPlaying || mode == 2) && ItemInfo.Selection != fb.GetSelections().Count ) {
ItemInfo.Update();
}
}
function on_playlist_items_removed(playlist, new_count) {
if ( (!fb.IsPlaying || mode == 2) || ItemInfo.Selection != fb.GetSelections().Count ) {
ItemInfo.Update();
}
}
function on_mouse_leave() {
g_hover = false;
ClearButtonsVars();
btn = null;
window.SetCursor( 32512 );
window.Repaint();
}
function on_mouse_rbtn_up(x,y) {
var _menu = window.CreatePopupMenu();
var _firstgroup = window.CreatePopupMenu();
var _secondgroup = window.CreatePopupMenu();
var _thirdgroup = window.CreatePopupMenu();
var i = 1;
var ret;
_menu.AppendMenuItem(MF_STRING, i++, "Settings");
_menu.AppendMenuSeparator();
_firstgroup.AppendMenuItem(MF_STRING, i++, "Playing item");
_firstgroup.AppendMenuItem(MF_STRING, i++, "Current selection");
_firstgroup.EnableMenuItem( mode+1, 1 );
_firstgroup.CheckMenuRadioItem( 2, i - 1, mode+1 );
_secondgroup.AppendMenuItem(MF_STRING, i++, "Enable rectangular backgrounds");
_secondgroup.CheckMenuItem( i-1, rects, bypos = false);
_secondgroup.AppendMenuItem(MF_STRING, i++, "Enable vertical text alignment");
_secondgroup.CheckMenuItem( i-1, valign, bypos = false);
_secondgroup.AppendMenuItem(MF_STRING, i++, "Show cover instead of icon");
_secondgroup.CheckMenuItem( i-1, show_cover_instead, bypos = false);
_thirdgroup.AppendMenuItem(MF_STRING, i++, "Write rating into tags, if no playcount component is present");
_thirdgroup.CheckMenuItem( i-1, ini_tag_write, bypos = false);
_firstgroup.AppendTo( _menu, MF_STRING, "Focus settings");
_secondgroup.AppendTo( _menu, MF_STRING, "Visual settings");
_thirdgroup.AppendTo( _menu, MF_STRING, "Rating settings");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 1 ) {
window.ShowConfigure();
}
else if (ret >= 2 && ret <= 3) {
utils.WriteINI( fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'track-info-mode', mode = ret - 1);
ItemInfo.Update();
}
else if (ret == 4 ) {
utils.WriteINI( fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'rectangular-backs', rects = rects == 1 ? 0 : 1);
window.Repaint();
}
else if (ret == 5 ) {
utils.WriteINI( fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'vertical-align', valign = valign == 1 ? 0 : 1);
calculate_dims();
ItemInfo.ButtonsReady = 0;
ClearButtonCoords();
window.Repaint();
}
else if (ret == 6 ) {
utils.WriteINI( fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'show-cover-instead', show_cover_instead = show_cover_instead == 1 ? 0 : 1);
}
else if (ret == 7 ) {
utils.WriteINI( fb.FoobarPath + 's7e.ini', 'info-panel-settings', 'write-rating-to-tag', ini_tag_write = ini_tag_write == 1 ? 0 : 1);
}
return true;
}