Notifier,
PeerTubeSocket,
RestExtractor,
+ ScreenService,
ServerService,
UserService
} from '@app/core'
player: any
playerElement: HTMLVideoElement
+
theaterEnabled = false
+
userRating: UserVideoRateType = null
- descriptionLoading = false
+
+ playerPlaceholderImgSrc: string
video: VideoDetails = null
videoCaptions: VideoCaption[] = []
playlistPosition: number
playlist: VideoPlaylist = null
+ descriptionLoading = false
completeDescriptionShown = false
completeVideoDescription: string
shortVideoDescription: string
videoHTMLDescription = ''
+
likesBarTooltipText = ''
+
hasAlreadyAcceptedPrivacyConcern = false
remoteServerDown = false
+
hotkeys: Hotkey[] = []
tooltipLike = ''
private hotkeysService: HotkeysService,
private hooks: HooksService,
private peertubeSocket: PeerTubeSocket,
+ private screenService: ScreenService,
private location: PlatformLocation,
@Inject(LOCALE_ID) private localeId: string
- ) {
- this.tooltipLike = $localize`Like this video`
- this.tooltipDislike = $localize`Dislike this video`
- this.tooltipSupport = $localize`Support options for this video`
- this.tooltipSaveToPlaylist = $localize`Save to playlist`
- }
+ ) { }
get user () {
return this.authService.getUser()
}
async ngOnInit () {
+ // Hide the tooltips for unlogged users in mobile view, this adds confusion with the popover
+ if (this.user || !this.screenService.isInMobileView()) {
+ this.tooltipLike = $localize`Like this video`
+ this.tooltipDislike = $localize`Dislike this video`
+ this.tooltipSupport = $localize`Support options for this video`
+ this.tooltipSaveToPlaylist = $localize`Save to playlist`
+ }
+
PeertubePlayerManager.initState()
this.serverConfig = this.serverService.getTmpConfig()
}
handleTimestampClicked (timestamp: number) {
- if (this.player) this.player.currentTime(timestamp)
+ if (!this.player || this.video.isLive) return
+
+ this.player.currentTime(timestamp)
scrollToTop()
}
this.videoCaptionService.listCaptions(videoId)
])
.pipe(
- // If 401, the video is private or blocked so redirect to 404
+ // If 400, 403 or 404, the video is private or blocked so redirect to 404
catchError(err => {
if (err.body.errorCode === ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS && err.body.originUrl) {
const search = window.location.search
$localize`Redirection`
).then(res => {
if (res === false) {
- return this.restExtractor.redirectTo404IfNotFound(err, [
+ return this.restExtractor.redirectTo404IfNotFound(err, 'video', [
HttpStatusCode.BAD_REQUEST_400,
- HttpStatusCode.UNAUTHORIZED_401,
HttpStatusCode.FORBIDDEN_403,
HttpStatusCode.NOT_FOUND_404
])
})
}
- return this.restExtractor.redirectTo404IfNotFound(err, [
+ return this.restExtractor.redirectTo404IfNotFound(err, 'video', [
HttpStatusCode.BAD_REQUEST_400,
- HttpStatusCode.UNAUTHORIZED_401,
HttpStatusCode.FORBIDDEN_403,
HttpStatusCode.NOT_FOUND_404
])
this.playlistService.getVideoPlaylist(playlistId)
.pipe(
- // If 401, the video is private or blocked so redirect to 404
- catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [
+ // If 400 or 403, the video is private or blocked so redirect to 404
+ catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'video', [
HttpStatusCode.BAD_REQUEST_400,
- HttpStatusCode.UNAUTHORIZED_401,
HttpStatusCode.FORBIDDEN_403,
HttpStatusCode.NOT_FOUND_404
]))
this.videoCaptions = videoCaptions
// Re init attributes
+ this.playerPlaceholderImgSrc = undefined
this.descriptionLoading = false
this.completeDescriptionShown = false
+ this.completeVideoDescription = undefined
this.remoteServerDown = false
this.currentTime = undefined
if (res === false) return this.location.back()
}
- const videoState = this.video.state.id
- if (videoState === VideoState.LIVE_ENDED || videoState === VideoState.WAITING_FOR_LIVE) return
+ this.buildPlayer(urlOptions)
+ .catch(err => console.error('Cannot build the player', err))
+
+ this.setVideoDescriptionHTML()
+ this.setVideoLikesBarTooltipText()
+
+ this.setOpenGraphTags()
+ this.checkUserRating()
+
+ this.hooks.runAction('action:video-watch.video.loaded', 'video-watch', { videojs })
+ }
+ private async buildPlayer (urlOptions: URLOptions) {
// Flush old player if needed
this.flushPlayer()
+ const videoState = this.video.state.id
+ if (videoState === VideoState.LIVE_ENDED || videoState === VideoState.WAITING_FOR_LIVE) {
+ this.playerPlaceholderImgSrc = this.video.previewPath
+ return
+ }
+
// Build video element, because videojs removes it on dispose
const playerElementWrapper = this.elementRef.nativeElement.querySelector('#videojs-wrapper')
this.playerElement = document.createElement('video')
const params = {
video: this.video,
- videoCaptions,
+ videoCaptions: this.videoCaptions,
urlOptions,
user: this.user
}
this.hooks.runAction('action:video-watch.player.loaded', 'video-watch', { player: this.player, videojs, video: this.video })
})
-
- this.setVideoDescriptionHTML()
- this.setVideoLikesBarTooltipText()
-
- this.setOpenGraphTags()
- this.checkUserRating()
-
- this.hooks.runAction('action:video-watch.video.loaded', 'video-watch', { videojs })
}
private autoplayNext () {
return
}
+ console.log('Updating live views.')
+
this.video.views = newViews
}