-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a media queue editor generated with AI
- Loading branch information
Showing
7 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<button mat-button (click)="toggleTray()">Toggle Player</button> | ||
|
||
<app-queue-editor></app-queue-editor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/app/apps/app/player/queue-editor/queue-editor.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h2>Queue Editor</h2> | ||
<input [(ngModel)]="newItemTitle" placeholder="Title" /> | ||
<select [(ngModel)]="newItemType"> | ||
<option value="music">Music</option> | ||
<option value="podcast">Podcast</option> | ||
<option value="video">Video</option> | ||
</select> | ||
<button (click)="addItem()">Add to Queue</button> | ||
|
||
<ul> | ||
<li *ngFor="let item of queue"> | ||
{{ item.title }} ({{ item.type }}) <button (click)="removeItem(item.id)">Remove</button> | ||
</li> | ||
</ul> |
37 changes: 37 additions & 0 deletions
37
app/src/app/apps/app/player/queue-editor/queue-editor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// src/app/components/queue-editor/queue-editor.component.ts | ||
import { Component } from '@angular/core'; | ||
import { MediaQueueService, MediaItem } from '../../../../media-queue.service'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-queue-editor', | ||
standalone: true, | ||
imports: [MatButtonModule, FormsModule], | ||
templateUrl: './queue-editor.component.html', // Reference to external template | ||
}) | ||
export class QueueEditorComponent { | ||
newItemTitle: string = ''; | ||
newItemType: 'music' | 'podcast' | 'video' = 'music'; | ||
queue: MediaItem[] = []; | ||
|
||
constructor(private mediaQueueService: MediaQueueService) { | ||
this.mediaQueueService.queue$.subscribe((queue) => { | ||
this.queue = queue; | ||
}); | ||
} | ||
|
||
addItem() { | ||
const newItem: MediaItem = { | ||
id: Date.now(), | ||
title: this.newItemTitle, | ||
type: this.newItemType, | ||
}; | ||
this.mediaQueueService.addToQueue(newItem); | ||
this.newItemTitle = ''; | ||
} | ||
|
||
removeItem(itemId: number) { | ||
this.mediaQueueService.removeFromQueue(itemId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// src/app/services/media-queue.service.ts | ||
import { Injectable } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
export interface MediaItem { | ||
id: number; | ||
title: string; | ||
type: 'music' | 'podcast' | 'video'; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class MediaQueueService { | ||
private queue: MediaItem[] = []; | ||
private queueSubject = new BehaviorSubject<MediaItem[]>(this.queue); | ||
|
||
queue$ = this.queueSubject.asObservable(); | ||
|
||
addToQueue(item: MediaItem) { | ||
this.queue.push(item); | ||
this.queueSubject.next(this.queue); | ||
} | ||
|
||
removeFromQueue(itemId: number) { | ||
this.queue = this.queue.filter((item) => item.id !== itemId); | ||
this.queueSubject.next(this.queue); | ||
} | ||
|
||
clearQueue() { | ||
this.queue = []; | ||
this.queueSubject.next(this.queue); | ||
} | ||
} |