Compare commits

...

5 Commits

Author SHA1 Message Date
Matt Walsh
d810b429c5 5.15.1 2025-03-27 10:36:37 -05:00
Matt Walsh
560b51ccee fix playlist preload 2025-03-27 10:36:28 -05:00
Matt Walsh
e8f69ce28b Merge branch 'music-player' close #56 2025-03-27 10:27:45 -05:00
Matt Walsh
46fb40058f gulp publish caching changes 2025-03-27 10:23:27 -05:00
thatguychuck
b40fe08465 Music player dockerfile and readme. (#71)
* Update Dockerfile, swapped index.js for index.mjs

* Update README.md with docker music instructions.
2025-03-27 10:22:52 -05:00
6 changed files with 19 additions and 13 deletions

View File

@@ -7,4 +7,4 @@ COPY package-lock.json .
RUN npm ci
COPY . .
CMD ["node", "index.js"]
CMD ["node", "index.mjs"]

View File

@@ -111,7 +111,12 @@ The WeatherStar had wonderful background music from the smooth jazz and new age
I've used AI tools to create WeatherStar-inspired music tracks that are unencumbered by copyright and are included in this repo. Too keep the size down, I've only included 4 tracks. Additional tracks will be posted in a companion repository [ws4kp-music](https://github.com/netbymatt/ws4kp-music).
### Customizing the music
Placing .mp3 files in the `/server/music` folder will override the default music included in the repo. When weatherstar loads in the browser it will load a list if available files and randomize the order when it starts playing. On each loop through the available tracks the order will again be shuffled. If you're using the static files method to host your WeatherStar music is located in `/music`.
Placing .mp3 files in the `/server/music` folder will override the default music included in the repo. Subdirectories will not be scanned. When weatherstar loads in the browser it will load a list if available files and randomize the order when it starts playing. On each loop through the available tracks the order will again be shuffled. If you're using the static files method to host your WeatherStar music is located in `/music`.
If using docker, you must pass a local accessible folder to the container in the `/app/server/music` directory.
```
docker run -p 8080:8080 -v /path/to/local/music:/app/server/music ghcr.io/netbymatt/ws4kp
```
### Music doesn't auto play
Ws4kp is muted by default, but if it was unmuted on the last visit it is coded to try and auto play music on subsequent visits. But, it's considered bad form to have a web site play music automatically on load, and I fully agree with this. [Chrome](https://developer.chrome.com/blog/autoplay/#media_engagement_index) and [Firefox](https://hacks.mozilla.org/2019/02/firefox-66-to-block-automatically-playing-audible-video-and-audio/) have extensive details on how and when auto play is allowed.

View File

@@ -12,11 +12,11 @@ import s3Upload from 'gulp-s3-upload';
import webpack from 'webpack-stream';
import TerserPlugin from 'terser-webpack-plugin';
import { readFile } from 'fs/promises';
import reader from '../src/playlist-reader.mjs';
import file from "gulp-file";
import file from 'gulp-file';
// get cloudfront
import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront';
import reader from '../src/playlist-reader.mjs';
const clean = () => deleteAsync(['./dist/**/*', '!./dist/readme.txt']);
@@ -124,7 +124,7 @@ const compressHtml = async () => {
const otherFiles = [
'server/robots.txt',
'server/manifest.json',
'server/music/**/*.mp3'
'server/music/**/*.mp3',
];
const copyOtherFiles = () => src(otherFiles, { base: 'server/', encoding: false })
.pipe(dest('./dist'));
@@ -138,13 +138,14 @@ const uploadSources = [
'dist/**',
'!dist/**/*.map',
];
const upload = () => src(uploadSources, { base: './dist' })
const upload = () => src(uploadSources, { base: './dist', encoding: false })
.pipe(s3({
Bucket: 'weatherstar',
StorageClass: 'STANDARD',
maps: {
CacheControl: (keyname) => {
if (keyname.indexOf('index.html') > -1) return 'max-age=300'; // 10 minutes
if (keyname.indexOf('.mp3') > -1) return 'max-age=31536000'; // 1 year for mp3 files
return 'max-age=2592000'; // 1 month
},
},
@@ -176,8 +177,8 @@ const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
const buildPlaylist = async () => {
const availableFiles = await reader();
const playlist = { availableFiles };
return file('playlist.json', JSON.stringify(playlist)).pipe(dest('./dist'))
}
return file('playlist.json', JSON.stringify(playlist)).pipe(dest('./dist'));
};
const buildDist = series(clean, parallel(buildJs, compressJsData, compressJsVendor, copyCss, compressHtml, copyOtherFiles, buildPlaylist));
@@ -189,4 +190,4 @@ export default publishFrontend;
export {
buildDist,
}
};

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "ws4kp",
"version": "5.15.0",
"version": "5.15.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ws4kp",
"version": "5.15.0",
"version": "5.15.1",
"license": "MIT",
"dependencies": {
"ejs": "^3.1.5",

View File

@@ -1,6 +1,6 @@
{
"name": "ws4kp",
"version": "5.15.0",
"version": "5.15.1",
"description": "Welcome to the WeatherStar 4000+ project page!",
"main": "index.mjs",
"type": "module",

View File

@@ -14,7 +14,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="manifest" href="manifest.json" />
<link rel="icon" href="images/Logo192.png" />
<link rel="preload" href="playlist.json" />
<link rel="preload" href="playlist.json" as="fetch"/>
<meta property="og:image" content="https://weatherstar.netbymatt.com/images/social/1200x600.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="627">