Stuff
This commit is contained in:
11
src/app/app.config.ts
Normal file
11
src/app/app.config.ts
Normal 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
1
src/app/app.html
Normal file
@@ -0,0 +1 @@
|
||||
<router-outlet />
|
||||
9
src/app/app.routes.ts
Normal file
9
src/app/app.routes.ts
Normal 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
0
src/app/app.scss
Normal file
23
src/app/app.spec.ts
Normal file
23
src/app/app.spec.ts
Normal 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
12
src/app/app.ts
Normal 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
9
src/app/models/file.ts
Normal 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
12
src/app/models/track.ts
Normal 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,
|
||||
) {
|
||||
}
|
||||
}
|
||||
10
src/app/models/trackmeta.ts
Normal file
10
src/app/models/trackmeta.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export class TrackMeta {
|
||||
constructor(
|
||||
public title: string,
|
||||
public artist: string,
|
||||
public album: string,
|
||||
public genre: string,
|
||||
public trackNumber: number,
|
||||
) {
|
||||
}
|
||||
}
|
||||
3
src/app/pages/homepage/homepage.html
Normal file
3
src/app/pages/homepage/homepage.html
Normal file
@@ -0,0 +1,3 @@
|
||||
Home
|
||||
|
||||
<button id="play" (click)="play($event)">Play</button>
|
||||
18
src/app/pages/homepage/homepage.ts
Normal file
18
src/app/pages/homepage/homepage.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
30
src/app/services/audio.service.ts
Normal file
30
src/app/services/audio.service.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
5
src/app/services/file.service.ts
Normal file
5
src/app/services/file.service.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class FileService {
|
||||
getFile(uuid: string) {
|
||||
|
||||
}
|
||||
}
|
||||
3
src/app/services/mock/file.json
Normal file
3
src/app/services/mock/file.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"filename": ""
|
||||
}
|
||||
Reference in New Issue
Block a user