track listing font color by audio format?

Get help for different MediaMonkey 5 Addons.

Moderators: jiri, drakinite, Addon Administrators

smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

track listing font color by audio format?

Post by smellhole »

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.
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
Erwin Hanzl
Posts: 1051
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

Re: track listing font color by audio format?

Post by Erwin Hanzl »

@drakinite

There is a script "HighlightBitrate".
Could one program something like "smellhole" wishes?
MMW 4.1.31.1919 Gold-Standardinstallation auf WIN 10-64Bit Pro Vers. 21H2| Windows-Defender mit Echtzeitüberwachung. | Meine Einstellungen
MMA 1.4.5.0960 Free Beta-Tester auf Huawei Mate 20 Pro 128 GB Android 12 | USB-Kabel-Sync
MMW 5.0.4.2660 Beta (Free unregistered)-Standard installation in a separate collection for testing purposes only.
Many bugs that were still present in the "MM5 last official version" have already been fixed in Alpha- and Beta-Builds.
When an unexpected error occurred, I always wonder what errors were expected...😉
Ludek
Posts: 4658
Joined: Fri Mar 09, 2007 9:00 am

Re: track listing font color by audio format?

Post by Ludek »

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.
smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

Re: track listing font color by audio format?

Post by smellhole »

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. :)
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
Erwin Hanzl
Posts: 1051
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

Re: track listing font color by audio format?

Post by Erwin Hanzl »

@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';
Last edited by Erwin Hanzl on Fri Aug 05, 2022 9:28 am, edited 3 times in total.
MMW 4.1.31.1919 Gold-Standardinstallation auf WIN 10-64Bit Pro Vers. 21H2| Windows-Defender mit Echtzeitüberwachung. | Meine Einstellungen
MMA 1.4.5.0960 Free Beta-Tester auf Huawei Mate 20 Pro 128 GB Android 12 | USB-Kabel-Sync
MMW 5.0.4.2660 Beta (Free unregistered)-Standard installation in a separate collection for testing purposes only.
Many bugs that were still present in the "MM5 last official version" have already been fixed in Alpha- and Beta-Builds.
When an unexpected error occurred, I always wonder what errors were expected...😉
smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

Re: track listing font color by audio format?

Post by smellhole »

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!
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

Re: track listing font color by audio format?

Post by smellhole »

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 = '';
        }
            }
});
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
Erwin Hanzl
Posts: 1051
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

Re: track listing font color by audio format?

Post by Erwin Hanzl »

Please see my UPDATE
Extension determines the title color.
MMW 4.1.31.1919 Gold-Standardinstallation auf WIN 10-64Bit Pro Vers. 21H2| Windows-Defender mit Echtzeitüberwachung. | Meine Einstellungen
MMA 1.4.5.0960 Free Beta-Tester auf Huawei Mate 20 Pro 128 GB Android 12 | USB-Kabel-Sync
MMW 5.0.4.2660 Beta (Free unregistered)-Standard installation in a separate collection for testing purposes only.
Many bugs that were still present in the "MM5 last official version" have already been fixed in Alpha- and Beta-Builds.
When an unexpected error occurred, I always wonder what errors were expected...😉
smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

Re: track listing font color by audio format?

Post by smellhole »

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.
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
Erwin Hanzl
Posts: 1051
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

Re: track listing font color by audio format?

Post by Erwin Hanzl »

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.
MMW 4.1.31.1919 Gold-Standardinstallation auf WIN 10-64Bit Pro Vers. 21H2| Windows-Defender mit Echtzeitüberwachung. | Meine Einstellungen
MMA 1.4.5.0960 Free Beta-Tester auf Huawei Mate 20 Pro 128 GB Android 12 | USB-Kabel-Sync
MMW 5.0.4.2660 Beta (Free unregistered)-Standard installation in a separate collection for testing purposes only.
Many bugs that were still present in the "MM5 last official version" have already been fixed in Alpha- and Beta-Builds.
When an unexpected error occurred, I always wonder what errors were expected...😉
smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

Re: track listing font color by audio format?

Post by smellhole »

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.
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
Ludek
Posts: 4658
Joined: Fri Mar 09, 2007 9:00 am

Re: track listing font color by audio format?

Post by Ludek »

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 = '';
        }
    }
});
smellhole
Posts: 85
Joined: Mon Jan 23, 2012 4:21 pm

Re: track listing font color by audio format?

Post by smellhole »

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 = '';
        }
            }
});
::: Smellhole
::: It's better to have loved and lost than to never have had a good pair of speakers.
Post Reply