diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-14 10:57:07 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-15 08:39:02 +0200 |
commit | efda99c30f2c04702bf57cc150cdfdd0acccc178 (patch) | |
tree | 2d7a0807189f75ed75365f86d85e57211c8d3e74 /client/src/assets/player/peertube-videojs-plugin.ts | |
parent | 4de2fafcad4b56449e3817825d4b317c5ed4696c (diff) | |
download | PeerTube-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.ts | 19 |
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' | |||
4 | import { renderVideo } from './video-renderer' | 4 | import { renderVideo } from './video-renderer' |
5 | import './settings-menu-button' | 5 | import './settings-menu-button' |
6 | import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 6 | import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
7 | import { | 7 | import { getAverageBandwidth, getStoredMute, getStoredVolume, saveAverageBandwidth, saveMuteInStore, saveVolumeInStore } from './utils' |
8 | getAverageBandwidth, | ||
9 | getStoredMute, | ||
10 | getStoredVolume, | ||
11 | saveAverageBandwidth, | ||
12 | saveMuteInStore, | ||
13 | saveVolumeInStore | ||
14 | } from './utils' | ||
15 | import minBy from 'lodash-es/minBy' | 8 | import minBy from 'lodash-es/minBy' |
16 | import maxBy from 'lodash-es/maxBy' | 9 | import maxBy from 'lodash-es/maxBy' |
10 | import * as CacheChunkStore from 'cache-chunk-store' | ||
11 | import { PeertubeChunkStore } from './peertube-chunk-store' | ||
17 | 12 | ||
18 | const webtorrent = new WebTorrent({ | 13 | const 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 |