Files
geograsim/App/sims/tourismustal/js/player.js
T
Adminator 0a2ebf46b4 Tourismustal: Komplett-Integration (Sim + Wrapper + SQL + Lehrer-Backend)
Sim nach App/sims/tourismustal umgezogen (Source of Truth), game.html mit
Injection-Marker. Neu in der Sim: 5 Sommergebaeude (Bikepark mit Flowtrails,
Hochseilgarten, Fahrradverleih als Verstaerker, Aussichtsplattform,
Erlebnisspielplatz), Rettungsstation mit Notarzthubschrauber, Ausbau-
Bauanimation, Event-Pacing, Schulden-Notbremse (Bank-Zwangsverkauf),
Berater-Tipps (Ruecklagen), Sommer-Trend-Mechanik (Serfaus-Effekt) und
Wissens-Bausteine mit echten DACH-Tourismusdaten (QUELLEN.md).

Plattform: PHP-Wrapper mit base-Tag + Session-Mode, Modul-Detailseite,
module_info (beta) + Glossar (14 Begriffe inkl. Leichter Sprache + Quellen)
+ Lehrplan-Anker AT/DE/CH an neuer Kompetenz tourismus-raumentwicklung.
Lehrer-Backend: Benchmark-Formel, Live-Cockpit-Spalten, needsHelp-Heuristik,
Modul-Highlights. Strategie-Testharness (tests/strategien.mjs) belegt:
Panzer-Rush wird liquidiert, Ruecklagen zahlen sich aus.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-11 02:45:08 +02:00

78 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Hintergrundmusik-Player: spielt die Lieder aus assets/music/
// (HTML5-Audio). Die Original-Dateinamen sind kryptisch hier bekommen
// sie stimmige Titel fürs Tal.
const DIR = 'assets/music/';
export const TRACKS = [
{ file: 'Geluk op de Piste.mp3', title: 'Glück auf der Piste' },
{ file: 'Sur les skis en Autriche.mp3', title: 'Auf Skiern durch Österreich' },
{ file: 'ski rock 1.mp3', title: 'Pistenrock' },
{ file: 'När jag var liten i Österrike SW.mp3', title: 'Heimweh nach dem Tal' },
{ file: 'När jag var liten i Österrike SW (1).mp3', title: 'Kindheit in den Bergen' },
{ file: 'När jag var liten i Österrike SW (2).mp3', title: 'Almsommer' },
{ file: 'sweet cold tunes.mp3', title: 'Schneegestöber' },
{ file: 'sweet cold tunes (1).mp3', title: 'Erster Schnee' },
{ file: 'sweet cold tunes 2.mp3', title: 'Gipfelmelodie' },
{ file: 'sweet cold tunes 3.mp3', title: 'Winterruhe' },
{ file: 'sweet cold tunes 3 (1).mp3', title: 'Spuren im Pulverschnee' },
{ file: 'sweet cold tunes 3 (2).mp3', title: 'Hüttenabend' },
{ file: 'sweet cold tunes 3 (3).mp3', title: 'Talstation um sieben' },
{ file: 'sweet cold tunes 3 (4).mp3', title: 'Nordwandlicht' },
{ file: 'sweet cold tunes 3 (5).mp3', title: 'Seilbahnschweben' },
{ file: 'sweet cold tunes 3 (6).mp3', title: 'Föhn überm Grat' },
];
export const player = {
el: null, // HTMLAudioElement
idx: 0,
playing: false,
onChange: null, // UI-Callback bei jedem Zustandswechsel
init() {
this.el = new Audio();
this.el.volume = Number(localStorage.getItem('tt_volume') ?? 0.35);
this.idx = Number(localStorage.getItem('tt_track') ?? 0) % TRACKS.length;
this.el.addEventListener('ended', () => this.next());
this._load();
},
_load() {
this.el.src = DIR + encodeURIComponent(TRACKS[this.idx].file);
localStorage.setItem('tt_track', this.idx);
},
_notify() { this.onChange?.(); },
current() { return TRACKS[this.idx]; },
play() {
this.el.play().then(() => {
this.playing = true;
this._notify();
}).catch(() => { /* Autoplay blockiert Nutzer startet manuell */ });
},
pause() {
this.el.pause();
this.playing = false;
this._notify();
},
toggle() { this.playing ? this.pause() : this.play(); },
next() { this.select((this.idx + 1) % TRACKS.length); },
prev() { this.select((this.idx - 1 + TRACKS.length) % TRACKS.length); },
select(i) {
this.idx = i % TRACKS.length;
this._load();
if (this.playing) this.play(); else this._notify();
},
setVolume(v) {
this.el.volume = v;
localStorage.setItem('tt_volume', v);
},
};