mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-18 21:41:30 +03:00
Info icon now appears for playlist files in the player component
Added missing data types
This commit is contained in:
@@ -2519,6 +2519,8 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
auto:
|
auto:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
sharingEnabled:
|
||||||
|
type: boolean
|
||||||
Download:
|
Download:
|
||||||
required:
|
required:
|
||||||
- url
|
- url
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export type Playlist = {
|
|||||||
duration: number;
|
duration: number;
|
||||||
user_uid?: string;
|
user_uid?: string;
|
||||||
auto?: boolean;
|
auto?: boolean;
|
||||||
|
sharingEnabled?: boolean;
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, ElementRef, Input, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
import { Component, ElementRef, Input, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
||||||
|
import { DatabaseFile } from 'api-types';
|
||||||
import { PostsService } from 'app/posts.services';
|
import { PostsService } from 'app/posts.services';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -20,7 +21,7 @@ export class TwitchChatComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
scrollContainer = null;
|
scrollContainer = null;
|
||||||
|
|
||||||
@Input() db_file = null;
|
@Input() db_file: DatabaseFile = null;
|
||||||
@Input() sub = null;
|
@Input() sub = null;
|
||||||
@Input() current_timestamp = null;
|
@Input() current_timestamp = null;
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,9 @@
|
|||||||
<ng-container *ngIf="db_file">
|
<ng-container *ngIf="db_file">
|
||||||
<button (click)="downloadFile()" [disabled]="downloading" mat-icon-button><mat-icon>cloud_download</mat-icon><mat-spinner *ngIf="downloading" class="spinner" [diameter]="35"></mat-spinner></button>
|
<button (click)="downloadFile()" [disabled]="downloading" mat-icon-button><mat-icon>cloud_download</mat-icon><mat-spinner *ngIf="downloading" class="spinner" [diameter]="35"></mat-spinner></button>
|
||||||
<button *ngIf="type !== 'subscription' && (!postsService.isLoggedIn || postsService.permissions.includes('sharing'))" (click)="openShareDialog()" mat-icon-button><mat-icon>share</mat-icon></button>
|
<button *ngIf="type !== 'subscription' && (!postsService.isLoggedIn || postsService.permissions.includes('sharing'))" (click)="openShareDialog()" mat-icon-button><mat-icon>share</mat-icon></button>
|
||||||
<button (click)="openFileInfoDialog()" *ngIf="db_file" mat-icon-button><mat-icon>info</mat-icon></button>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
<ng-container *ngIf="db_file || playlist[currentIndex]"></ng-container>
|
||||||
|
<button (click)="openFileInfoDialog()" *ngIf="db_file || db_playlist" mat-icon-button><mat-icon>info</mat-icon></button>
|
||||||
<button *ngIf="db_file && db_file.url.includes('twitch.tv') && postsService['config']['API']['use_twitch_API']" (click)="drawer.toggle()" mat-icon-button><mat-icon>chat</mat-icon></button>
|
<button *ngIf="db_file && db_file.url.includes('twitch.tv') && postsService['config']['API']['use_twitch_API']" (click)="drawer.toggle()" mat-icon-button><mat-icon>chat</mat-icon></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||||
import { ShareMediaDialogComponent } from '../dialogs/share-media-dialog/share-media-dialog.component';
|
import { ShareMediaDialogComponent } from '../dialogs/share-media-dialog/share-media-dialog.component';
|
||||||
import { FileType } from '../../api-types';
|
import { DatabaseFile, FileType, Playlist } from '../../api-types';
|
||||||
import { TwitchChatComponent } from 'app/components/twitch-chat/twitch-chat.component';
|
import { TwitchChatComponent } from 'app/components/twitch-chat/twitch-chat.component';
|
||||||
import { VideoInfoDialogComponent } from 'app/dialogs/video-info-dialog/video-info-dialog.component';
|
import { VideoInfoDialogComponent } from 'app/dialogs/video-info-dialog/video-info-dialog.component';
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ export interface IMedia {
|
|||||||
type: string;
|
type: string;
|
||||||
label: string;
|
label: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
uid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -39,6 +40,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
uids: string[];
|
uids: string[];
|
||||||
type: FileType;
|
type: FileType;
|
||||||
playlist_id = null; // used for playlists (not subscription)
|
playlist_id = null; // used for playlists (not subscription)
|
||||||
|
file_objs: DatabaseFile[] = []; // used for playlists
|
||||||
uid = null; // used for non-subscription files (audio, video, playlist)
|
uid = null; // used for non-subscription files (audio, video, playlist)
|
||||||
subscription = null;
|
subscription = null;
|
||||||
sub_id = null;
|
sub_id = null;
|
||||||
@@ -47,8 +49,8 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
timestamp = null;
|
timestamp = null;
|
||||||
auto = null;
|
auto = null;
|
||||||
|
|
||||||
db_playlist = null;
|
db_playlist: Playlist = null;
|
||||||
db_file = null;
|
db_file: DatabaseFile = null;
|
||||||
|
|
||||||
baseStreamPath = null;
|
baseStreamPath = null;
|
||||||
audioFolderPath = null;
|
audioFolderPath = null;
|
||||||
@@ -133,11 +135,11 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
label: this.name,
|
label: this.name,
|
||||||
src: this.url,
|
src: this.url,
|
||||||
type: 'video/mp4',
|
type: 'video/mp4',
|
||||||
url: this.url
|
url: this.url,
|
||||||
|
uid: this.uid
|
||||||
}
|
}
|
||||||
this.playlist.push(imedia);
|
this.playlist.push(imedia);
|
||||||
this.currentItem = this.playlist[0];
|
this.updateCurrentItem(this.playlist[0], 0);
|
||||||
this.currentIndex = 0;
|
|
||||||
this.show_player = true;
|
this.show_player = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +179,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.postsService.getPlaylist(this.playlist_id, this.uuid, true).subscribe(res => {
|
this.postsService.getPlaylist(this.playlist_id, this.uuid, true).subscribe(res => {
|
||||||
if (res['playlist']) {
|
if (res['playlist']) {
|
||||||
this.db_playlist = res['playlist'];
|
this.db_playlist = res['playlist'];
|
||||||
this.db_playlist['file_objs'] = res['file_objs'];
|
this.file_objs = res['file_objs'];
|
||||||
this.uids = this.db_playlist.uids;
|
this.uids = this.db_playlist.uids;
|
||||||
this.type = res['type'];
|
this.type = res['type'];
|
||||||
this.show_player = true;
|
this.show_player = true;
|
||||||
@@ -195,7 +197,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
for (let i = 0; i < this.uids.length; i++) {
|
for (let i = 0; i < this.uids.length; i++) {
|
||||||
let file_obj = null;
|
let file_obj = null;
|
||||||
if (this.playlist_id) {
|
if (this.playlist_id) {
|
||||||
file_obj = this.db_playlist['file_objs'][i];
|
file_obj = this.file_objs[i];
|
||||||
} else if (this.sub_id) {
|
} else if (this.sub_id) {
|
||||||
file_obj = this.subscription['videos'][i];
|
file_obj = this.subscription['videos'][i];
|
||||||
} else {
|
} else {
|
||||||
@@ -226,7 +228,8 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
src: fullLocation,
|
src: fullLocation,
|
||||||
type: mime_type,
|
type: mime_type,
|
||||||
label: file_obj['title'],
|
label: file_obj['title'],
|
||||||
url: file_obj['url']
|
url: file_obj['url'],
|
||||||
|
uid: file_obj['uid']
|
||||||
}
|
}
|
||||||
this.playlist.push(mediaObject);
|
this.playlist.push(mediaObject);
|
||||||
}
|
}
|
||||||
@@ -272,8 +275,12 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentIndex++;
|
this.updateCurrentItem(this.playlist[this.currentIndex], ++this.currentIndex);
|
||||||
this.currentItem = this.playlist[ this.currentIndex ];
|
}
|
||||||
|
|
||||||
|
updateCurrentItem(newCurrentItem: IMedia, newCurrentIndex: number) {
|
||||||
|
this.currentItem = newCurrentItem;
|
||||||
|
this.currentIndex = newCurrentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
playVideo(): void {
|
playVideo(): void {
|
||||||
@@ -283,6 +290,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
onClickPlaylistItem(item: IMedia, index: number): void {
|
onClickPlaylistItem(item: IMedia, index: number): void {
|
||||||
this.currentIndex = index;
|
this.currentIndex = index;
|
||||||
this.currentItem = item;
|
this.currentItem = item;
|
||||||
|
this.updateCurrentItem(this.currentItem, this.currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileNames(): string[] {
|
getFileNames(): string[] {
|
||||||
@@ -305,7 +313,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, zipName + '.zip');
|
saveAs(blob, zipName + '.zip');
|
||||||
}, err => {
|
}, err => {
|
||||||
console.log(err);
|
console.error(err);
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -319,7 +327,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, filename + ext);
|
saveAs(blob, filename + ext);
|
||||||
}, err => {
|
}, err => {
|
||||||
console.log(err);
|
console.error(err);
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -361,18 +369,32 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openFileInfoDialog(): void {
|
openFileInfoDialog(): void {
|
||||||
|
let file_obj = this.db_file;
|
||||||
|
const original_uid = this.currentItem.uid;
|
||||||
|
if (this.db_playlist) {
|
||||||
|
const idx = this.getPlaylistFileIndexUID(original_uid);
|
||||||
|
file_obj = this.file_objs[idx];
|
||||||
|
}
|
||||||
const dialogRef = this.dialog.open(VideoInfoDialogComponent, {
|
const dialogRef = this.dialog.open(VideoInfoDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
file: this.db_file,
|
file: file_obj,
|
||||||
},
|
},
|
||||||
minWidth: '50vw'
|
minWidth: '50vw'
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe(() => {
|
dialogRef.afterClosed().subscribe(() => {
|
||||||
this.db_file = dialogRef.componentInstance.file;
|
if (this.db_file) this.db_file = dialogRef.componentInstance.file;
|
||||||
|
else if (this.db_playlist) {
|
||||||
|
const idx = this.getPlaylistFileIndexUID(original_uid);
|
||||||
|
this.file_objs[idx] = dialogRef.componentInstance.file;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlaylistFileIndexUID(uid: string): number {
|
||||||
|
return this.file_objs.findIndex(file_obj => file_obj['uid'] === uid);
|
||||||
|
}
|
||||||
|
|
||||||
setPlaybackTimestamp(time: number): void {
|
setPlaybackTimestamp(time: number): void {
|
||||||
this.api.seekTime(time);
|
this.api.seekTime(time);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user