]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/video/video-thumbnail.component.ts
Playlist support in watch page
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / video-thumbnail.component.ts
index e52f7dfb0824f2da18389a7a73a49d6a961c5a6c..fe65ade9442a1b5da0beedaab65b269fa699d0fd 100644 (file)
@@ -1,6 +1,6 @@
 import { Component, Input } from '@angular/core'
-import { isInMobileView } from '@app/shared/misc/utils'
 import { Video } from './video.model'
+import { ScreenService } from '@app/shared/misc/screen.service'
 
 @Component({
   selector: 'my-video-thumbnail',
@@ -10,14 +10,33 @@ import { Video } from './video.model'
 export class VideoThumbnailComponent {
   @Input() video: Video
   @Input() nsfw = false
+  @Input() routerLink: any[]
+  @Input() queryParams: any[]
+
+  constructor (private screenService: ScreenService) {
+  }
 
   getImageUrl () {
     if (!this.video) return ''
 
-    if (isInMobileView()) {
+    if (this.screenService.isInMobileView()) {
       return this.video.previewUrl
     }
 
     return this.video.thumbnailUrl
   }
+
+  getProgressPercent () {
+    if (!this.video.userHistory) return 0
+
+    const currentTime = this.video.userHistory.currentTime
+
+    return (currentTime / this.video.duration) * 100
+  }
+
+  getVideoRouterLink () {
+    if (this.routerLink) return this.routerLink
+
+    return [ '/videos/watch', this.video.uuid ]
+  }
 }