aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-videojs-plugin.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-14 10:57:07 +0200
committerChocobozzz <me@florianbigard.com>2018-05-15 08:39:02 +0200
commitefda99c30f2c04702bf57cc150cdfdd0acccc178 (patch)
tree2d7a0807189f75ed75365f86d85e57211c8d3e74 /client/src/assets/player/peertube-videojs-plugin.ts
parent4de2fafcad4b56449e3817825d4b317c5ed4696c (diff)
downloadPeerTube-efda99c30f2c04702bf57cc150cdfdd0acccc178.tar.gz
PeerTube-efda99c30f2c04702bf57cc150cdfdd0acccc178.tar.zst
PeerTube-efda99c30f2c04702bf57cc150cdfdd0acccc178.zip
Store webtorrent chunks in indexdb
Diffstat (limited to 'client/src/assets/player/peertube-videojs-plugin.ts')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index a4f99559c..ac04421a7 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -4,16 +4,11 @@ import { VideoFile } from '../../../../shared/models/videos/video.model'
4import { renderVideo } from './video-renderer' 4import { renderVideo } from './video-renderer'
5import './settings-menu-button' 5import './settings-menu-button'
6import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 6import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
7import { 7import { getAverageBandwidth, getStoredMute, getStoredVolume, saveAverageBandwidth, saveMuteInStore, saveVolumeInStore } from './utils'
8 getAverageBandwidth,
9 getStoredMute,
10 getStoredVolume,
11 saveAverageBandwidth,
12 saveMuteInStore,
13 saveVolumeInStore
14} from './utils'
15import minBy from 'lodash-es/minBy' 8import minBy from 'lodash-es/minBy'
16import maxBy from 'lodash-es/maxBy' 9import maxBy from 'lodash-es/maxBy'
10import * as CacheChunkStore from 'cache-chunk-store'
11import { PeertubeChunkStore } from './peertube-chunk-store'
17 12
18const webtorrent = new WebTorrent({ 13const webtorrent = new WebTorrent({
19 tracker: { 14 tracker: {
@@ -169,7 +164,13 @@ class PeerTubePlugin extends Plugin {
169 console.log('Adding ' + magnetOrTorrentUrl + '.') 164 console.log('Adding ' + magnetOrTorrentUrl + '.')
170 165
171 const oldTorrent = this.torrent 166 const oldTorrent = this.torrent
172 this.torrent = webtorrent.add(magnetOrTorrentUrl, torrent => { 167 const options = {
168 store: (chunkLength, storeOpts) => new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), {
169 max: 100
170 })
171 }
172
173 this.torrent = webtorrent.add(magnetOrTorrentUrl, options, torrent => {
173 console.log('Added ' + magnetOrTorrentUrl + '.') 174 console.log('Added ' + magnetOrTorrentUrl + '.')
174 175
175 // Pause the old torrent 176 // Pause the old torrent