track listing font color by audio format?

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: track listing font color by audio format?

Re: track listing font color by audio format?

by smellhole » Sat Aug 06, 2022 4:33 pm

Ludek wrote: Sat Aug 06, 2022 3:59 pm Yes, to change the title column colour use
Thank you, sir!

I ended up with this for my use. It just shows green for mp3 and blue for all of my 24-bit stuff.

Code: Select all

uitools.tracklistFieldDefs.title.override({
    bindData: function ($super, div, item) {
        $super(div, item); // override() gives us $super, so we can call the original code, which renders bitrate and we can only change the color here

        var bitrate = Math.round(item.bitrate / 1000);
        div.style.fontWeight = '';
        if (bitrate > 1411) {
            div.style.color = 'blue';
            div.style.fontWeight = '';
        } else
        if (bitrate < 321)
            div.style.color = 'green';
        else {
            div.style.color = '';
        }
            }
});

Re: track listing font color by audio format?

by Ludek » Sat Aug 06, 2022 3:59 pm

Yes, to change the title column colour use

uitools.tracklistFieldDefs.title.override (instead of current uitools.tracklistFieldDefs.bitrate.override)

i.e.

Code: Select all

uitools.tracklistFieldDefs.title.override({
    bindData: function ($super, div, item) {
        $super(div, item); 
        
        if (item.fileType == 'mp3')
            div.style.color = 'red';
        else {
            div.style.color = '';
        }
    }
});

Re: track listing font color by audio format?

by smellhole » Fri Aug 05, 2022 9:37 am

Erwin Hanzl wrote: Fri Aug 05, 2022 9:33 am Yes, for you and Ludek
I'm not a JavaScripter either, otherwise I would already have the solution.
So we wait for Ludek's solution.
Roger, standing by.

Re: track listing font color by audio format?

by Erwin Hanzl » Fri Aug 05, 2022 9:33 am

Yes, for you and Ludek
I'm not a JavaScripter either, otherwise I would already have the solution.
So we wait for Ludek's solution.

Re: track listing font color by audio format?

by smellhole » Fri Aug 05, 2022 9:31 am

Erwin Hanzl wrote: Fri Aug 05, 2022 9:25 am Please see my UPDATE
Extension determines the title color.
Was this for me? I don't know what to do with that, alas. I'm not really a coder though I can modify other people's scripts sometimes.

Re: track listing font color by audio format?

by Erwin Hanzl » Fri Aug 05, 2022 9:25 am

Please see my UPDATE
Extension determines the title color.

Re: track listing font color by audio format?

by smellhole » Fri Aug 05, 2022 9:19 am

I got this working to at least show two different colors, one for less than 321 and one for more than 1411. Basically, for me, that's MP3s, then 16-bit FLAC, then 24-bit FLAC, which is all I have in my collection.

Code: Select all

/* 'This file is part of MediaMonkey licensed for use under the Ventis Media End User License Agreement, and for the creation of derivative works under the less restrictive Ventis Limited Reciprocal License. See: https://www.mediamonkey.com/sw/mmw/5/Ventis_limited_reciprocal_license.txt' */

// A simple example of formatting of a tracklist column - in this case bitrate color is modified, very low bitrates in red, etc.

uitools.tracklistFieldDefs.bitrate.override({
    bindData: function ($super, div, item) {
        $super(div, item); // override() gives us $super, so we can call the original code, which renders bitrate and we can only change the color here
        // Note that from performance point of view, it would make more sense to rather do it all here, without calling $super, this is just an example.

        var bitrate = Math.round(item.bitrate / 1000);
        div.style.fontWeight = '';
        if (bitrate > 1411) {
            div.style.color = 'blue';
            div.style.fontWeight = '';
        } else
        if (bitrate < 321)
            div.style.color = 'green';
        else {
            div.style.color = '';
        }
            }
});

Re: track listing font color by audio format?

by smellhole » Fri Aug 05, 2022 9:04 am

Erwin Hanzl wrote: Fri Aug 05, 2022 8:53 am @Ludek
Thank's
I would love to combine that. I just don't know where to use this:
See the last four lines of code
I would like to use this too!

Re: track listing font color by audio format?

by Erwin Hanzl » Fri Aug 05, 2022 8:53 am

@Ludek
Thank's
I would love to combine that. I just don't know where to use this:
See the last four lines of code - UPDATE: The "Title" field should be colored with it!!!!

Code: Select all

/* 'This file is part of MediaMonkey licensed for use under the Ventis Media End User License Agreement, and for the creation of derivative works under the less restrictive Ventis Limited Reciprocal License. See: https://www.mediamonkey.com/sw/mmw/5/Ventis_limited_reciprocal_license.txt' */

// A simple example of formatting of a tracklist column - in this case bitrate color is modified, very low bitrates in red, etc.

uitools.tracklistFieldDefs.bitrate.override({
    bindData: function ($super, div, item) {
        $super(div, item); // override() gives us $super, so we can call the original code, which renders bitrate and we can only change the color here
        // Note that from performance point of view, it would make more sense to rather do it all here, without calling $super, this is just an example.

        var bitrate = Math.round(item.bitrate / 1000);
        div.style.fontWeight = '';
        if (bitrate > 319) {
            div.style.color = '';
            div.style.fontWeight = 'bold';
        } else
        if (bitrate < 320)
            div.style.color = 'red';
        else {
            div.style.color = '';
        }
    }
});

// ?????????????????????????????????????????????????????????????????????
// if (item.fileType.toUpperCase() == 'MP3') then item.Title.div.style.color = 'red';
// if (item.fileType.toUpperCase() == 'FLAC') then item.Title.div.style.color = 'green';
// if (item.fileType.toUpperCase() == 'WAV') then item.Title.div.style.color = 'yellow';
// if (item.fileType.toUpperCase() == 'OGG') then item.Title.div.style.color = 'blue';

Re: track listing font color by audio format?

by smellhole » Fri Aug 05, 2022 8:46 am

Thanks, guys. Not exactly how I thought it would get done, but this works well enough for my purposes, which were just temporary anyway. Thanks! You guys are great. :)

Re: track listing font color by audio format?

by Ludek » Fri Aug 05, 2022 8:34 am

Yes, highlightBitrate is perfect example how to easily do this.

So just modify the code slightly there in trackListView_add.js and instead of

Code: Select all

if (bitrate < 128)
            div.style.color = 'red';
        else {
            div.style.color = '';
        }
use something like:

Code: Select all

if (item.fileType == 'mp3')
            div.style.color = 'red';
        else {
            div.style.color = '';
        }
i.e. copy [MMInstallFolder]/sampleScripts/highlightBitrate/ to [MMInstallFolder]/scripts/highlightBitrate/ and modify.

Re: track listing font color by audio format?

by Erwin Hanzl » Wed Aug 03, 2022 1:25 pm

@drakinite

There is a script "HighlightBitrate".
Could one program something like "smellhole" wishes?

track listing font color by audio format?

by smellhole » Mon Jul 25, 2022 10:26 pm

Hallo! I'm not sure if I should ask this here or in the add-ons section so I'll just err on this side...

I'm wondering if there's a way to have the display font for a track change color depending on the audio format. That way, when I look at a playlist, I'd get a clear view of what sort of files were in there.

Is that a thing at all?

I use the Code Monkey skin, should I ask that nice person?

Thanks.

Top