Add duration to video attributes in watch view
This commit is contained in:
parent
31174a272a
commit
df8340b7b8
3 changed files with 28 additions and 1 deletions
|
@ -0,0 +1,19 @@
|
|||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
|
||||
// Thanks: https://stackoverflow.com/a/46055604
|
||||
|
||||
@Pipe({
|
||||
name: 'myVideoDurationFormatter'
|
||||
})
|
||||
export class VideoDurationPipe implements PipeTransform {
|
||||
transform (value: number): string {
|
||||
const minutes = Math.floor(value / 60)
|
||||
const hours = Math.floor(minutes / 60)
|
||||
|
||||
if (hours > 0) {
|
||||
return hours + ' h ' + (minutes - hours * 60) + ' min ' + (value - (minutes - hours * 60) * 60) + ' sec'
|
||||
}
|
||||
|
||||
return minutes + ' min ' + (value - minutes * 60) + ' sec'
|
||||
}
|
||||
}
|
|
@ -85,6 +85,7 @@ import { TimestampInputComponent } from '@app/shared/forms/timestamp-input.compo
|
|||
import { VideoPlaylistElementMiniatureComponent } from '@app/shared/video-playlist/video-playlist-element-miniature.component'
|
||||
import { VideosSelectionComponent } from '@app/shared/video/videos-selection.component'
|
||||
import { NumberFormatterPipe } from '@app/shared/angular/number-formatter.pipe'
|
||||
import { VideoDurationPipe } from '@app/shared/angular/video-duration-formatter.pipe'
|
||||
import { ObjectLengthPipe } from '@app/shared/angular/object-length.pipe'
|
||||
import { FromNowPipe } from '@app/shared/angular/from-now.pipe'
|
||||
import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive'
|
||||
|
@ -147,6 +148,7 @@ import { InputReadonlyCopyComponent } from '@app/shared/forms/input-readonly-cop
|
|||
ObjectLengthPipe,
|
||||
FromNowPipe,
|
||||
PeerTubeTemplateDirective,
|
||||
VideoDurationPipe,
|
||||
|
||||
ActionDropdownComponent,
|
||||
MarkdownTextareaComponent,
|
||||
|
@ -248,7 +250,8 @@ import { InputReadonlyCopyComponent } from '@app/shared/forms/input-readonly-cop
|
|||
NumberFormatterPipe,
|
||||
ObjectLengthPipe,
|
||||
FromNowPipe,
|
||||
PeerTubeTemplateDirective
|
||||
PeerTubeTemplateDirective,
|
||||
VideoDurationPipe
|
||||
],
|
||||
|
||||
providers: [
|
||||
|
|
|
@ -226,6 +226,11 @@
|
|||
class="video-attribute-value" [routerLink]="[ '/search' ]" [queryParams]="{ tagsOneOf: [ tag ] }"
|
||||
>{{ tag }}</a>
|
||||
</div>
|
||||
|
||||
<div class="video-attribute">
|
||||
<span i18n class="video-attribute-label">Duration</span>
|
||||
<span class="video-attribute-value">{{ video.duration | myVideoDurationFormatter }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<my-video-comments
|
||||
|
|
Loading…
Reference in a new issue