Installation and Usage
Download flixmate-1.1.0.min.js file and include it in your webpage or extension.
<script src="flixmate-1.1.0.min.js"></script>
Wait for script initialization and add a download request.
const FlixmateClient = Flixmate.default;
FlixmateClient.setDebugLevel('debug');
const flixmate = new FlixmateClient({
addonId: 'xxxxxxx', // Unique extension or web service ID
addonName: 'Video Downloader', // Extension or web service name
addonVersion: '1.0.0', // Extension or web service version
});
if (flixmate.isSupported) {
// Try for a connection to Flixmate service
flixmate.connect();
}
flixmate.onConnected(async () => {
// Merge audio and video streams and output as MP4
const download = await flixmate.downloads.add({
quality: '720p',
videoUrl: 'https://example.com/video.webm',
audioUrl: 'https://example.com/audio.webm',
length: 127,
startTime: null,
endTime: null,
format: 'mp4',
title: 'Video title',
thumbnailUrl: 'https://example.com/thumb.jpg',
});
});
// Watch for changes on active downloads
flixmate.downloads.onChange((changes) => {
const { items } = changes;
Object.keys(items).forEach((downloadId) => {
const {
state,
progress,
size,
errorMessage,
} = items[downloadId];
console.log({ state, progress, size, errorMessage });
});
});
API
FlixmateClient(options)
Initializes an instance of Flixmate. options requires the following properties.
addonId: StringUnique ID of the web application or the extensionaddonName: StringName of the web application or the extensionaddonVersion: StringVersion of the web application or the extension
isSupported: Boolean
Flixmate instance property, Use to check if Flixmate is supported in user's OS.
isConnected: Boolean
Flixmate instance property, Use to check if Flixmate is connected to the desktop service.
static setDebugLevel(level): void
Used to set logging level. Possible values for level are debug, info, warning or error.
connect(): void
Try to connect to Flixmate desktop service.
disconnect(): void
Disconnect from Flixmate desktop service.
info(): Promise<FlixmateInfo>
Returns information about Flixmate service. FlixmateInfo has following properties.
name: StringName of the serviceversion: StringCurrent version of the service
onConnected(listener): void
Event fired on successful connection with the service. listener is a callback function executed on connection.
onDisconnected(listener): void
Event fired when the service is disconnected. listener is a callback function executed on connection.
onExceptionCaught(listener): void
Event fired whenever an error or exception occurs. listener is callback function that takes an argument which has the following properties.
message?: StringError messagestack?: StringError stack trace
downloads.add(request): Promise<Download>
Adds a new download request to the queue and returns the item details. request required the following properties.
quality: StringResolution of the download or bitrate in case of audio download. Possible values are 128kbps, 256kbps, 320kbps, 480p, 720p, 1080p, 1440p, 2160p, 4320pvideoUrl: String | nullURL of the video stream, Can be null in case of an audio downloadaudioUrl: String | nullURL of the audio stream, Can be null in case of a video conversion onlylength: NumberDuration of the download in secondsstartTime: Number | nullStart time of the output stream used for trimming, null means start time is 0endTime: Number | nullEnd time of the output stream used for trimming, null means up to the endformat: StringOutput format of the download. Possible values are mp3, mp4, mkv, flv, avi, 3gptitle: StringTitle of the downloadthumbnailUrl: StringImage URL used for album art
Returned value Download has following properties.
id: StringA unique ID assigned to the downloadtitle: StringTitle of the downloadformat: StringOutput format of the download. Possible values are mp3, mp4, mkv, flv, avi, 3gpquality: StringResolution of the download or bitrate in case of audio download. Possible values are 128kbps, 256kbps, 320kbps, 480p, 720p, 1080p, 1440p, 2160p, 4320pstate: StringCurrent state of the download. Possible values are queued, downloading, paused, processing, completed, canceled, errorprogress: Number | nullDownload or conversion progress, null in case of an inactive downloadsize: Number | nullSize of the download in bytes, null in case of inactive downloadcreatedAt: NumberTimestamp when the download was addederrorMessage: String | nullError message if the download or conversion fails
downloads.get(limit, offset): Promise<DownloadsList>
Get list of downloads from the service. limit and offset can to used to limit the number of returned items. DownloadsList has the following properties.
items: { [downloadId: String]: Download }An object containing Download items with download id as key of the downloadstart: NumberStarting index of the downloads listend: NumberEnding index of the downloads listtotal: NumberTotal number of downloads
downloads.pause(id): Promise<ActionStatus>
Pause an active download using the download id. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
downloads.resume(id): Promise<ActionStatus>
Resume a paused download using the download id. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
downloads.cancel(id): Promise<ActionStatus>
Cancel an active or queued download using the download id. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
downloads.delete(id): Promise<ActionStatus>
Delete a downloaded file using the download id. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
downloads.play(id): Promise<ActionStatus>
Play a downloaded item using the download id. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
downloads.clear(): Promise<ActionStatus>
Clear all the downloaded items. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
downloads.showFolder(): Promise<ActionStatus>
Open the downloads folder in a new explorer window. ActionStatus has the following properties.
error: BooleanThe action was successful or notmessage?: StringError message in case the action failed
onAdded(listener): void
Event fired when a new download is added to the queue. listener is callback function that takes a Download item as argument.
onChanged(listener): void
Event fired when a download item changes i.e. state, progress. listener is callback function that takes an argument which has the following properties.
items?: { [downloadId: String]: ChangeInfo }Download items with their changes.ChangeInfohas the following properties.state?: StringCurrent state of the download. Possible values are queued, downloading, paused, processing, completed, canceled, errorprogress?: NumberDownload or conversion progresssize?: NumberSize of the download in byteserrorMessage?: StringError message in case the download fails