mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 00:59:29 +00:00
Stub out more "modern" skins stuff
This commit is contained in:
parent
1f75d7ec4c
commit
b8cc5e8438
9 changed files with 62 additions and 2 deletions
|
|
@ -188,7 +188,11 @@ export class UIRoot {
|
|||
return found ?? null;
|
||||
}
|
||||
|
||||
dispatch(action: string, param: string | null, actionTarget: string | null) {
|
||||
dispatch(
|
||||
action: string,
|
||||
param: string | null | number,
|
||||
actionTarget: string | null
|
||||
) {
|
||||
switch (action.toLowerCase()) {
|
||||
case "play":
|
||||
this.audio.play();
|
||||
|
|
@ -208,6 +212,9 @@ export class UIRoot {
|
|||
case "eject":
|
||||
this.audio.eject();
|
||||
break;
|
||||
case "seek":
|
||||
this.audio.seekToPercent((param as number) / 255);
|
||||
break;
|
||||
default:
|
||||
assume(false, `Unknown global action: ${action}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,19 @@ export class AudioPlayer {
|
|||
this._audio.currentTime = secs;
|
||||
}
|
||||
|
||||
seekToPercent(percent: number) {
|
||||
this._audio.currentTime = this._audio.duration * percent;
|
||||
}
|
||||
|
||||
// In seconds
|
||||
getCurrentTime(): number {
|
||||
return this._audio.currentTime;
|
||||
}
|
||||
|
||||
getCurrentTimePercent(): number {
|
||||
return this._audio.currentTime / this._audio.duration;
|
||||
}
|
||||
|
||||
onCurrentTimeChange(cb: () => void): () => void {
|
||||
const handler = () => cb();
|
||||
this._audio.addEventListener("timeupdate", handler);
|
||||
|
|
@ -62,6 +70,15 @@ export class AudioPlayer {
|
|||
return dispose;
|
||||
}
|
||||
|
||||
onSeek(cb: () => void): () => void {
|
||||
const handler = () => cb();
|
||||
this._audio.addEventListener("seeked", handler);
|
||||
const dispose = () => {
|
||||
this._audio.removeEventListener("seeked", handler);
|
||||
};
|
||||
return dispose;
|
||||
}
|
||||
|
||||
// Current track length in seconds
|
||||
getLength(): number {
|
||||
return this._audio.duration;
|
||||
|
|
|
|||
10
packages/webamp-modern-2/src/skin/makiClasses/Config.ts
Normal file
10
packages/webamp-modern-2/src/skin/makiClasses/Config.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import XmlObj from "../XmlObj";
|
||||
import ConfigItem from "./ConfigItem";
|
||||
|
||||
export default class Config extends XmlObj {
|
||||
static GUID = "593dba224976d07771f452b90b405536";
|
||||
|
||||
newitem(itemName: string, itemGuid: string): ConfigItem {
|
||||
return new ConfigItem();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import XmlObj from "../XmlObj";
|
||||
|
||||
export default class ConfigItem extends XmlObj {}
|
||||
|
|
@ -12,6 +12,7 @@ export default class Slider extends GuiObj {
|
|||
_thumb: string;
|
||||
_downThumb: string;
|
||||
_hoverThumb: string;
|
||||
_action: string | null = null;
|
||||
_low: number;
|
||||
_high: number;
|
||||
_position: number = 0;
|
||||
|
|
@ -100,6 +101,10 @@ export default class Slider extends GuiObj {
|
|||
// (int) Set the high-value boundary. Default is 255.
|
||||
this._high = num(value);
|
||||
break;
|
||||
case "action":
|
||||
// Undocumented on the Wiki
|
||||
this._action = value;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -115,6 +120,9 @@ export default class Slider extends GuiObj {
|
|||
UI_ROOT.vm.dispatch(this, "onsetposition", [
|
||||
{ type: "INT", value: newPos },
|
||||
]);
|
||||
if (this._action) {
|
||||
UI_ROOT.dispatch(this._action, this.getposition(), null);
|
||||
}
|
||||
}
|
||||
|
||||
_renderThumb() {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ export default class SystemObject extends BaseObject {
|
|||
constructor(parsedScript: ParsedMaki) {
|
||||
super();
|
||||
this._parsedScript = parsedScript;
|
||||
UI_ROOT.audio.onSeek(() => {
|
||||
UI_ROOT.vm.dispatch(this, "onseek", [
|
||||
{ type: "INT", value: UI_ROOT.audio.getCurrentTimePercent() * 255 },
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
init() {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,11 @@ offsety - (int) Extra pixels to be added to or subtracted from the calculated x
|
|||
case "songname":
|
||||
this._displayValue = "Niente da Caprie (3";
|
||||
break;
|
||||
case "songtitle":
|
||||
this._displayValue = "Niente da Caprie (3";
|
||||
break;
|
||||
case "songbitrate":
|
||||
case "songsamplerate":
|
||||
case "songinfo":
|
||||
this._displayValue = "112kbps stereo 44.";
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ export default class SkinParser {
|
|||
case "wrapper":
|
||||
return this.traverseChildren(node);
|
||||
default:
|
||||
throw new Error(`Unhandled XML node type: ${node.name}`);
|
||||
console.warn(`Unhandled XML node type: ${node.name}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,12 @@ import Timer from "./makiClasses/Timer";
|
|||
import Slider from "./makiClasses/Slider";
|
||||
import Vis from "./makiClasses/Vis";
|
||||
import GuiObj from "./makiClasses/GuiObj";
|
||||
import Config from "./makiClasses/Config";
|
||||
import ConfigItem from "./makiClasses/ConfigItem";
|
||||
|
||||
const CLASSES = [
|
||||
Config,
|
||||
// ConfigItem,
|
||||
Button,
|
||||
SystemObject,
|
||||
Container,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue