Skip to content

Commit

Permalink
feat(iOS): Support system media control
Browse files Browse the repository at this point in the history
  • Loading branch information
XMLHexagram committed Jan 2, 2025
1 parent 901bdc6 commit ed3550e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions playback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ windows = { version = "0.44.0", features = [
once_cell = "1.20.2"
simple_channel = { path = "../simple-channel" }

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
souvlaki = "0.7.3"
[target.'cfg(not(any(target_os = "android")))'.dependencies]
souvlaki = { git = "https://github.com/XMLHexagram/souvlaki", branch = "master" }

[target.'cfg(target_os = "android")'.dependencies]
ndk-context = "0.1.1"
jni = "0.21.1"
jni = "0.21.1"
11 changes: 4 additions & 7 deletions playback/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ use log::{debug, info};
use once_cell::sync::OnceCell;
use tokio::sync::Mutex;

#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(target_os = "android")]
use crate::dummy_souvlaki::{MediaControlEvent, MediaControls, PlatformConfig, SeekDirection};
#[cfg(not(any(target_os = "android", target_os = "ios")))]

#[cfg(not(target_os = "android"))]
use souvlaki::{MediaControlEvent, MediaControls, PlatformConfig, SeekDirection};

use simple_channel::{SimpleChannel, SimpleReceiver, SimpleSender};
Expand Down Expand Up @@ -51,7 +52,7 @@ pub struct MediaControlManager {

impl MediaControlManager {
pub fn new() -> Result<Self> {
#[cfg(not(any(target_os = "windows", target_os = "android", target_os = "ios")))]
#[cfg(not(any(target_os = "windows")))]
let hwnd = None;

#[cfg(target_os = "windows")]
Expand All @@ -61,13 +62,9 @@ impl MediaControlManager {
(Some(handle), dummy_window)
};

// #[cfg(target_os = "android")]
// let hwnd = ();

let config = PlatformConfig {
dbus_name: "rune_player",
display_name: "Rune",
#[cfg(not(any(target_os = "android", target_os = "ios")))]
hwnd,
};

Expand Down
1 change: 1 addition & 0 deletions playback/src/dummy_souvlaki.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum SeekDirection {
pub struct PlatformConfig {
pub dbus_name: &'static str,
pub display_name: &'static str,
pub hwnd: Option<()>,
}

/// A platform-specific error.
Expand Down
12 changes: 6 additions & 6 deletions playback/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ pub mod player;
pub mod sfx_player;
pub mod strategies;

#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(target_os = "android")]
mod dummy_souvlaki;

#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub use souvlaki::{MediaMetadata, MediaPlayback, MediaPosition};

#[cfg(any(target_os = "android", target_os = "ios"))]
#[cfg(target_os = "android")]
pub use dummy_souvlaki::{MediaMetadata, MediaPlayback, MediaPosition};

#[cfg(not(target_os = "android"))]
pub use souvlaki::{MediaMetadata, MediaPlayback, MediaPosition};

pub use internal::{PlayerCommand, PlayerEvent};

#[cfg(target_os = "android")]
pub mod android_utils;
pub mod android_utils;

0 comments on commit ed3550e

Please sign in to comment.