Download the PHP package nativephp/mobile-media-player without Composer
On this page you can find all versions of the php package nativephp/mobile-media-player. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nativephp/mobile-media-player
More information about nativephp/mobile-media-player
Files in nativephp/mobile-media-player
Package mobile-media-player
Short Description Media player plugin for NativePHP Mobile - shared audio/video playback, full-screen presentation, and a video-player element
License MIT
Informations about the package mobile-media-player
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 <video-player> element for native (Edge) views.
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
<video-player>element — a video surface for native UI views, rendered as SwiftUIVideoPlayer(AVKit) on iOS and aVideoViewinside Compose on Android.
Installation
Don't forget to register the plugin:
Usage
Shared player (PHP)
play() and present() return false when the source can't be started (or when
running outside the native runtime).
Full-screen system player
Inline video in native views
Attributes:
| Attribute | Default | Description |
|---|---|---|
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 muted |
Sizing 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
Events
PlaybackEnded
Fired when the shared player reaches the end of the source.
Payload: string $source
PlaybackError
Fired when the shared player fails to load or play a source.
Payload: string $source, string $message
Status values
MediaPlayer::getStatus()['state'] is one of: idle, playing, paused.
Testing
The plugin extends the NativePHP testing suite with playback-specific helpers, so your app tests can fake and assert media activity without knowing any bridge internals:
Helpers
withPlaybackStatus(string $state = 'playing', float $position = 0.0, float $duration = 0.0, ?string $source = null)— script the statusgetStatus()reports.$stateis one ofidle,playing,paused.assertPlayed(?string $source = null)— assert playback was started, or exactly$source(a path or URL) when given.assertPaused()— assert playback was paused.assertStopped()— assert playback was stopped and the player released.assertSeeked(?float $to = null)— assert a seek happened, or to exactly$toseconds when given.assertNothingPlayed()— assert no playback was started.
The helpers are available on Native::fakeBridge() and chain directly off Native::test(...). They register automatically while running tests (requires a core with a macroable FakeBridge; on older cores they simply don't register).
Platform Support
- iOS: 16.0+ (AVPlayer / AVKit)
- Android: API 26+ (MediaPlayer / Media3 UI)
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.