Skip to content

Feature/mpv player#9

Merged
sparkison merged 24 commits intom3ue:masterfrom
Serph91P:feature/mpv-player
Mar 31, 2026
Merged

Feature/mpv player#9
sparkison merged 24 commits intom3ue:masterfrom
Serph91P:feature/mpv-player

Conversation

@Serph91P
Copy link
Copy Markdown
Contributor

This pull request introduces a new embedded mpv player capability for both Electron and React Native environments, significantly enhancing video playback flexibility and control. The main changes include the addition of an mpvController for Electron, a new React Native module for mpv integration on Android, and the necessary APIs and configuration to support these features. There are also minor improvements and bugfixes for existing video player code.

Embedded mpv player integration:

  • Added a new mpvController class in electron/mpvController.js that manages mpv as a seamless "takeover" player, synchronizing playback state and geometry with the Electron window and communicating via JSON IPC. This enables advanced playback control, track selection, and progress reporting directly from the Electron app.
  • Integrated the embedded mpv player into Electron's main process (electron/main.js), including secure IPC handlers for starting/stopping playback, seeking, toggling pause, and track selection. The Electron window is hidden during mpv playback and restored afterward. [1] [2]
  • Exposed a comprehensive mpv player API to the renderer process via electron/preload.js, allowing the frontend to control playback and subscribe to events such as progress, pause, buffering, and track changes.

React Native mpv module (Android):

  • Added a new modules/react-native-mpv package with Android-specific Gradle configuration, manifest, and Kotlin source code for a basic mpv integration. This includes the MpvModule and MpvPackage classes, laying the groundwork for advanced native playback on Android. [1] [2] [3] [4] [5]
  • Registered the new React Native mpv module in the Expo configuration via a custom plugin (withMpvPlayer).

Bugfixes and improvements to existing video player code:

  • Improved robustness of the VLC player integration by safely copying the source object and adding additional null checks and resource cleanup in the Android implementation.

These changes collectively provide a robust foundation for embedded mpv playback across platforms, with a clear path for further feature development and frontend integration.

Serph91P and others added 15 commits March 29, 2026 13:01
- Add react-native-mpv native module (Android Kotlin + iOS Swift)
  - Android: libmpv via dev.jdtech.mpv:libmpv:0.5.1
  - iOS: MPVKit ~> 0.40.0 via CocoaPods
  - Full playback control: play/pause/seek/stop, audio/subtitle tracks
  - Hardware decoding enabled by default
- Rewrite PlayerScreen.native.tsx to use single mpv backend
  - EPG overlay (LIVE badge, progress bar, next title)
  - Back button handling with double-press exit
  - Loading timeout (20s) with auto-recovery
  - Watch progress tracking via ViewerContext
  - Audio/subtitle track selection
- Add withMpvPlayer Expo plugin for MPVKit CocoaPods source
- Remove react-native-video and react-native-vlc-media-player deps
- Remove VLC patches
- Add mpvController.js with JSON IPC socket communication
- Add mpv IPC handlers to main.js
- Add mpv API to preload.js
- Update PlayerScreen.web.tsx with embedded mpv overlay controls
- Note: takeover mode only - true embedding blocked on Wayland
- useDeviceType: tablet now uses bottom tabs alongside phone
- useScale: add phone base resolution (440x960)
- useResponsiveColumns: new hook for dynamic grid columns based on screen width
- VODScreen, SeriesScreen, SearchScreen: use responsive column grid
- LiveTVScreen: auto-width category pills on phone, responsive margins
- MovieDetailsScreen: vertical layout on phone, StatusBar padding for back button,
  smaller poster, responsive gradient padding
- SeriesDetailsScreen: fix text rendering bug (rating ternary), horizontal season
  buttons on phone, vertical episode cards with 16:9 thumbnails, StatusBar padding
- Add startPosition prop to MpvPlayerView (Android + iOS + TS bridge)
- Native side sets pendingSeek on FILE_LOADED for reliable seek timing
- Remove JS-side seek from handleMpvLoad (was racing with file load)
- Fix Kotlin deprecated warnings: modern UIManagerHelper event dispatch,
  Kotlin mapOf(), async destroy with guarded callbacks
- Tap on Continue Watching card shows resume/start-over dialog immediately
- Skips navigation to movie/series detail screen for faster playback
- Builds stream URL and navigates directly to Player with correct startPosition
- Fixes Continue Watching poster aspect ratio (2:3)
@sparkison
Copy link
Copy Markdown
Member

I've been struggling all day to get this working and the native side is completely broken 🤷 It doesn't link correctly for the Expo build, and once I got it linked, it references Android libs that don't exist for iOS and other mangled things. It's just not working at all on the native side

I'll struggle a bit longer and see if I can make progress, but if I can't get playback working I'm gonna close it. Playback is working on native in the master branch currently on both Android TV and tvOS. Still working on trying to get tvOS working, haven't even tried Android TV yet...

@Serph91P
Copy link
Copy Markdown
Contributor Author

I've been struggling all day to get this working and the native side is completely broken 🤷 It doesn't link correctly for the Expo build, and once I got it linked, it references Android libs that don't exist for iOS and other mangled things. It's just not working at all on the native side

I'll struggle a bit longer and see if I can make progress, but if I can't get playback working I'm gonna close it. Playback is working on native in the master branch currently on both Android TV and tvOS. Still working on trying to get tvOS working, haven't even tried Android TV yet...

Sorry about that. It was working for me on the android side great. I even pushed it to my smartphone and can use it just fine. I have no Mac that's why I cannot test this on it. But on Linux and Windows it works as well.

So again sorry.

- Fix react-native.config.json: use 'dependency' format instead of
  'platforms' array (was being treated as a Platform Provider, not a
  dependency, causing iOS autolinking to skip the module entirely)
- Fix podspec path reference from ./ios/ to ./ (podspec lives at root)
- Replace deprecated 'React-Core' dependency with install_modules_dependencies()
  for proper RN 0.81+ New Architecture compatibility
- Fix critical ObjC/Swift name mismatch: bridge declared MpvPlayerViewManager
  but Swift class was @objc(MpvViewManager) — renamed to MpvPlayerViewManager
  so RN correctly derives view name 'MpvPlayerView'
- Add missing Bridging Header (react-native-mpv-Bridging-Header.h)
- Fix ObjC bridge trackId type from int to NSInteger (matches Swift Int)
- Raise deployment target from 15.1 to 16.0 for MPVKit compatibility
- Remove direct 'import React' from Swift files (use bridging header instead)
@Serph91P
Copy link
Copy Markdown
Contributor Author

I've been struggling all day to get this working and the native side is completely broken 🤷 It doesn't link correctly for the Expo build, and once I got it linked, it references Android libs that don't exist for iOS and other mangled things. It's just not working at all on the native side

I'll struggle a bit longer and see if I can make progress, but if I can't get playback working I'm gonna close it. Playback is working on native in the master branch currently on both Android TV and tvOS. Still working on trying to get tvOS working, haven't even tried Android TV yet...

@sparkison can you please check again I pushed some updates. It's kinda hard for me to test this with the whole apple thing only running on an Apple device.

Builds all platforms to verify compilation:
- Lint & typecheck (ubuntu)
- Android TV (EXPO_TV=1) and Android Phone
- tvOS (Apple TV simulator) and iOS (iPhone simulator)
- Electron: Linux (AppImage), macOS (DMG), Windows (EXE)

Triggers on push/PR to main, master, dev branches.
Uploads build artifacts for 7 days.
@Serph91P
Copy link
Copy Markdown
Contributor Author

Added a workflow to test if the app builds for all the platforms.

@sparkison
Copy link
Copy Markdown
Member

well shit, I was making progress, now it seems prebuild won't work any more for iOS. If you could leave the iOS side as-is for now I'll work on a fix...

sparkison and others added 3 commits March 31, 2026 06:42
…nt target

- Add description and author fields to package.json (required for .deb)
- Set ios.deploymentTarget to 16.0 via expo-build-properties
  (fixes CocoaPods 'higher minimum deployment target' error for MPVKit)
@Serph91P
Copy link
Copy Markdown
Contributor Author

well shit, I was making progress, now it seems prebuild won't work any more for iOS. If you could leave the iOS side as-is for now I'll work on a fix...

  • Electron Linux (deb build failed on missing author email): Added description and author (with email) to package.json

  • iOS/tvOS (CocoaPods "higher minimum deployment target"): Added ios.deploymentTarget: '16.0' to the expo-build-properties plugin in app.config.js this gets written to Podfile.properties.json during prebuild, so the Podfile reads 16.0 instead of the 15.1 fallback, matching what MPVKit requires

- actions/checkout v4 → v6
- actions/setup-node v4 → v6
- actions/setup-java v4 → v5
- actions/cache v4 → v5
- actions/upload-artifact v4 → v7
- Node.js 22 → 24
@Serph91P
Copy link
Copy Markdown
Contributor Author

Updated all the actions and node to 24.

@sparkison
Copy link
Copy Markdown
Member

Apple devices might be fucked, lol! I can get the app built and installed, but the nav is totally screwed up. It's impossible to navigate the app now, and if I do manage to navigate to a screen I get stuck with no option to back out. None of the playback controls work either, the player screen just freezes forcing a device reboot to close it, it's a mess, lol!!

I'm done messing with it for now, it's good enough, I don't have time to keep rebuilding this thing to test, it takes too damn long. And the build pass is a red herring too since it doesn't check nav or playback etc. It's great that we'll be able to know it builds at least, but that doesn't really help much in the long run if you still have to build install and test to confirm.

@Serph91P
Copy link
Copy Markdown
Contributor Author

Apple devices might be fucked, lol! I can get the app built and installed, but the nav is totally screwed up. It's impossible to navigate the app now, and if I do manage to navigate to a screen I get stuck with no option to back out. None of the playback controls work either, the player screen just freezes forcing a device reboot to close it, it's a mess, lol!!

I'm done messing with it for now, it's good enough, I don't have time to keep rebuilding this thing to test, it takes too damn long. And the build pass is a red herring too since it doesn't check nav or playback etc. It's great that we'll be able to know it builds at least, but that doesn't really help much in the long run if you still have to build install and test to confirm.

Sorry about that again. It does suck that I cannot help with apple at all since they require for you to have an apple device to build it.
Android is working fine Like I said I even build the apk and installed it on my phone and working fine.

Still not working right, crashes on playback.
@sparkison sparkison merged commit 682bbea into m3ue:master Mar 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants