PHPackages                             nativephp/mobile-media-player - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nativephp/mobile-media-player

ActiveNativephp-plugin[Utility &amp; Helpers](/categories/utility)

nativephp/mobile-media-player
=============================

Media player plugin for NativePHP Mobile - shared audio/video playback, full-screen presentation, and a video-player element

1.0.1(1mo ago)5102MITKotlinPHP ^8.2

Since Jul 2Pushed 1mo agoCompare

[ Source](https://github.com/NativePHP/mobile-media-player)[ Packagist](https://packagist.org/packages/nativephp/mobile-media-player)[ RSS](/packages/nativephp-mobile-media-player/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Media Player Plugin for NativePHP Mobile
========================================

[](#media-player-plugin-for-nativephp-mobile)

Audio/video playback for NativePHP Mobile: a shared background player driven from PHP, a full-screen system player, and an inline `` element for native (Edge) views.

Overview
--------

[](#overview)

The plugin provides three ways to play media:

- **Shared player** — `MediaPlayer::play()` plays audio or video sources app-wide (AVPlayer on iOS, MediaPlayer on Android) with pause/resume/seek/volume control from PHP.
- **Full-screen presentation** — `MediaPlayer::present()` opens the system player UI (AVPlayerViewController on iOS, a dedicated full-screen activity on Android); the user dismisses it natively.
- **Inline `` element** — a video surface for native UI views, rendered as SwiftUI `VideoPlayer` (AVKit) on iOS and a `VideoView` inside Compose on Android.

Installation
------------

[](#installation)

```
composer require nativephp/mobile-media-player
```

Don't forget to register the plugin:

```
php artisan native:plugin:register nativephp/mobile-media-player
```

Usage
-----

[](#usage)

### Shared player (PHP)

[](#shared-player-php)

```
use NativePHP\MediaPlayer\Facades\MediaPlayer;

// Play a bundled file, storage path, or URL
MediaPlayer::play(storage_path('app/theme.mp3'));

// With options
MediaPlayer::play('https://example.com/stream.mp3', [
    'loop' => true,
    'volume' => 0.5,
]);

// Transport controls
MediaPlayer::pause();
MediaPlayer::resume();
MediaPlayer::seek(42.5);        // seconds
MediaPlayer::setVolume(0.8);    // 0.0 – 1.0
MediaPlayer::stop();            // stops and releases the player

// Poll playback state
$status = MediaPlayer::getStatus();
// ['state' => 'playing', 'position' => 12.3, 'duration' => 180.0, 'source' => '...']
```

`play()` and `present()` return `false` when the source can't be started (or when running outside the native runtime).

### Full-screen system player

[](#full-screen-system-player)

```
MediaPlayer::present(storage_path('app/videos/intro.mp4'));
```

### Inline video in native views

[](#inline-video-in-native-views)

```

```

Attributes:

AttributeDefaultDescription`src`—File path or URL`controls``true`Show native transport chrome`autoplay``false`Start playback on mount`loop``false`Restart when playback ends`muted``false`Start mutedSizing follows the element's layout props (`width`/`height`/`aspect` classes), like `Image`.

With `controls=false` you get a bare video surface — overlay your own Element UI and drive playback through the `MediaPlayer` facade:

```

```

### Building the element from PHP

[](#building-the-element-from-php)

```
use NativePHP\MediaPlayer\Elements\VideoPlayer;

VideoPlayer::make($path)
    ->controls(false)
    ->autoplay()
    ->loop()
    ->muted();
```

Events
------

[](#events)

### `PlaybackEnded`

[](#playbackended)

Fired when the shared player reaches the end of the source.

**Payload:** `string $source`

```
use Native\Mobile\Attributes\OnNative;
use NativePHP\MediaPlayer\Events\PlaybackEnded;

#[OnNative(PlaybackEnded::class)]
public function handlePlaybackEnded(string $source)
{
    $this->playNext();
}
```

### `PlaybackError`

[](#playbackerror)

Fired when the shared player fails to load or play a source.

**Payload:** `string $source`, `string $message`

```
use Native\Mobile\Attributes\OnNative;
use NativePHP\MediaPlayer\Events\PlaybackError;

#[OnNative(PlaybackError::class)]
public function handlePlaybackError(string $source, string $message)
{
    $this->status = "Playback failed: {$message}";
}
```

Status values
-------------

[](#status-values)

`MediaPlayer::getStatus()['state']` is one of: `idle`, `playing`, `paused`.

Platform Support
----------------

[](#platform-support)

- **iOS:** 16.0+ (AVPlayer / AVKit)
- **Android:** API 26+ (MediaPlayer / Media3 UI)

Notes
-----

[](#notes)

- One shared player: calling `play()` replaces whatever is currently playing.
- Remote URLs require network access; local paths must be readable by the app (e.g. `storage_path()` or bundled assets).
- No runtime permissions are required.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance91

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

3

Last Release

35d ago

Major Versions

v0.0.1 → 1.0.12026-07-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ab43d3432a80f0f41fe7015280f6024ff13fe8c2306cf114a1fbc91a4cd6f35?d=identicon)[simonhamp](/maintainers/simonhamp)

![](https://www.gravatar.com/avatar/16cc4d562d3f6f302901f1c65eb3ce819c0fb24ab2616241c605126102812ca4?d=identicon)[shanerbaner82](/maintainers/shanerbaner82)

---

Top Contributors

[![shanerbaner82](https://avatars.githubusercontent.com/u/5580860?v=4)](https://github.com/shanerbaner82 "shanerbaner82 (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/nativephp-mobile-media-player/health.svg)

```
[![Health](https://phpackages.com/badges/nativephp-mobile-media-player/health.svg)](https://phpackages.com/packages/nativephp-mobile-media-player)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
