+
+ 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 ]
+ }
+
+ isUserLoggedIn () {
+ return this.authService.isLoggedIn()
+ }
+
+ addToWatchLater () {
+ if (this.addedToWatchLater === undefined) return
+ this.addedToWatchLater = true
+
+ this.videoPlaylistService.addVideoInPlaylist(
+ this.watchLaterPlaylist.playlistId,
+ { videoId: this.video.id } as VideoPlaylistElementCreate
+ ).subscribe(
+ res => {
+ this.addedToWatchLater = true
+ this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id
+ }
+ )
+ }
+
+ removeFromWatchLater () {
+ if (this.addedToWatchLater === undefined) return
+ this.addedToWatchLater = false
+
+ this.videoPlaylistService.removeVideoFromPlaylist(
+ this.watchLaterPlaylist.playlistId,
+ this.watchLaterPlaylist.playlistElementId
+ ).subscribe(
+ _ => {
+ this.addedToWatchLater = false
+ }
+ )
+ }