aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts24
1 files changed, 17 insertions, 7 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 2e090847c..91ca6a2aa 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -15,7 +15,6 @@ import './videojs-components/theater-button'
15import { P2PMediaLoaderPluginOptions, UserWatching, VideoJSCaption, VideoJSPluginOptions, videojsUntyped } from './peertube-videojs-typings' 15import { P2PMediaLoaderPluginOptions, UserWatching, VideoJSCaption, VideoJSPluginOptions, videojsUntyped } from './peertube-videojs-typings'
16import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' 16import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils'
17import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' 17import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n'
18import { Engine } from 'p2p-media-loader-hlsjs'
19 18
20// Change 'Playback Rate' to 'Speed' (smaller for our settings menu) 19// Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
21videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' 20videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
@@ -32,6 +31,7 @@ export type WebtorrentOptions = {
32 31
33export type P2PMediaLoaderOptions = { 32export type P2PMediaLoaderOptions = {
34 playlistUrl: string 33 playlistUrl: string
34 trackerAnnounce: string[]
35} 35}
36 36
37export type CommonOptions = { 37export type CommonOptions = {
@@ -88,10 +88,17 @@ export class PeertubePlayerManager {
88 } 88 }
89 89
90 static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions) { 90 static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions) {
91 let p2pMediaLoader: any
92
91 if (mode === 'webtorrent') await import('./webtorrent-plugin') 93 if (mode === 'webtorrent') await import('./webtorrent-plugin')
92 if (mode === 'p2p-media-loader') await import('./p2p-media-loader-plugin') 94 if (mode === 'p2p-media-loader') {
95 [ p2pMediaLoader ] = await Promise.all([
96 import('p2p-media-loader-hlsjs'),
97 import('./p2p-media-loader-plugin')
98 ])
99 }
93 100
94 const videojsOptions = this.getVideojsOptions(mode, options) 101 const videojsOptions = this.getVideojsOptions(mode, options, p2pMediaLoader)
95 102
96 await this.loadLocaleInVideoJS(options.common.serverUrl, options.common.language) 103 await this.loadLocaleInVideoJS(options.common.serverUrl, options.common.language)
97 104
@@ -133,7 +140,7 @@ export class PeertubePlayerManager {
133 return p.then(json => videojs.addLanguage(getShortLocale(completeLocale), json)) 140 return p.then(json => videojs.addLanguage(getShortLocale(completeLocale), json))
134 } 141 }
135 142
136 private static getVideojsOptions (mode: PlayerMode, options: PeertubePlayerManagerOptions) { 143 private static getVideojsOptions (mode: PlayerMode, options: PeertubePlayerManagerOptions, p2pMediaLoaderModule?: any) {
137 const commonOptions = options.common 144 const commonOptions = options.common
138 const webtorrentOptions = options.webtorrent 145 const webtorrentOptions = options.webtorrent
139 const p2pMediaLoaderOptions = options.p2pMediaLoader 146 const p2pMediaLoaderOptions = options.p2pMediaLoader
@@ -157,16 +164,19 @@ export class PeertubePlayerManager {
157 src: p2pMediaLoaderOptions.playlistUrl 164 src: p2pMediaLoaderOptions.playlistUrl
158 } 165 }
159 166
160 const config = { 167 const p2pMediaLoaderConfig = {
168 // loader: {
169 // trackerAnnounce: p2pMediaLoaderOptions.trackerAnnounce
170 // },
161 segments: { 171 segments: {
162 swarmId: 'swarm' // TODO: choose swarm id 172 swarmId: p2pMediaLoaderOptions.playlistUrl
163 } 173 }
164 } 174 }
165 const streamrootHls = { 175 const streamrootHls = {
166 html5: { 176 html5: {
167 hlsjsConfig: { 177 hlsjsConfig: {
168 liveSyncDurationCount: 7, 178 liveSyncDurationCount: 7,
169 loader: new Engine(config).createLoaderClass() 179 loader: new p2pMediaLoaderModule.Engine(p2pMediaLoaderConfig).createLoaderClass()
170 } 180 }
171 } 181 }
172 } 182 }