Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Displaying PDF File
#1
Most classical albums come with a PDF file containing information about the artist, composer, and the pieces included.
Would it be possible to have an otion within Moode to display this?
I know this has been requested before, but a while ago, so I wondered whether this was feasible now.

Thanks,
Geoff
Reply
#2
Yes technically it's possible. For example the simple JS code below will open a PDF file in a new Browser tab using the Browsers native PDF viewer.

Code:
window.open('PATH_TO_PDF_FILE');

   

The challenging part is the implementation because there a several moving parts. It would be something like this.

In the file: /var/www/inc/mpd.php, function enhanceMetadata() there is the line below that gets the URL to the cover art image.
Code:
$current['coverurl'] = '/coverart.php/' . rawurlencode($song['file']);

Add a new line right below it for example.

Code:
$current['pdfurl'] = getPDF($song['file']);

Create the new function getPDF() in /var/www/inc/mpd.php. It accepts the path to the song file and returns the URL to a PDF file if it exists in the song file containing directory (the album directory).

In file /var/www/js/playerlib.js at an appropriate location check the value of MPD.json['pdfurl'] and if its not blank then inject some html with id="SELECTOR-NAME" that would display a clickable badge [PDF] maybe in one of the lower corners of the cover art.

Put the click handler somewhere in playerlib.js or scripts-panels.js

Code:
$(document).on('click', 'SELECTOR-NAME' function(e) {
   window.open(MPD.json['pdfurl']);
});

Maybe an interested dev will work out the details and contribute a PR to the repo :-)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
Thanks for your reply Tim.

I think that it would be a useful addition - here's hoping someone can take it up.

Geoff
Reply


Forum Jump: