-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup new plugin development kit (wasm addons)
- Loading branch information
Showing
23 changed files
with
576 additions
and
21 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "chromecast" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("chromecast")? | ||
.with_capabilities(vec![Capability::Player])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "dlna" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("dlna")? | ||
.with_capabilities(vec![Capability::Player, Capability::Browse])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "kodi" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("kodi")? | ||
.with_capabilities(vec![Capability::Player, Capability::Browse])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "local" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("local")? | ||
.with_capabilities(vec![Capability::Player, Capability::Browse])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "mopidy" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("mopidy")? | ||
.with_capabilities(vec![Capability::Player])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "mpd" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("mpd")? | ||
.with_capabilities(vec![Capability::Player])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "mpris" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("mpris")? | ||
.with_capabilities(vec![Capability::Player])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "squeezebox" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("squeezebox")? | ||
.with_capabilities(vec![Capability::Player])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
edition = "2021" | ||
name = "tunein" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
music-player-pdk = {version = "0.1.0", path = "../../pdk"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use extism_pdk::*; | ||
use music_player_pdk::{addon, Capability}; | ||
|
||
#[plugin_fn] | ||
pub fn setup() -> FnResult<()> { | ||
addon() | ||
.register("tunein")? | ||
.with_capabilities(vec![Capability::Player, Capability::Browse])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
edition = "2021" | ||
name = "music-player-pdk" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
extism-pdk = "1.2.1" | ||
serde = {version = "1.0.208", features = ["serde_derive", "derive"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use extism_pdk::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[host_fn] | ||
extern "ExtismHost" { | ||
fn open_media(url: String); | ||
fn browse(url: &str); | ||
fn register_addon(name: String); | ||
fn currently_playing_song(); | ||
fn next(); | ||
fn previous(); | ||
fn pause(); | ||
fn play(); | ||
fn stop(); | ||
fn seek(time: u32); | ||
fn position_ms() -> u32; | ||
fn playlist(); | ||
fn playlists(); | ||
fn main_playlists(); | ||
fn recent_playlists(); | ||
fn folder(); | ||
fn folders(); | ||
fn create_playlist(args: Json<CreatePlaylistOpt>); | ||
fn delete_playlist(id: String); | ||
fn add_to_playlist(args: Json<AddToPlaylistOpt>); | ||
fn remove_from_playlist(args: Json<RemoveFromPlaylistOpt>); | ||
fn rename_playlist(args: Json<RenamePlaylistOpt>); | ||
fn with_capabilities(capabilities: Json<Vec<String>>); | ||
} | ||
|
||
pub enum Capability { | ||
Player, | ||
Browse, | ||
Share, | ||
} | ||
|
||
impl Capability { | ||
pub fn to_string(&self) -> String { | ||
match self { | ||
Capability::Player => "player".into(), | ||
Capability::Browse => "browse".into(), | ||
Capability::Share => "share".into(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct CreatePlaylistOpt { | ||
pub name: String, | ||
pub description: String, | ||
pub folder_id: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct AddToPlaylistOpt { | ||
pub playlist_id: String, | ||
pub song_id: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RemoveFromPlaylistOpt { | ||
pub playlist_id: String, | ||
pub song_id: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RenamePlaylistOpt { | ||
pub playlist_id: String, | ||
pub name: String, | ||
} | ||
|
||
pub fn addon() -> Addon { | ||
Addon {} | ||
} | ||
|
||
pub struct Addon {} | ||
|
||
impl Addon { | ||
pub fn register(&self, name: &str) -> Result<&Addon, Error> { | ||
unsafe { register_addon(name.into())? }; | ||
Ok(self) | ||
} | ||
|
||
pub fn with_capabilities(&self, capabilities: Vec<Capability>) -> Result<&Addon, Error> { | ||
let capabilities: Vec<String> = capabilities.iter().map(|c| c.to_string()).collect(); | ||
unsafe { with_capabilities(Json(capabilities))? }; | ||
Ok(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters