Skip to content

🎥 Make videos programmatically with React

1.1 KB
Raw Blame
let maxTimelineTracks: number | null = null;
let configuredMaxTimelineTracks: number | null = null;

export const setMaxTimelineTracks = (maxTracks: number) => {
	if (typeof maxTracks !== 'number') {
		throw new Error(
			`Need to pass a number to Config.setMaxTimelineTracks(), got ${typeof maxTracks}`,
		);
	}

	if (Number.isNaN(maxTracks)) {
		throw new Error(
			`Need to pass a real number to Config.setMaxTimelineTracks(), got NaN`,
		);
	}

	if (!Number.isFinite(maxTracks)) {
		throw new Error(
			`Need to pass a real number to Config.setMaxTimelineTracks(), got ${maxTracks}`,
		);
	}

	if (maxTracks < 0) {
		throw new Error(
			`Need to pass a non-negative number to Config.setMaxTimelineTracks(), got ${maxTracks}`,
		);
	}

	maxTimelineTracks = maxTracks;
	configuredMaxTimelineTracks = maxTracks;
};

export const getMaxTimelineTracks = () => {
	return maxTimelineTracks;
};

export const getConfiguredMaxTimelineTracks = () => {
	return configuredMaxTimelineTracks;
};

export const resetMaxTimelineTracks = () => {
	maxTimelineTracks = null;
	configuredMaxTimelineTracks = null;
};