Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add chromecast support #129

Merged
merged 17 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 332 additions & 4 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions addons/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ version = "0.1.2"
surf = { version = "2.3.2", features = ["h1-client-rustls"], default-features = false}
async-trait = "0.1.59"
anyhow = "1.0.67"
rust_cast = { git = "https://github.com/tsirysndr/rust-cast.git", rev = "3a36506", features = ["thread_safe"] }
jsonrpsee = { version = "0.16.2", features = ["jsonrpsee-ws-client", "jsonrpsee-http-client", "jsonrpsee-client-transport", "async-client", "client"] }
url = "2.3.1"
md5 = "0.7.0"
local-ip-addr = "0.1.1"
112 changes: 112 additions & 0 deletions addons/src/airplay.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
use crate::{Addon, Player};
use anyhow::Error;
use async_trait::async_trait;
use music_player_types::types::{Device, Playback, Track};

pub struct Airplay {
name: String,
version: String,
author: String,
description: String,
enabled: bool,
}

impl Airplay {
pub fn new() -> Self {
Self {
name: "Airplay".to_string(),
version: "0.1.0".to_string(),
author: "Tsiry Sandratraina".to_string(),
description: "Airplay addon".to_string(),
enabled: true,
}
}

pub fn connect(&mut self, device: Device) -> Result<Option<Box<dyn Player + Send>>, Error> {
let player: Self = device.clone().into();
Ok(Some(Box::new(player)))
}
}

impl Addon for Airplay {
fn name(&self) -> &str {
&self.name
}

fn version(&self) -> &str {
&self.version
}

fn author(&self) -> &str {
&self.author
}

fn description(&self) -> &str {
&self.description
}

fn enabled(&self) -> bool {
self.enabled
}

fn set_enabled(&mut self, enabled: bool) {
self.enabled = enabled;
}
}

#[async_trait]
impl Player for Airplay {
async fn play(&mut self) -> Result<(), Error> {
todo!()
}

async fn pause(&mut self) -> Result<(), Error> {
todo!()
}

async fn stop(&mut self) -> Result<(), Error> {
todo!()
}

async fn next(&mut self) -> Result<(), Error> {
todo!()
}

async fn previous(&mut self) -> Result<(), Error> {
todo!()
}

async fn seek(&mut self, position: u32) -> Result<(), Error> {
todo!()
}

async fn load_tracks(&mut self, tracks: Vec<Track>, start_index: Option<i32>) -> Result<(), Error> {
todo!()
}

async fn play_next(&mut self, track: Track) -> Result<(), Error> {
todo!()
}

async fn load(&mut self, track: Track) -> Result<(), Error> {
todo!()
}

async fn get_current_playback(&mut self) -> Result<Playback, Error> {
todo!()
}

fn device_type(&self) -> String {
"airplay".to_string()
}

fn disconnect(&mut self) -> Result<(), Error> {
Ok(())
}
}

impl From<Device> for Airplay {
fn from(device: Device) -> Self {
Self { ..Airplay::new() }
}
}
Loading