From a0ecf24dedf8ecde4630499274fa108e9eb1d8ff Mon Sep 17 00:00:00 2001
From: ulrich
Date: Fri, 22 Nov 2024 08:21:50 +0000
Subject: [PATCH] Angaben in Readme praezisiert.
---
www/js/app.js | 55 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/www/js/app.js b/www/js/app.js
index a21de07..fafbd3d 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -364,7 +364,10 @@
self.addEvtListener('#pause-btn', 'click', function() {
self.kommando('pause');
});
- self.addEvtListener('#weiter-btn', 'click', self.weiter);
+ //self.addEvtListener('#weiter-btn', 'click', self.weiter);
+ self.addEvtListener('#weiter-btn', 'click', function() {
+ self.kommando('next');
+ });
self.addEvtListener('#hier-btn', 'click', self.hier_spielen);
@@ -482,18 +485,33 @@
}
};
+ /*
+ * DEPRECATED
+ */
this.weiter = function() {
- var bereichName = document.querySelector('.bereich-name').textContent;
- if(bereichName === '') {
- var titel = self.titelErmitteln(document.querySelector(".selected"));
- var playername = document.querySelector('#abspieler').value;
- console.log('plname: ' + playername + ' url: ' + titel.katalogUrl + titel.pfad + titel.name);
- self.http_post('api/strg/' + playername + '/weiter/titel', JSON.stringify(titel), function(responseText) {
- self.meldung_mit_timeout(responseText, 1500);
- });
- }
+ //var bereichName = document.querySelector('.bereich-name').textContent;
+ //if(bereichName === '') {
+ // var titel = self.titelErmitteln(document.querySelector(".selected"));
+ // var playername = document.querySelector('#abspieler').value;
+ // console.log('plname: ' + playername + ' url: ' + titel.katalogUrl + titel.pfad + titel.name);
+ // self.http_post('api/strg/' + playername + '/weiter/titel', JSON.stringify(titel), function(responseText) {
+ // self.meldung_mit_timeout(responseText, 1500);
+ // });
+ //}
};
+ /*
+ * Ein Abspieler-Kommando ausfuehren. Der Client entscheidet anhand
+ * des Indikators self.playingIndex, ob 'hier spielen' gewaehlt wurde
+ * (playingIndex groesser -1) oder das Kommando an den Server gehen soll.
+ *
+ * self.kommendo('play') wird nur von der Schaltflaeche 'hier spielen' gerufen.
+ * Die Schaltflaeche Play ist mit self.play verknuepft (s.o.) und spielt Listen
+ * oder Titel ueber des Server und Calypso.
+ *
+ * @param {type} kommando stop, pause, next, play
+ * @returns nichts
+ */
this.kommando = function(kommando) {
console.log(kommando);
if(self.playingIndex > -1) {
@@ -503,6 +521,11 @@
self.audioElem.removeEventListener("ended", self.nextTrack);
self.playingIndex = -1;
self.playState = 'stop';
+ } else if(kommando === 'next') {
+ const curidx = self.playingIndex;
+ self.kommando('stop');
+ self.playingIndex = curidx;
+ self.nextTrack();
} else if(kommando === 'pause') {
if(self.playState === 'pause') {
self.playState = 'play';
@@ -597,15 +620,12 @@
//const titelElem = new Audio(titel);
self.audioElem = new Audio(titelUrl);
self.audioElem.addEventListener("ended", self.nextTrack);
- self.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
- const track = self.audioCtx.createMediaElementSource(self.audioElem);
- track.connect(self.audioCtx.destination);
self.audioElem.play();
- self.playState = 'play';
+ self.playState = 'play';
}
});
};
-
+
this.getTitelFromJSONObj = function(titelObj) {
//const audioElements = document.querySelectorAll('.entity-eintrag');
const host = 'http://' + window.location.host + '/tango';
@@ -704,6 +724,11 @@
self.http_delete('api/alist/' + plname + '/' + index,'', function(responseText) {
// DELETE http://localhost:9090/mz/api/alist/liste1/0
//self.meldung_mit_timeout(responseText, 1500);
+ if(self.playingList === plname) {
+ if(self.playingIndex > index) {
+ --self.playingIndex;
+ }
+ }
self.titel_liste();
});
--
Gitblit v1.9.3