Thank you for your donation!


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


Good evening from hot Spain.
#10
(07-07-2023, 10:31 AM)janiversen Wrote: There are some good doc on the audio structure in https://github.com/moode-player/docs/blo...ructure.md, except there are no code pointers.

I did not find an architecture describing the frontend (web browser / js) and backend (php), e.g. is it using web-sockets.

But in general this documentation is not too bad, actually a lot better than many open source projects :-) I guess I will just have to debug my way through.

The application architecture is summarized in the Overview section of the Master Development Guide. It's based on the original 2013 tsunamp player written by Andrea Coiutti & Simone De Gregori from which moOde and other similar projects were forked. https://github.com/moode-player/docs/blo...20guide.md

There are no details in the document describing how all the parts of application are stitched together due to lack of time to write that section. Similarly the Source Tree documentation which would be related to that section is incomplete and outdated. Volunteers are welcome :-)

I can get you started with the following quick run through.

Each web page consists of:

1. /var/www/header.php
2. An HTML template file from /var/www/templates/
3. /var/www/footer.php

The main Playback/Library screen is /var/www/templates/indextpl.html and /var/www/index.php. The rest of the files in /var/www/templates/ are the Configtration screens with corresponding PHP scripts in /var/www/

When a web page loads into the Browser the jQuery(document).ready code is executed in /var/www/js/scripts-panels.js or scripts-configs.js depending on whether the page is indextpl.html or one of the Configuration HTML templates respectively.

In these two JS scripts, settings and other data is fetched from SQL tables on the back-end and then AJAX connections to the two "server engines" are made in the section below via functions in /var/www/js/playerlib.js

Code:
// Connect to server engines
engineMpd();
engineCmd();

The MPD engine is /var/www/engine-mpd.php. It's a PHP wrapper around the MPD idle timeout loop which waits for MPD state change events and emits the state data back to the front-end JS engineMpd() function in playerlib.js. This function establishes permanent AJAX while loop with engine-mpd.php.

The Command engine is /var/www/engine-cmd.php. It's based on straight sockets and serves as a way for PHP scripts to send commands back to the front-end via the sendEngCmd() function in /var/www/inc/common.php. The commands are processed by the front-end JS engineCmd() function in playerlib.js. This function establishes a permanent AJAX while loop with engine-cmd.php.

The other core part of the application is /var/www/daemon/worker.php. Its function is to perform startup, process jobs sent to it by the front-end and handle player state when any of the "Renderers" connect/disconnect. Look in the section below where this polling loop is started.

(1) Turn on Debug logging in System Config to see in the Browser console whats returned by engine-mpd.php to the front-end, and in /var/log/moode.log to see some of the activity in worker.php and other PHP functions.
(2) The Library JSON files are cached in /var/local/www/

Code:
// BEGIN WORKER EVENT LOOP
 
A couple other application things to take note of:

1. Although the application is complex with many features, the default audio pipeline is simple and has not changed from the original over 10 years ago. It's still MPD -> ALSA -> Device.

2. The WebUI is designed to scale and adapt to screen sizes including Smartphone, Tablet, Desktop, TV and various locally  attached screens for example Pi 7" Touch or Ultra-wide LCD/OLED displays.

3. The data used to populate Library Tag and Album views is extracted from the MPD database by function loadLibrary($sock) in /var/www/inc/music-library.php and sent in its entirety as a JSON file to the front-end function loadLibrary() in /var/www/js/scripts-library.js which renders it.

4. The application is designed and optimized for the Raspberry Pi family of single board computers. No other platforms are supported.

5. Music Services are not integrated because their API's are proprietary (not Open Source) and they require annual license fees with contracts and NDA's.

6. Development is done using Gulp https://github.com/moode-player/docs/blo...th_gulp.md

7. The release images are built using pi-gen (the tool used to create Raspberry Pi OS images) and standard Debian packages. See our pkgbuild and imgbuild repos. The Raspberry Pi OS packages that are used are current as of the date our release images are generated.

8. We generally stay in sync with the latest official Raspberry Pi OS and kernel releases and 3rd party component releases for example shairport-sync, MPD, librespot, etc.

Lastly a few maintenance items to take note of:

1. Several JS/CSS libraries including Bootstrap, Font Awesome and jQuery should be bumped at some point but the effort to test and debug these lib upgrades is substantial and thus its a low priority.

2. A substantial part of the codebase was refactored a while back. Whats remaining is the JS but due to it's complexity and similar to the libs above the effort to test and debug is substantial and thus its a low priority.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
Good evening from hot Spain. - by janiversen - 07-06-2023, 08:40 PM
RE: Good evening from hot Spain. - by Nutul - 07-06-2023, 09:51 PM
RE: Good evening from hot Spain. - by Tim Curtis - 07-06-2023, 10:40 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 10:31 AM
RE: Good evening from hot Spain. - by Tim Curtis - 07-07-2023, 01:36 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 10:37 AM
RE: Good evening from hot Spain. - by Nutul - 07-07-2023, 10:49 AM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 11:58 AM
RE: Good evening from hot Spain. - by Nutul - 07-07-2023, 12:18 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 01:23 PM
RE: Good evening from hot Spain. - by Nutul - 07-07-2023, 01:37 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 02:26 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 02:45 PM
RE: Good evening from hot Spain. - by Tim Curtis - 07-07-2023, 04:19 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 04:01 PM
RE: Good evening from hot Spain. - by Tim Curtis - 07-07-2023, 04:49 PM
RE: Good evening from hot Spain. - by janiversen - 07-07-2023, 05:42 PM
RE: Good evening from hot Spain. - by Tim Curtis - 07-07-2023, 08:58 PM
RE: Good evening from hot Spain. - by Nutul - 07-07-2023, 06:25 PM
RE: Good evening from hot Spain. - by janiversen - 07-08-2023, 01:08 PM

Forum Jump: