@geheimgang188/fmod-service-api
Version:
FMOD service API
96 lines (95 loc) • 3.73 kB
TypeScript
import { FmodBank, FmodParameter } from './fmod-types';
import { TypedEmitter } from 'tiny-typed-emitter';
import { ILogger } from '../api/i-logger';
import { IRequireBank } from './ports/i-require-bank';
import { FmodEvent } from './fmod-event';
import { IFmodApi } from '../ports/i-fmod-api';
import { IFmodProject } from './interfaces/fmod-interfaces';
export interface FmodPlayerEvents {
init: () => void;
reconnect: () => void;
}
export declare abstract class FmodPlayer<TProjectData extends IFmodProject = IFmodProject> extends TypedEmitter<FmodPlayerEvents> implements IRequireBank {
/**
* Raw project data which was used to generate this player, if it was generated.
* Otherwise, this object is undefined.
*/
readonly rawProjectData: TProjectData | undefined;
protected readonly _banks: FmodBank;
protected readonly _api: IFmodApi;
private _initCalled;
private _firstConnection;
private _currentLanguage;
private _defaultLanguage;
private readonly _logger;
private readonly _loadedBanksByName;
private readonly _localisedBanks;
private readonly _languages;
private readonly _eventsByName;
private readonly _globalParamsByName;
protected constructor(api: IFmodApi, bankDir: string, logger?: ILogger);
/**
* Returns the current language, if localisation is enabled, and undefined otherwise.
*/
get currentLanguage(): string | undefined;
/**
* Returns all events that have been registered for this player.
*/
get allEvents(): FmodEvent[];
/**
* Returns all global parameters that have been registered for this player.
*/
get allGlobalParameters(): FmodParameter[];
/**
* Initialise the player by connecting it to the FMOD service
* using the provided API.
*/
init(): void;
/**
* Close the API connection.
*/
close(): void;
ensureBankLoaded(bankName: string): Promise<void>;
ensureBankUnloaded(bankName: string, force: boolean): Promise<void>;
/**
*
* @param bankNames Banks which are localised. If e.g. Voice is localised, the player will load
* Voice_en, Voice_de etc. according to the languages that have been configured.
* @param languages Languages supported by the localised banks. This is the Locale Code in FMOD,
* not the full name of the language.
* @param initialLanguage Default language to use when none has been configured.
*/
configureLocalisation(bankNames: string[], languages: string[], initialLanguage: string): void;
/**
* Set a new language. The language must have been configured in the localisation setup.
*
* Loading a new language causes localised banks to be unloaded in the previous language
* and reloaded in the new language.
*/
setLanguage(language: string): Promise<void>;
resetAllParameters(): Promise<void>;
/**
* Stops **all** running events, including snapshots.
*/
stopAllEvents(): Promise<void>;
/**
* Retrieves an event by its name (event path).
*/
getEvent(eventName: string): FmodEvent;
/**
* Retrieves a global parameter by name (parameter path).
*/
getGlobalParameter(paramName: string): FmodParameter;
/**
* Registers an event so it can later on be retrieved with the `getEvent()` function.
*/
protected registerEvent(event: FmodEvent): void;
/**
* Registers a global parameter so it can later on be retrieved with the `getGlobalParameter()` function.
*/
protected registerGlobalParam(param: FmodParameter): void;
private initBanks;
private handleReconnect;
private handleDisconnect;
private isLocalisedBank;
}