Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(video-player) Playback service and storage #263

Merged
merged 19 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
eb156ec
created schema folder and template code for the video-player.service …
OchiengPaul442 Apr 18, 2024
50cda9c
Add video playback schema and collection creator
OchiengPaul442 Apr 18, 2024
21af80a
Refactor video player service to use PicsaAsyncService and PicsaDatab…
OchiengPaul442 Apr 18, 2024
289a8bf
Refactor video player service to use PicsaAsyncService and PicsaDatab…
OchiengPaul442 Apr 18, 2024
72f49e9
Refactor video player service to use PicsaAsyncService and PicsaDatab…
OchiengPaul442 Apr 18, 2024
730b833
included override to the init method in PicsaAsyncService in the vide…
OchiengPaul442 Apr 18, 2024
af50524
Refactor video player component to include progress bar in video-play…
OchiengPaul442 Apr 18, 2024
d2237d7
Refactor video player component to include progress bar and update vi…
OchiengPaul442 Apr 19, 2024
564fb7a
Refactor video player component to include progress bar and update vi…
OchiengPaul442 Apr 19, 2024
0406c0f
chore: move video player service
chrismclarke Apr 19, 2024
6b408dd
chore: generalise video player schema naming
chrismclarke Apr 19, 2024
77ceeb3
chore: code tidying
chrismclarke Apr 19, 2024
f020f1c
chore: round video state values
chrismclarke Apr 19, 2024
1b359df
chore: add rxjs incremental patch
chrismclarke Apr 19, 2024
07157b5
Refactor video player component to include progress bar and update vi…
OchiengPaul442 Apr 20, 2024
0f44f17
Refactor video player component to include progress bar and update vi…
OchiengPaul442 Apr 20, 2024
bcd4c48
fix: video playback and resume triggers
chrismclarke Apr 20, 2024
3a82e53
Merge branch 'ft-video-playback' of https://github.com/e-picsa/picsa-…
chrismclarke Apr 20, 2024
b32971d
Merge pull request #264 from e-picsa/review/ft-video-playback
chrismclarke Apr 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/shared/src/features/video-player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressBarModule } from '@angular/material/progress-bar';

import { VideoPlayerComponent } from './video-player.component';

@NgModule({
imports: [CommonModule, MatButtonModule, MatIconModule],
imports: [CommonModule, MatButtonModule, MatIconModule, MatProgressBarModule],
exports: [VideoPlayerComponent],
declarations: [VideoPlayerComponent],
providers: [],
Expand Down
12 changes: 12 additions & 0 deletions libs/shared/src/features/video-player/schema/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as schema from './schema_v0';

// Re-export schema to provide latest version without need to refactor additonal code

export const COLLECTION = schema.COLLECTION_V0;
export type IVideoPlayerEntry = schema.IVideoPlayerEntry_V0;
export const SCHEMA = schema.SCHEMA_V0;

// Ensure blank templates always recreated from scratch
export const ENTRY_TEMPLATE = schema.ENTRY_TEMPLATE_V0;

export const COLLECTION_NAME = 'video_player';
46 changes: 46 additions & 0 deletions libs/shared/src/features/video-player/schema/schema_v0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { RxJsonSchema } from 'rxdb';

import type { IPicsaCollectionCreator } from '../../../services/core/db_v2/models/index';

const SCHEMA_VERSION = 0;

export interface IVideoPlayerEntry_V0 {
videoId: string;
currentTime: number;
totalTime: number;
playbackPercentage: number;
}

export const ENTRY_TEMPLATE_V0: (videoId: string) => IVideoPlayerEntry_V0 = (videoId) => ({
videoId,
currentTime: 0,
totalTime: 0,
playbackPercentage: 0,
});

export const SCHEMA_V0: RxJsonSchema<IVideoPlayerEntry_V0> = {
title: 'video playback schema',
version: SCHEMA_VERSION,
type: 'object',
primaryKey: 'videoId',
properties: {
videoId: {
type: 'string',
},
currentTime: {
type: 'number',
},
totalTime: {
type: 'number',
},
playbackPercentage: {
type: 'number',
},
},
required: ['videoId', 'currentTime', 'totalTime', 'playbackPercentage'],
};

export const COLLECTION_V0: IPicsaCollectionCreator<IVideoPlayerEntry_V0> = {
schema: SCHEMA_V0,
isUserCollection: true,
};
22 changes: 17 additions & 5 deletions libs/shared/src/features/video-player/video-player.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<div class="placeholder" [id]="playerId" #playerEl slot="fixed">
<div *ngIf="thumbnail" class="thumbnail" [style.background-image]="'url(' + thumbnail + ')'"></div>
<button *ngIf="showPlayButton" mat-fab color="primary" class="play-button" (click)="playVideo()" [disabled]="!source">
<mat-icon>play_arrow</mat-icon>
</button>
<div class="placeholderContainer">
<div class="placeholder" [id]="playerId" #playerEl slot="fixed">
<div *ngIf="thumbnail" class="thumbnail" [style.background-image]="'url(' + thumbnail + ')'"></div>
<button
*ngIf="showPlayButton"
mat-fab
color="primary"
class="play-button"
(click)="playVideo()"
[disabled]="!source"
>
<mat-icon>play_arrow</mat-icon>
</button>
</div>
<div *ngIf="playbackPercentage > 0 && showPlayButton" class="progress-bar">
<mat-progress-bar mode="determinate" [value]="playbackPercentage"></mat-progress-bar>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ $playerWidth: 854px;
margin-right: -1rem;
}
}
.placeholderContainer {
position: relative;
width: 100%;
overflow: hidden;
margin-bottom: 2rem;
}
.placeholder,
.thumbnail {
width: 100%;
Expand All @@ -23,7 +29,6 @@ $playerWidth: 854px;
}
.placeholder {
position: relative;
margin-bottom: 2rem;
display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -64,3 +69,8 @@ $icon-size: 3rem;
background: #ffffff;
color: var(--color-warn);
}
.progress-bar {
position: relative;
width: 100%;
background-color: rgba(0, 0, 0, 0.25);
}
Loading
Loading