tuneflow-plugin-basic
Version:
Basic TuneFlow plugins
39 lines (34 loc) • 966 B
text/typescript
import type { ParamDescriptor, Song, TrackSelectorWidgetConfig } from 'tuneflow';
import { TuneflowPlugin, WidgetType } from 'tuneflow';
export class TrackRemover extends TuneflowPlugin {
static providerId(): string {
return 'andantei';
}
static pluginId(): string {
return 'track-remover';
}
params(): { [paramName: string]: ParamDescriptor } {
return {
trackId: {
displayName: {
zh: '轨道',
en: 'Track',
},
defaultValue: undefined,
widget: {
type: WidgetType.TrackSelector,
config: {} as TrackSelectorWidgetConfig,
},
hidden: true,
},
};
}
async run(song: Song, params: { [paramName: string]: any }): Promise<void> {
const trackId = this.getParam<string>(params, 'trackId');
const track = song.getTrackById(trackId);
if (!track) {
throw new Error('Track not ready');
}
song.removeTrack(trackId);
}
}