import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { HTMLServerConfig, PeerTubeProblemDocument, ServerErrorCode, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
+import { timeToInt } from '@shared/core-utils'
+import {
+ HTMLServerConfig,
+ HttpStatusCode,
+ PeerTubeProblemDocument,
+ ServerErrorCode,
+ VideoCaption,
+ VideoPrivacy,
+ VideoState
+} from '@shared/models'
import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage'
import {
CustomizationOptions,
PlayerMode,
videojs
} from '../../../assets/player/peertube-player-manager'
-import { timeToInt } from '../../../assets/player/utils'
import { environment } from '../../../environments/environment'
import { VideoWatchPlaylistComponent } from './shared'
return this.userService.getAnonymousUser()
}
- async ngOnInit () {
+ ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig()
PeertubePlayerManager.initState()
private loadRouteParams () {
this.paramsSub = this.route.params.subscribe(routeParams => {
- const videoId = routeParams[ 'videoId' ]
+ const videoId = routeParams['videoId']
if (videoId) return this.loadVideo(videoId)
- const playlistId = routeParams[ 'playlistId' ]
+ const playlistId = routeParams['playlistId']
if (playlistId) return this.loadPlaylist(playlistId)
})
}
private loadRouteQuery () {
this.queryParamsSub = this.route.queryParams.subscribe(queryParams => {
// Handle the ?playlistPosition
- const positionParam = queryParams[ 'playlistPosition' ] ?? 1
+ const positionParam = queryParams['playlistPosition'] ?? 1
this.playlistPosition = positionParam === 'last'
? -1 // Handle the "last" index
this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition)
- const start = queryParams[ 'start' ]
+ const start = queryParams['start']
if (this.player && start) this.player.currentTime(parseInt(start, 10))
})
}
'filter:api.video-watch.video.get.result'
)
- forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId)])
- .subscribe(
- ([ video, captionsResult ]) => {
+ forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId) ])
+ .subscribe({
+ next: ([ video, captionsResult ]) => {
const queryParams = this.route.snapshot.queryParams
const urlOptions = {
.catch(err => this.handleGlobalError(err))
},
- err => this.handleRequestError(err)
- )
+ error: err => this.handleRequestError(err)
+ })
}
private loadPlaylist (playlistId: string) {
if (this.isSameElement(this.playlist, playlistId)) return
this.playlistService.getVideoPlaylist(playlistId)
- .subscribe(
- playlist => {
+ .subscribe({
+ next: playlist => {
this.playlist = playlist
this.videoWatchPlaylist.loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition)
},
- err => this.handleRequestError(err)
- )
+ error: err => this.handleRequestError(err)
+ })
}
private isSameElement (element: VideoDetails | VideoPlaylist, newId: string) {
const originUrl = errorBody.originUrl + (window.location.search ?? '')
const res = await this.confirmService.confirm(
+ // eslint-disable-next-line max-len
$localize`This video is not available on this instance. Do you want to be redirected on the origin instance: <a href="${originUrl}">${originUrl}</a>?`,
$localize`Redirection`
)
if (!errorMessage) return
// Display a message in the video player instead of a notification
- if (errorMessage.indexOf('from xs param') !== -1) {
+ if (errorMessage.includes('from xs param')) {
this.flushPlayer()
this.remoteServerDown = true
this.zone.run(() => this.theaterEnabled = enabled)
})
- this.hooks.runAction('action:video-watch.player.loaded', 'video-watch', { player: this.player, videojs, video: this.video })
+ this.hooks.runAction('action:video-watch.player.loaded', 'video-watch', {
+ player: this.player,
+ playlist: this.playlist,
+ playlistPosition: this.playlistPosition,
+ videojs,
+ video: this.video
+ })
})
}
if (this.nextVideoUUID) {
this.router.navigate([ '/w', this.nextVideoUUID ])
- return
}
}
private isAutoPlayNext () {
return (
- (this.user && this.user.autoPlayNextVideo) ||
+ (this.user?.autoPlayNextVideo) ||
this.anonymousUser.autoPlayNextVideo
)
}
private isPlaylistAutoPlayNext () {
return (
- (this.user && this.user.autoPlayNextVideoPlaylist) ||
+ (this.user?.autoPlayNextVideoPlaylist) ||
this.anonymousUser.autoPlayNextVideoPlaylist
)
}
}
private buildPlayerManagerOptions (params: {
- video: VideoDetails,
- videoCaptions: VideoCaption[],
- urlOptions: CustomizationOptions & { playerMode: PlayerMode },
+ video: VideoDetails
+ videoCaptions: VideoCaption[]
+ urlOptions: CustomizationOptions & { playerMode: PlayerMode }
user?: AuthUser
}) {
const { video, videoCaptions, urlOptions, user } = params
language: this.localeId,
- userWatching: user && user.videosHistoryEnabled === true ? {
- url: this.videoService.getUserWatchingVideoUrl(video.uuid),
- authorizationHeader: this.authService.getRequestHeaderValue()
- } : undefined,
+ userWatching: user && user.videosHistoryEnabled === true
+ ? {
+ url: this.videoService.getUserWatchingVideoUrl(video.uuid),
+ authorizationHeader: this.authService.getRequestHeaderValue()
+ }
+ : undefined,
serverUrl: environment.apiUrl,
videoCaptions: playerCaptions,
+ videoShortUUID: video.shortUUID,
videoUUID: video.uuid
},
}
if (oldVideo && oldVideo.id !== newVideo.id) {
- await this.peertubeSocket.unsubscribeLiveVideos(oldVideo.id)
+ this.peertubeSocket.unsubscribeLiveVideos(oldVideo.id)
}
if (!newVideo.isLive) return
if (this.isUserLoggedIn()) {
this.hotkeys = this.hotkeys.concat([
new Hotkey('shift+s', () => {
- this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
+ if (this.subscribeButton.isSubscribedToAll()) this.subscribeButton.unsubscribe()
+ else this.subscribeButton.subscribe()
+
return false
}, undefined, $localize`Subscribe to the account`)
])