#android #jni #media #rust

aloe-android-video

Aloe Android Video provides an extensive API for managing video playback in Android applications using Rust. Engagement with Java components through JNI is optimized for efficient media handling and state control. This crate is a translation of the c++ juce module serving the same function.

1 unstable release

Uses new Rust 2024

new 0.1.1 Apr 2, 2025

#77 in #jni

22 downloads per month
Used in aloe-exports

GPL-3.0 license

2MB
16K SLoC

Aloe Android Video

Aloe Android Video is a Rust crate providing a comprehensive interface for video management in Android applications. It integrates tightly with the Android Media framework, enabling seamless interaction between Rust and Java components.

This crate defines a robust architecture featuring state-aware media session management, audio focus handling, video rendering, and callback interfaces for media events. It provides a rich API for managing video playback, including actions like play, pause, seek, volume adjustment, and audio focus change monitoring.

Key Concepts

  • MediaSessionPlayerState: Enumerates the various states of media playback such as initialised, playing, paused, and completed, allowing fine-grained control over the playback lifecycle.

  • MediaPlayerListener & AudioManagerOnAudioFocusChangeListener: Traits allowing implementers to respond to key media events such as preparation, buffering, completion, errors, and audio focus changes.

  • MediaSessionPlayer & MediaSession: Core structures responsible for managing the playback state and audio focus, leveraging Android's media APIs.

  • VideoComponentImpl: Integrates with Android's SurfaceHolder for rendering video and managing lifecycle events.

Installation

Include this crate in your Cargo.toml:

[dependencies]
aloe-android-video = "0.1.0"

Usage

Implement the MediaPlayerListenerOwner and AudioManagerOnAudioFocusChangeListenerOwner traits in your application to handle media events:

impl MediaPlayerListenerOwner for MyApp {
    fn on_prepared(&mut self, media_player: &mut LocalRef<jobject>) {
        // Handle media preparation
    }
    // Implement other required methods...
}

impl AudioManagerOnAudioFocusChangeListenerOwner for MyApp {
    fn on_audio_focus_change(&mut self, change_type: i32) {
        // Handle audio focus changes
    }
}

Create a MediaSessionPlayer instance and control playback:

let mut media_session = MediaSessionPlayer::new(&mut my_media_session);
media_session.load(&media_id, &extras);
media_session.play();

Contributions

Contributions are welcome in the form of issues or pull requests to the repository.


Note: This README.md file was generated by an AI model and may not be 100% accurate, however, it should be pretty good.

This crate is a translation of the JUCE module.

JUCE is a c++ software framework for developing high performance audio applications.

Usage falls under the GPLv3 as well as the JUCE commercial license.

See github.com/juce-framework/JUCE and the JUCE license page for details.

This crate is in the process of being translated from c++ to rust. For progress updates, please see the workspacer rust project. designed specifically for rust projects.

Dependencies

~40MB
~645K SLoC