From 244b4ae3973bc1511464a08158a123767f83179c Mon Sep 17 00:00:00 2001 From: BO41 Date: Thu, 18 Oct 2018 09:08:59 +0200 Subject: NoImplicitAny flag true (#1157) this enables the `noImplicitAny` flag in the Typescript compiler > When the noImplicitAny flag is true and the TypeScript compiler cannot infer the type, it still generates the JavaScript files, but it also reports an error. Many seasoned developers prefer this stricter setting because type checking catches more unintentional errors at compile time. closes: #1131 replaces #1137 --- client/src/standalone/videos/embed.ts | 4 ++-- client/src/standalone/videos/test-embed.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index ea3436c7c..e5a2d208a 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -17,7 +17,7 @@ import 'core-js/es6/set' // For google bot that uses Chrome 41 and does not understand fetch import 'whatwg-fetch' -import * as vjs from 'video.js' +const vjs = require('video.js') import * as Channel from 'jschannel' import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' @@ -304,7 +304,7 @@ class PeerTubeEmbed { this.playerOptions = videojsOptions this.player = vjs(this.videoContainerId, videojsOptions, () => { - this.player.on('customError', (event, data) => this.handleError(data.err)) + this.player.on('customError', (data: any) => this.handleError(data.err)) window[ 'videojsPlayer' ] = this.player diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts index dba331e90..b750c2ee6 100644 --- a/client/src/standalone/videos/test-embed.ts +++ b/client/src/standalone/videos/test-embed.ts @@ -66,11 +66,11 @@ window.addEventListener('load', async () => { updateRates() }) - let updateResolutions = resolutions => { + let updateResolutions = ((resolutions: any) => { let resolutionListEl = document.querySelector('#resolution-list') resolutionListEl.innerHTML = '' - resolutions.forEach(resolution => { + resolutions.forEach((resolution: any) => { if (resolution.active) { let itemEl = document.createElement('strong') itemEl.innerText = `${resolution.label} (active)` @@ -87,7 +87,7 @@ window.addEventListener('load', async () => { resolutionListEl.appendChild(itemEl) } }) - } + }) player.getResolutions().then( resolutions => updateResolutions(resolutions)) -- cgit v1.2.3 From c199c427d4ae586339822320f20f512a7a19dc3f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Oct 2018 14:35:31 +0200 Subject: Better typings --- client/src/standalone/videos/embed.ts | 7 +++++-- client/src/standalone/videos/test-embed.ts | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index e5a2d208a..7b269eeb9 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -17,7 +17,10 @@ import 'core-js/es6/set' // For google bot that uses Chrome 41 and does not understand fetch import 'whatwg-fetch' -const vjs = require('video.js') +// FIXME: something weird with our path definition in tsconfig and typings +// @ts-ignore +import vjs from 'video.js' + import * as Channel from 'jschannel' import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' @@ -304,7 +307,7 @@ class PeerTubeEmbed { this.playerOptions = videojsOptions this.player = vjs(this.videoContainerId, videojsOptions, () => { - this.player.on('customError', (data: any) => this.handleError(data.err)) + this.player.on('customError', (event: any, data: any) => this.handleError(data.err)) window[ 'videojsPlayer' ] = this.player diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts index b750c2ee6..30a298573 100644 --- a/client/src/standalone/videos/test-embed.ts +++ b/client/src/standalone/videos/test-embed.ts @@ -1,6 +1,6 @@ import './test-embed.scss' import { PeerTubePlayer } from '../player/player' -import { PlayerEventType } from '../player/definitions' +import { PeerTubeResolution, PlayerEventType } from '../player/definitions' window.addEventListener('load', async () => { const urlParts = window.location.href.split('/') @@ -66,11 +66,11 @@ window.addEventListener('load', async () => { updateRates() }) - let updateResolutions = ((resolutions: any) => { + let updateResolutions = ((resolutions: PeerTubeResolution[]) => { let resolutionListEl = document.querySelector('#resolution-list') resolutionListEl.innerHTML = '' - resolutions.forEach((resolution: any) => { + resolutions.forEach(resolution => { if (resolution.active) { let itemEl = document.createElement('strong') itemEl.innerText = `${resolution.label} (active)` -- cgit v1.2.3 From e0628695c3425bf69b5d7a46b24dcdf31892d9b6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Oct 2018 08:37:10 +0200 Subject: Fix embed --- client/src/standalone/videos/embed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 7b269eeb9..c113c67da 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -19,7 +19,7 @@ import 'whatwg-fetch' // FIXME: something weird with our path definition in tsconfig and typings // @ts-ignore -import vjs from 'video.js' +import * as vjs from 'video.js' import * as Channel from 'jschannel' -- cgit v1.2.3 From 6385c0cb7f773f5212a96807468988e17dba1d6d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Nov 2018 16:57:59 +0100 Subject: Fix embed video id parsing --- client/src/standalone/videos/embed.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index c113c67da..7daa03f23 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -256,9 +256,8 @@ class PeerTubeEmbed { } private async initCore () { - const urlParts = window.location.href.split('/') - const lastPart = urlParts[ urlParts.length - 1 ] - const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ] + const urlParts = window.location.pathname.split('/') + const videoId = urlParts[ urlParts.length - 1 ] const [ , serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ loadLocaleInVideoJS(window.location.origin, vjs, navigator.language), -- cgit v1.2.3 From 3b019808ef529cacce7f40706441670309e231d1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Dec 2018 14:14:54 +0100 Subject: Set last subtitle or subtitle in URL --- client/src/standalone/videos/embed.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 7daa03f23..3a09f285e 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -157,10 +157,11 @@ class PeerTubeEmbed { player: any playerOptions: any api: PeerTubeEmbedApi = null - autoplay = false - controls = true - muted = false - loop = false + autoplay: boolean + controls: boolean + muted: boolean + loop: boolean + subtitle: string enableApi = false startTime: number | string = 0 scope = 'peertube' @@ -214,11 +215,11 @@ class PeerTubeEmbed { this.displayError(text) } - getParamToggle (params: URLSearchParams, name: string, defaultValue: boolean) { + getParamToggle (params: URLSearchParams, name: string, defaultValue?: boolean) { return params.has(name) ? (params.get(name) === '1' || params.get(name) === 'true') : defaultValue } - getParamString (params: URLSearchParams, name: string, defaultValue: string) { + getParamString (params: URLSearchParams, name: string, defaultValue?: string) { return params.has(name) ? params.get(name) : defaultValue } @@ -241,15 +242,15 @@ class PeerTubeEmbed { try { let params = new URL(window.location.toString()).searchParams - this.autoplay = this.getParamToggle(params, 'autoplay', this.autoplay) - this.controls = this.getParamToggle(params, 'controls', this.controls) - this.muted = this.getParamToggle(params, 'muted', this.muted) - this.loop = this.getParamToggle(params, 'loop', this.loop) + this.autoplay = this.getParamToggle(params, 'autoplay') + this.controls = this.getParamToggle(params, 'controls') + this.muted = this.getParamToggle(params, 'muted') + this.loop = this.getParamToggle(params, 'loop') this.enableApi = this.getParamToggle(params, 'api', this.enableApi) - this.scope = this.getParamString(params, 'scope', this.scope) - const startTimeParamString = params.get('start') - if (startTimeParamString) this.startTime = startTimeParamString + this.scope = this.getParamString(params, 'scope', this.scope) + this.subtitle = this.getParamString(params, 'subtitle') + this.startTime = this.getParamString(params, 'start') } catch (err) { console.error('Cannot get params from URL.', err) } @@ -291,6 +292,7 @@ class PeerTubeEmbed { muted: this.muted, loop: this.loop, startTime: this.startTime, + subtitle: this.subtitle, videoCaptions, inactivityTimeout: 1500, -- cgit v1.2.3 From ad3fa0c56715f98886b1b6400fc54ce7d568d899 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Jan 2019 17:45:02 +0100 Subject: Add missing translations in embed template --- client/src/standalone/videos/embed.html | 2 +- client/src/standalone/videos/embed.ts | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.html b/client/src/standalone/videos/embed.html index b7cf13ec2..f79cf68df 100644 --- a/client/src/standalone/videos/embed.html +++ b/client/src/standalone/videos/embed.html @@ -13,7 +13,7 @@
-

Sorry

+

diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 3a09f285e..54b8fb543 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -192,27 +192,33 @@ class PeerTubeEmbed { element.parentElement.removeChild(element) } - displayError (text: string) { + displayError (text: string, translations?: { [ id: string ]: string }) { // Remove video element if (this.videoElement) this.removeElement(this.videoElement) - document.title = 'Sorry - ' + text + const translatedText = peertubeTranslate(text, translations) + const translatedSorry = peertubeTranslate('Sorry', translations) + + document.title = translatedSorry + ' - ' + translatedText const errorBlock = document.getElementById('error-block') errorBlock.style.display = 'flex' + const errorTitle = document.getElementById('error-title') + errorTitle.innerHTML = peertubeTranslate('Sorry', translations) + const errorText = document.getElementById('error-content') - errorText.innerHTML = text + errorText.innerHTML = translatedText } - videoNotFound () { + videoNotFound (translations?: { [ id: string ]: string }) { const text = 'This video does not exist.' - this.displayError(text) + this.displayError(text, translations) } - videoFetchError () { + videoFetchError (translations?: { [ id: string ]: string }) { const text = 'We cannot fetch the video. Please try again later.' - this.displayError(text) + this.displayError(text, translations) } getParamToggle (params: URLSearchParams, name: string, defaultValue?: boolean) { @@ -268,9 +274,9 @@ class PeerTubeEmbed { ]) if (!videoResponse.ok) { - if (videoResponse.status === 404) return this.videoNotFound() + if (videoResponse.status === 404) return this.videoNotFound(serverTranslations) - return this.videoFetchError() + return this.videoFetchError(serverTranslations) } const videoInfo: VideoDetails = await videoResponse.json() @@ -308,7 +314,7 @@ class PeerTubeEmbed { this.playerOptions = videojsOptions this.player = vjs(this.videoContainerId, videojsOptions, () => { - this.player.on('customError', (event: any, data: any) => this.handleError(data.err)) + this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations)) window[ 'videojsPlayer' ] = this.player @@ -325,11 +331,11 @@ class PeerTubeEmbed { }) } - private handleError (err: Error) { + private handleError (err: Error, translations?: { [ id: string ]: string }) { if (err.message.indexOf('from xs param') !== -1) { this.player.dispose() this.videoElement = null - this.displayError('This video is not available because the remote instance is not responding.') + this.displayError('This video is not available because the remote instance is not responding.', translations) return } } -- cgit v1.2.3 From 9fb6cfc49b38d006d1d25e09efedf15f87c44310 Mon Sep 17 00:00:00 2001 From: buoyantair Date: Thu, 31 Jan 2019 21:02:40 +0530 Subject: Add meta tag to embed.html --- client/src/standalone/videos/embed.html | 1 + 1 file changed, 1 insertion(+) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.html b/client/src/standalone/videos/embed.html index f79cf68df..c3b6e08ca 100644 --- a/client/src/standalone/videos/embed.html +++ b/client/src/standalone/videos/embed.html @@ -6,6 +6,7 @@ + -- cgit v1.2.3 From 2adfc7ea9a1f858db874df9fe322e7ae833db77c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 23 Jan 2019 15:36:45 +0100 Subject: Refractor videojs player Add fake p2p-media-loader plugin --- client/src/standalone/videos/embed.ts | 108 +++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 49 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 54b8fb543..b1261c4a2 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -17,17 +17,13 @@ import 'core-js/es6/set' // For google bot that uses Chrome 41 and does not understand fetch import 'whatwg-fetch' -// FIXME: something weird with our path definition in tsconfig and typings -// @ts-ignore -import * as vjs from 'video.js' - import * as Channel from 'jschannel' import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' -import { addContextMenu, getServerTranslations, getVideojsOptions, loadLocaleInVideoJS } from '../../assets/player/peertube-player' import { PeerTubeResolution } from '../player/definitions' import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' +import { PeertubePlayerManager, PeertubePlayerManagerOptions } from '../../assets/player/peertube-player-manager' /** * Embed API exposes control of the embed player to the outside world via @@ -73,16 +69,16 @@ class PeerTubeEmbedApi { } private setResolution (resolutionId: number) { - if (resolutionId === -1 && this.embed.player.peertube().isAutoResolutionForbidden()) return + if (resolutionId === -1 && this.embed.player.webtorrent().isAutoResolutionForbidden()) return // Auto resolution if (resolutionId === -1) { - this.embed.player.peertube().enableAutoResolution() + this.embed.player.webtorrent().enableAutoResolution() return } - this.embed.player.peertube().disableAutoResolution() - this.embed.player.peertube().updateResolution(resolutionId) + this.embed.player.webtorrent().disableAutoResolution() + this.embed.player.webtorrent().updateResolution(resolutionId) } /** @@ -122,15 +118,17 @@ class PeerTubeEmbedApi { // PeerTube specific capabilities - this.embed.player.peertube().on('autoResolutionUpdate', () => this.loadResolutions()) - this.embed.player.peertube().on('videoFileUpdate', () => this.loadResolutions()) + if (this.embed.player.webtorrent) { + this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions()) + this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions()) + } } - private loadResolutions () { + private loadWebTorrentResolutions () { let resolutions = [] - let currentResolutionId = this.embed.player.peertube().getCurrentResolutionId() + let currentResolutionId = this.embed.player.webtorrent().getCurrentResolutionId() - for (const videoFile of this.embed.player.peertube().videoFiles) { + for (const videoFile of this.embed.player.webtorrent().videoFiles) { let label = videoFile.resolution.label if (videoFile.fps && videoFile.fps >= 50) { label += videoFile.fps @@ -266,9 +264,8 @@ class PeerTubeEmbed { const urlParts = window.location.pathname.split('/') const videoId = urlParts[ urlParts.length - 1 ] - const [ , serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ - loadLocaleInVideoJS(window.location.origin, vjs, navigator.language), - getServerTranslations(window.location.origin, navigator.language), + const [ serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ + PeertubePlayerManager.getServerTranslations(window.location.origin, navigator.language), this.loadVideoInfo(videoId), this.loadVideoCaptions(videoId) ]) @@ -292,43 +289,56 @@ class PeerTubeEmbed { this.loadParams() - const videojsOptions = getVideojsOptions({ - autoplay: this.autoplay, - controls: this.controls, - muted: this.muted, - loop: this.loop, - startTime: this.startTime, - subtitle: this.subtitle, - - videoCaptions, - inactivityTimeout: 1500, - videoViewUrl: this.getVideoUrl(videoId) + '/views', - playerElement: this.videoElement, - videoFiles: videoInfo.files, - videoDuration: videoInfo.duration, - enableHotkeys: true, - peertubeLink: true, - poster: window.location.origin + videoInfo.previewPath, - theaterMode: false - }) + const options: PeertubePlayerManagerOptions = { + common: { + autoplay: this.autoplay, + controls: this.controls, + muted: this.muted, + loop: this.loop, + captions: videoCaptions.length !== 0, + startTime: this.startTime, + subtitle: this.subtitle, + + videoCaptions, + inactivityTimeout: 1500, + videoViewUrl: this.getVideoUrl(videoId) + '/views', + playerElement: this.videoElement, + videoDuration: videoInfo.duration, + enableHotkeys: true, + peertubeLink: true, + poster: window.location.origin + videoInfo.previewPath, + theaterMode: false, + + serverUrl: window.location.origin, + language: navigator.language, + embedUrl: window.location.origin + videoInfo.embedPath + }, + + webtorrent: { + videoFiles: videoInfo.files + } + + // p2pMediaLoader: { + // // playlistUrl: 'https://akamai-axtest.akamaized.net/routes/lapd-v1-acceptance/www_c4/Manifest.m3u8' + // // playlistUrl: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8' + // playlistUrl: 'https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8' + // } + } - this.playerOptions = videojsOptions - this.player = vjs(this.videoContainerId, videojsOptions, () => { - this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations)) + this.player = await PeertubePlayerManager.initialize('webtorrent', options) - window[ 'videojsPlayer' ] = this.player + this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations)) - if (this.controls) { - this.player.dock({ - title: videoInfo.name, - description: this.player.localize('Uses P2P, others may know your IP is downloading this video.') - }) - } + window[ 'videojsPlayer' ] = this.player - addContextMenu(this.player, window.location.origin + videoInfo.embedPath) + if (this.controls) { + this.player.dock({ + title: videoInfo.name, + description: this.player.localize('Uses P2P, others may know your IP is downloading this video.') + }) + } - this.initializeApi() - }) + this.initializeApi() } private handleError (err: Error, translations?: { [ id: string ]: string }) { -- cgit v1.2.3 From 3b6f205c34bb931de0323581edf991ca33256e6b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 24 Jan 2019 10:16:30 +0100 Subject: Correctly implement p2p-media-loader --- client/src/standalone/videos/embed.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index b1261c4a2..0d165ea7b 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -23,7 +23,7 @@ import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' import { PeerTubeResolution } from '../player/definitions' import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' -import { PeertubePlayerManager, PeertubePlayerManagerOptions } from '../../assets/player/peertube-player-manager' +import { PeertubePlayerManager, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player/peertube-player-manager' /** * Embed API exposes control of the embed player to the outside world via @@ -162,6 +162,7 @@ class PeerTubeEmbed { subtitle: string enableApi = false startTime: number | string = 0 + mode: PlayerMode scope = 'peertube' static async main () { @@ -255,6 +256,8 @@ class PeerTubeEmbed { this.scope = this.getParamString(params, 'scope', this.scope) this.subtitle = this.getParamString(params, 'subtitle') this.startTime = this.getParamString(params, 'start') + + this.mode = this.getParamToggle(params, 'p2p-media-loader') ? 'p2p-media-loader' : 'webtorrent' } catch (err) { console.error('Cannot get params from URL.', err) } @@ -312,20 +315,26 @@ class PeerTubeEmbed { serverUrl: window.location.origin, language: navigator.language, embedUrl: window.location.origin + videoInfo.embedPath - }, - - webtorrent: { - videoFiles: videoInfo.files } + } - // p2pMediaLoader: { - // // playlistUrl: 'https://akamai-axtest.akamaized.net/routes/lapd-v1-acceptance/www_c4/Manifest.m3u8' - // // playlistUrl: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8' - // playlistUrl: 'https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8' - // } + if (this.mode === 'p2p-media-loader') { + Object.assign(options, { + p2pMediaLoader: { + // playlistUrl: 'https://akamai-axtest.akamaized.net/routes/lapd-v1-acceptance/www_c4/Manifest.m3u8' + // playlistUrl: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8' + playlistUrl: 'https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8' + } + }) + } else { + Object.assign(options, { + webtorrent: { + videoFiles: videoInfo.files + } + }) } - this.player = await PeertubePlayerManager.initialize('webtorrent', options) + this.player = await PeertubePlayerManager.initialize(this.mode, options) this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations)) -- cgit v1.2.3 From 4348a27d252a3349bafa7ef4859c0e2cf060c255 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 24 Jan 2019 13:43:44 +0100 Subject: Add lazy loading in player --- client/src/standalone/videos/embed.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 0d165ea7b..6dd9a3d76 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -323,6 +323,7 @@ class PeerTubeEmbed { p2pMediaLoader: { // playlistUrl: 'https://akamai-axtest.akamaized.net/routes/lapd-v1-acceptance/www_c4/Manifest.m3u8' // playlistUrl: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8' + // trackerAnnounce: [ window.location.origin.replace(/^http/, 'ws') + '/tracker/socket' ], playlistUrl: 'https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8' } }) -- cgit v1.2.3 From 092092969633bbcf6d4891a083ea497a7d5c3154 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Jan 2019 08:37:25 +0100 Subject: Add hls support on server --- client/src/standalone/videos/embed.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 6dd9a3d76..1e58d42d9 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -23,7 +23,13 @@ import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' import { PeerTubeResolution } from '../player/definitions' import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' -import { PeertubePlayerManager, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player/peertube-player-manager' +import { + P2PMediaLoaderOptions, + PeertubePlayerManager, + PeertubePlayerManagerOptions, + PlayerMode +} from '../../assets/player/peertube-player-manager' +import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' /** * Embed API exposes control of the embed player to the outside world via @@ -319,13 +325,16 @@ class PeerTubeEmbed { } if (this.mode === 'p2p-media-loader') { + const hlsPlaylist = videoInfo.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS) + Object.assign(options, { p2pMediaLoader: { - // playlistUrl: 'https://akamai-axtest.akamaized.net/routes/lapd-v1-acceptance/www_c4/Manifest.m3u8' - // playlistUrl: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8' - // trackerAnnounce: [ window.location.origin.replace(/^http/, 'ws') + '/tracker/socket' ], - playlistUrl: 'https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8' - } + playlistUrl: hlsPlaylist.playlistUrl, + segmentsSha256Url: hlsPlaylist.segmentsSha256Url, + redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl), + trackerAnnounce: videoInfo.trackerUrls, + videoFiles: videoInfo.files + } as P2PMediaLoaderOptions }) } else { Object.assign(options, { -- cgit v1.2.3 From 6ec0b75beb9c8bcd84e178912319913b91830da2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Feb 2019 10:39:50 +0100 Subject: Fallback HLS to webtorrent --- client/src/standalone/videos/embed.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 1e58d42d9..c5c46d0c5 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -311,7 +311,10 @@ class PeerTubeEmbed { videoCaptions, inactivityTimeout: 1500, videoViewUrl: this.getVideoUrl(videoId) + '/views', + playerElement: this.videoElement, + onPlayerElementChange: (element: HTMLVideoElement) => this.videoElement = element, + videoDuration: videoInfo.duration, enableHotkeys: true, peertubeLink: true, @@ -321,6 +324,10 @@ class PeerTubeEmbed { serverUrl: window.location.origin, language: navigator.language, embedUrl: window.location.origin + videoInfo.embedPath + }, + + webtorrent: { + videoFiles: videoInfo.files } } @@ -336,12 +343,6 @@ class PeerTubeEmbed { videoFiles: videoInfo.files } as P2PMediaLoaderOptions }) - } else { - Object.assign(options, { - webtorrent: { - videoFiles: videoInfo.files - } - }) } this.player = await PeertubePlayerManager.initialize(this.mode, options) -- cgit v1.2.3 From 597a9266d426aa04c2f229168e4285a76bea2c12 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Feb 2019 15:56:17 +0100 Subject: Add player mode in watch/embed urls --- client/src/standalone/videos/embed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index c5c46d0c5..32bf42e12 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -263,7 +263,7 @@ class PeerTubeEmbed { this.subtitle = this.getParamString(params, 'subtitle') this.startTime = this.getParamString(params, 'start') - this.mode = this.getParamToggle(params, 'p2p-media-loader') ? 'p2p-media-loader' : 'webtorrent' + this.mode = this.getParamString(params, 'mode') === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent' } catch (err) { console.error('Cannot get params from URL.', err) } -- cgit v1.2.3