This commit is contained in:
2026-02-17 13:42:46 +00:00
parent a058d1e0bf
commit c8141a07f8
27 changed files with 9788 additions and 2 deletions

11
src/app/app.config.ts Normal file
View File

@@ -0,0 +1,11 @@
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes)
]
};

1
src/app/app.html Normal file
View File

@@ -0,0 +1 @@
<router-outlet />

9
src/app/app.routes.ts Normal file
View File

@@ -0,0 +1,9 @@
import { Routes } from '@angular/router';
import {HomePage} from './pages/homepage/homepage';
export const routes: Routes = [
{
path: '',
component: HomePage
}
];

0
src/app/app.scss Normal file
View File

23
src/app/app.spec.ts Normal file
View File

@@ -0,0 +1,23 @@
import { TestBed } from '@angular/core/testing';
import { App } from './app';
describe('App', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [App],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(App);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it('should render title', async () => {
const fixture = TestBed.createComponent(App);
await fixture.whenStable();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, jukesquare');
});
});

12
src/app/app.ts Normal file
View File

@@ -0,0 +1,12 @@
import { Component, signal } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.html',
styleUrl: './app.scss'
})
export class App {
protected readonly title = signal('jukesquare');
}

9
src/app/models/file.ts Normal file
View File

@@ -0,0 +1,9 @@
export class File {
constructor(
public filename: string,
public filepath: string,
public size: number,
) {
}
}

12
src/app/models/track.ts Normal file
View File

@@ -0,0 +1,12 @@
import {TrackMeta} from './trackmeta';
export class Track {
constructor(
public file: File,
public meta: TrackMeta,
public length: number,
public format: string,
public bitrate: number,
) {
}
}

View File

@@ -0,0 +1,10 @@
export class TrackMeta {
constructor(
public title: string,
public artist: string,
public album: string,
public genre: string,
public trackNumber: number,
) {
}
}

View File

@@ -0,0 +1,3 @@
Home
<button id="play" (click)="play($event)">Play</button>

View File

@@ -0,0 +1,18 @@
import {Component, OnInit, viewChild} from '@angular/core';
import {AudioService} from '../../services/audio.service';
@Component({
selector: 'app-home',
templateUrl: 'homepage.html',
})
export class HomePage{
protected audio: AudioService;
constructor() {
this.audio = new AudioService();
}
play(event: Event): void {
this.audio.play();
}
}

View File

@@ -0,0 +1,30 @@
import {HttpClient} from '@angular/common/http';
export class AudioService {
protected context: AudioContext;
protected track?: MediaElementAudioSourceNode;
constructor() {
this.context = new AudioContext();
}
createElement(filename: string) {
const element = document.createElement('audio');
const source = document.createElement('source');
source.src = filename;
source.type = 'audio/mp3';
element.appendChild(source);
return element;
}
async play(): Promise<void> {
if (this.context.state === 'suspended') {
await this.context.resume();
}
const element = this.createElement('audio/1.mp3');
this.track = this.context.createMediaElementSource(element);
this.track.connect(this.context.destination);
await element.play();
}
}

View File

@@ -0,0 +1,5 @@
export class FileService {
getFile(uuid: string) {
}
}

View File

@@ -0,0 +1,3 @@
{
"filename": ""
}