import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
+import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component'
import { MetaService } from '@ngx-meta/core'
import { NotificationsService } from 'angular2-notifications'
import { Observable } from 'rxjs/Observable'
@ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
@ViewChild('videoShareModal') videoShareModal: VideoShareComponent
@ViewChild('videoReportModal') videoReportModal: VideoReportComponent
+ @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent
otherVideosDisplayed: Video[] = []
this.player.pause()
}
- let uuid = routeParams['uuid']
+ const uuid = routeParams['uuid']
+ // Video did not changed
+ if (this.video && this.video.uuid === uuid) return
+
this.videoService.getVideo(uuid).subscribe(
video => this.onVideoFetched(video),
this.videoReportModal.show()
}
+ showSupportModal () {
+ this.videoSupportModal.show()
+ }
+
showShareModal () {
this.videoShareModal.show()
}
return Account.GET_ACCOUNT_AVATAR_URL(this.video.account)
}
+ getVideoPoster () {
+ if (!this.video) return ''
+
+ return this.video.previewUrl
+ }
+
getVideoTags () {
if (!this.video || Array.isArray(this.video.tags) === false) return []
return
}
- this.videoHTMLDescription = this.markdownService.markdownToHTML(this.video.description)
+ this.videoHTMLDescription = this.markdownService.textMarkdownToHTML(this.video.description)
}
private setVideoLikesBarTooltipText () {
peertube: {
videoFiles: this.video.files,
playerElement: this.playerElement,
- peerTubeLink: false
+ peerTubeLink: false,
+ videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid),
+ videoDuration: this.video.duration
},
hotkeys: {
enableVolumeScroll: false
})
})
} else {
- this.player.peertube().setVideoFiles(this.video.files)
+ const videoViewUrl = this.videoService.getVideoViewUrl(this.video.uuid)
+ this.player.peertube().setVideoFiles(this.video.files, videoViewUrl, this.video.duration)
}
this.setVideoDescriptionHTML()
this.setOpenGraphTags()
this.checkUserRating()
-
- this.prepareViewAdd()
}
)
}
this.metaService.setTag('url', window.location.href)
}
- private prepareViewAdd () {
- // After 30 seconds (or 3/4 of the video), increment add a view
- let viewTimeoutSeconds = 30
- if (this.video.duration < viewTimeoutSeconds) viewTimeoutSeconds = (this.video.duration * 3) / 4
-
- setTimeout(() => {
- this.videoService
- .viewVideo(this.video.uuid)
- .subscribe()
-
- }, viewTimeoutSeconds * 1000)
- }
-
private isAutoplay () {
// True by default
if (!this.user) return true