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({
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 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, subtitle, playerMode })
.catch(err => this.handleError(err))
})
})
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
}
)
}
- private async onVideoFetched (video: VideoDetails, videoCaptions: VideoCaption[], urlOptions: { startTime: number, subtitle: string }) {
+ private async onVideoFetched (
+ video: VideoDetails,
+ videoCaptions: VideoCaption[],
+ urlOptions: { startTime?: number, subtitle?: string, playerMode?: string }
+ ) {
this.video = video
// Re init attributes
}
}
- 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 () => {