mirror of https://github.com/Chocobozzz/PeerTube
Add duration to video attributes in watch view
parent
31174a272a
commit
df8340b7b8
|
@ -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 { VideoPlaylistElementMiniatureComponent } from '@app/shared/video-playlist/video-playlist-element-miniature.component'
|
||||||
import { VideosSelectionComponent } from '@app/shared/video/videos-selection.component'
|
import { VideosSelectionComponent } from '@app/shared/video/videos-selection.component'
|
||||||
import { NumberFormatterPipe } from '@app/shared/angular/number-formatter.pipe'
|
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 { ObjectLengthPipe } from '@app/shared/angular/object-length.pipe'
|
||||||
import { FromNowPipe } from '@app/shared/angular/from-now.pipe'
|
import { FromNowPipe } from '@app/shared/angular/from-now.pipe'
|
||||||
import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive'
|
import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive'
|
||||||
|
@ -147,6 +148,7 @@ import { InputReadonlyCopyComponent } from '@app/shared/forms/input-readonly-cop
|
||||||
ObjectLengthPipe,
|
ObjectLengthPipe,
|
||||||
FromNowPipe,
|
FromNowPipe,
|
||||||
PeerTubeTemplateDirective,
|
PeerTubeTemplateDirective,
|
||||||
|
VideoDurationPipe,
|
||||||
|
|
||||||
ActionDropdownComponent,
|
ActionDropdownComponent,
|
||||||
MarkdownTextareaComponent,
|
MarkdownTextareaComponent,
|
||||||
|
@ -248,7 +250,8 @@ import { InputReadonlyCopyComponent } from '@app/shared/forms/input-readonly-cop
|
||||||
NumberFormatterPipe,
|
NumberFormatterPipe,
|
||||||
ObjectLengthPipe,
|
ObjectLengthPipe,
|
||||||
FromNowPipe,
|
FromNowPipe,
|
||||||
PeerTubeTemplateDirective
|
PeerTubeTemplateDirective,
|
||||||
|
VideoDurationPipe
|
||||||
],
|
],
|
||||||
|
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -226,6 +226,11 @@
|
||||||
class="video-attribute-value" [routerLink]="[ '/search' ]" [queryParams]="{ tagsOneOf: [ tag ] }"
|
class="video-attribute-value" [routerLink]="[ '/search' ]" [queryParams]="{ tagsOneOf: [ tag ] }"
|
||||||
>{{ tag }}</a>
|
>{{ tag }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="video-attribute">
|
||||||
|
<span i18n class="video-attribute-label">Duration</span>
|
||||||
|
<span class="video-attribute-value">{{ video.duration | myVideoDurationFormatter }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<my-video-comments
|
<my-video-comments
|
||||||
|
|
Loading…
Reference in New Issue