import { Notifier, ServerService } from '@app/core'
import { forkJoin, Subscription } from 'rxjs'
import { Hotkey, HotkeysService } from 'angular2-hotkeys'
-import * as WebTorrent from 'webtorrent'
import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '../../../../../shared'
import { AuthService, ConfirmService } from '../../core'
import { RestExtractor, VideoBlacklistService } from '../../shared'
P2PMediaLoaderOptions,
PeertubePlayerManager,
PeertubePlayerManagerOptions,
- PlayerMode,
- WebtorrentOptions
+ PlayerMode
} from '../../../assets/player/peertube-player-manager'
@Component({
remoteServerDown = false
hotkeys: Hotkey[]
+ private currentTime: number
private paramsSub: Subscription
constructor (
ngOnInit () {
if (
- WebTorrent.WEBRTC_SUPPORT === false ||
+ !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false ||
peertubeLocalStorage.getItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
) {
this.hasAlreadyAcceptedPrivacyConcern = true
)
.subscribe(([ video, captionsResult ]) => {
const startTime = this.route.snapshot.queryParams.start
+ const stopTime = this.route.snapshot.queryParams.stop
const subtitle = this.route.snapshot.queryParams.subtitle
+ const playerMode = this.route.snapshot.queryParams.mode
- this.onVideoFetched(video, captionsResult.data, { startTime, subtitle })
+ this.onVideoFetched(video, captionsResult.data, { startTime, stopTime, subtitle, playerMode })
.catch(err => this.handleError(err))
})
})
showShareModal () {
const currentTime = this.player ? this.player.currentTime() : undefined
- this.videoShareModal.show(currentTime)
+ this.videoShareModal.show(this.currentTime)
}
showDownloadModal (event: Event) {
return this.video && this.video.state.id === VideoState.TO_TRANSCODE
}
+ isVideoDownloadable () {
+ return this.video && this.video.downloadEnabled
+ }
+
isVideoToImport () {
return this.video && this.video.state.id === VideoState.TO_IMPORT
}
this.setVideoDescriptionHTML()
}
- private setVideoDescriptionHTML () {
- this.videoHTMLDescription = this.markdownService.textMarkdownToHTML(this.video.description)
+ private async setVideoDescriptionHTML () {
+ this.videoHTMLDescription = await this.markdownService.textMarkdownToHTML(this.video.description)
}
private setVideoLikesBarTooltipText () {
)
}
- private async onVideoFetched (video: VideoDetails, videoCaptions: VideoCaption[], urlOptions: { startTime: number, subtitle: string }) {
+ private async onVideoFetched (
+ video: VideoDetails,
+ videoCaptions: VideoCaption[],
+ urlOptions: { startTime?: number, stopTime?: number, subtitle?: string, playerMode?: string }
+ ) {
this.video = video
// Re init attributes
this.descriptionLoading = false
this.completeDescriptionShown = false
this.remoteServerDown = false
+ this.currentTime = undefined
let startTime = urlOptions.startTime || (this.video.userHistory ? this.video.userHistory.currentTime : 0)
// If we are at the end of the video, reset the timer
inactivityTimeout: 2500,
poster: this.video.previewUrl,
startTime,
+ stopTime: urlOptions.stopTime,
theaterMode: true,
captions: videoCaptions.length !== 0,
}
}
- let mode: PlayerMode
- const hlsPlaylist = this.video.getHlsPlaylist()
- if (hlsPlaylist) {
- mode = 'p2p-media-loader'
+ const mode: PlayerMode = urlOptions.playerMode === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent'
+
+ if (mode === 'p2p-media-loader') {
+ const hlsPlaylist = this.video.getHlsPlaylist()
const p2pMediaLoader = {
playlistUrl: hlsPlaylist.playlistUrl,
} as P2PMediaLoaderOptions
Object.assign(options, { p2pMediaLoader })
- } else {
- mode = 'webtorrent'
}
this.zone.runOutsideAngular(async () => {
this.player = await PeertubePlayerManager.initialize(mode, options)
this.player.on('customError', ({ err }: { err: any }) => this.handleError(err))
+
+ this.player.on('timeupdate', () => {
+ this.currentTime = Math.floor(this.player.currentTime())
+ })
})
this.setVideoDescriptionHTML()