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: String
Unique ID of the web application or the extensionaddonName: String
Name of the web application or the extensionaddonVersion: String
Version 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: String
Name of the serviceversion: String
Current 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?: String
Error messagestack?: String
Error 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: String
Resolution of the download or bitrate in case of audio download. Possible values are 128kbps, 256kbps, 320kbps, 480p, 720p, 1080p, 1440p, 2160p, 4320pvideoUrl: String | null
URL of the video stream, Can be null in case of an audio downloadaudioUrl: String | null
URL of the audio stream, Can be null in case of a video conversion onlylength: Number
Duration of the download in secondsstartTime: Number | null
Start time of the output stream used for trimming, null means start time is 0endTime: Number | null
End time of the output stream used for trimming, null means up to the endformat: String
Output format of the download. Possible values are mp3, mp4, mkv, flv, avi, 3gptitle: String
Title of the downloadthumbnailUrl: String
Image URL used for album art
Returned value Download
has following properties.
id: String
A unique ID assigned to the downloadtitle: String
Title of the downloadformat: String
Output format of the download. Possible values are mp3, mp4, mkv, flv, avi, 3gpquality: String
Resolution of the download or bitrate in case of audio download. Possible values are 128kbps, 256kbps, 320kbps, 480p, 720p, 1080p, 1440p, 2160p, 4320pstate: String
Current state of the download. Possible values are queued, downloading, paused, processing, completed, canceled, errorprogress: Number | null
Download or conversion progress, null in case of an inactive downloadsize: Number | null
Size of the download in bytes, null in case of inactive downloadcreatedAt: Number
Timestamp when the download was addederrorMessage: String | null
Error 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: Number
Starting index of the downloads listend: Number
Ending index of the downloads listtotal: Number
Total number of downloads
downloads.pause(id): Promise<ActionStatus>
Pause an active download using the download id
. ActionStatus
has the following properties.
error: Boolean
The action was successful or notmessage?: String
Error 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: Boolean
The action was successful or notmessage?: String
Error 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: Boolean
The action was successful or notmessage?: String
Error 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: Boolean
The action was successful or notmessage?: String
Error 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: Boolean
The action was successful or notmessage?: String
Error message in case the action failed
downloads.clear(): Promise<ActionStatus>
Clear all the downloaded items. ActionStatus
has the following properties.
error: Boolean
The action was successful or notmessage?: String
Error 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: Boolean
The action was successful or notmessage?: String
Error 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.ChangeInfo
has the following properties.state?: String
Current state of the download. Possible values are queued, downloading, paused, processing, completed, canceled, errorprogress?: Number
Download or conversion progresssize?: Number
Size of the download in byteserrorMessage?: String
Error message in case the download fails