mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-08-10 23:24:08 +02:00
Move file caching logic to new FileCache service
Also: removes the -re ffmpeg option. If this option is passed, ffmpeg won't write to fs-capacitor (and the cache file) as fast as possible. In other words, the cache file won't finish writing until the entire stream has been played.
This commit is contained in:
parent
04d8f8d390
commit
f5149dfaba
12 changed files with 154 additions and 52 deletions
src/managers
|
@ -2,25 +2,25 @@ import {inject, injectable} from 'inversify';
|
|||
import {Client} from 'discord.js';
|
||||
import {TYPES} from '../types.js';
|
||||
import Player from '../services/player.js';
|
||||
import Config from '../services/config.js';
|
||||
import FileCacheProvider from '../services/file-cache.js';
|
||||
|
||||
@injectable()
|
||||
export default class {
|
||||
private readonly guildPlayers: Map<string, Player>;
|
||||
private readonly cacheDir: string;
|
||||
private readonly discordClient: Client;
|
||||
private readonly fileCache: FileCacheProvider;
|
||||
|
||||
constructor(@inject(TYPES.Config) config: Config, @inject(TYPES.Client) client: Client) {
|
||||
constructor(@inject(TYPES.FileCache) fileCache: FileCacheProvider, @inject(TYPES.Client) client: Client) {
|
||||
this.guildPlayers = new Map();
|
||||
this.cacheDir = config.CACHE_DIR;
|
||||
this.discordClient = client;
|
||||
this.fileCache = fileCache;
|
||||
}
|
||||
|
||||
get(guildId: string): Player {
|
||||
let player = this.guildPlayers.get(guildId);
|
||||
|
||||
if (!player) {
|
||||
player = new Player(this.cacheDir, this.discordClient);
|
||||
player = new Player(this.discordClient, this.fileCache);
|
||||
|
||||
this.guildPlayers.set(guildId, player);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue