-
Notifications
You must be signed in to change notification settings - Fork 5
API Reference
This page lists the API that you can use in plug-ins.
Standard functions like console.log()
, JSON.parse()
can be used in plugins.
In plugins, it's recommended to use these functions to get/post network data. These functions are easy to use, and they also apply MoonPlayer's network settings like proxy.
Download data from url.
- url: Url of data to be download.
- callback_func: Callback function.
Example:
function search(key, page) {
var url = "http://api.example.com/search?key=" + key + "&page=" + page;
moonplayer.get_content(url, function(content){
do_something(content);
});
}
Post data to url and get response data.
- url: Url of data to be download.
- post_data: data to be posted.
- callback_func: Callback function.
These functions show dialog window on screen.
Show a warning dialog.
- text: Text to be shown.
Example:
moonplayer.warning('Naive! I am angry!');
Show a question dialog. Returns boolean value.
- text: Text to be shown.
Example:
if (moonplayer.question('Are you OK?')) {
do_something();
}
Show a dialog to input some text.
- msg: Message to be shown.
Example:
var api_key = moonplayer.get_text("Please enter the API Key:");
if (api_key !== '') {
save_api_key(api_key);
}
Choose an item from the list.
- msg: Message to be shown.
- items: List of items.
Example:
var lang = moonplayer.get_item("Please choose the language of audio:", ["Chinese", "English"]);
if (lang === "Chinese") {
parse_zh();
} else if (lang === "English") {
parse_en();
}
Show the search result in MoonPlayer.
- result: list of objects in
{title: "item 1", url: "url 1" }
form.
Example:
var result = [
{ title: "item 1", url: "https://www.example.com/video1.mp4" },
{ title: "item 2", url: "https://www.example.com/video2.mp4" }
];
moonplayer.show_result(result);
Store / Read plugin configurations.
Store configurations.
- name: Configuration item name.
- value: Configuration item value.
Example:
moonplayer.set_configuration("api_key", api_key);
Read configurations. Type of return value can be variable.
- name: Configuration item name.
Example:
var api_key = moonplayer.get_configuration("api_key");