Compare commits

..
8 Commits
Author SHA1 Message Date
github-actions[bot] 888d232819 chore: bump version to 1.9.1 2025-12-05 20:14:02 +00:00
edde746 6c45706ea3 fix: improve item selection logic in playlist navigation
close #149
2025-12-05 21:12:29 +01:00
edde746 2a15126119 fix: macos playback crash
close #147
2025-12-05 20:50:29 +01:00
edde746 392ee575d0 fix: controls not reappearing on some android devices 2025-12-05 19:11:48 +01:00
edde746 6db21d93bb fix: hide hidden libraries on the home screen
close #145
2025-12-05 14:08:04 +01:00
edde746 4eed2aa3d2 fix: android app switching 2025-12-05 13:49:20 +01:00
edde746 cc9cdc8f26 fix: initialize language codes 2025-12-05 11:09:17 +01:00
edde746 20933d3543 fix: macos playback crash 2025-12-04 20:32:15 +01:00
10 changed files with 101 additions and 24 deletions
@@ -8,6 +8,8 @@ import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.TextureView
import dev.jdtech.mpv.MPVLib
interface MpvPlayerDelegate {
@@ -24,10 +26,58 @@ class MpvPlayerCore(private val activity: Activity) :
}
private var surfaceView: SurfaceView? = null
private var overlayLayoutListener: ViewTreeObserver.OnGlobalLayoutListener? =
null
private var voInUse: String = "gpu"
var delegate: MpvPlayerDelegate? = null
var isInitialized: Boolean = false
private set
private fun ensureFlutterOverlayOnTop() {
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
contentView.post {
var flutterContainer: ViewGroup? = null
// First pass: look for FlutterView by name (debug builds)
for (i in 0 until contentView.childCount) {
val child = contentView.getChildAt(i)
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
flutterContainer = child
break
}
}
// Fallback for release (FlutterView may be obfuscated): pick the last ViewGroup
// that is not our mpv SurfaceView and has children.
if (flutterContainer == null) {
for (i in contentView.childCount - 1 downTo 0) {
val child = contentView.getChildAt(i)
if (child is ViewGroup && child != surfaceView?.parent && child.childCount > 0) {
flutterContainer = child
break
}
}
}
flutterContainer?.let { container ->
contentView.bringChildToFront(container)
for (j in 0 until container.childCount) {
val flutterChild = container.getChildAt(j)
if (flutterChild is SurfaceView) {
flutterChild.setZOrderOnTop(true)
flutterChild.setZOrderMediaOverlay(true)
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
break
} else if (flutterChild is TextureView) {
// TextureView uses alpha composition; ensure it stays above.
flutterChild.isOpaque = false
break
}
}
}
}
}
fun initialize(): Boolean {
if (isInitialized) {
Log.d(TAG, "Already initialized")
@@ -42,6 +92,9 @@ class MpvPlayerCore(private val activity: Activity) :
ViewGroup.LayoutParams.MATCH_PARENT
)
setBackgroundColor(Color.BLACK)
// Keep video composited in the normal view hierarchy (avoid hardware overlay promotion)
// so Flutter controls reliably draw above it in release builds.
alpha = 0.999f
holder.addCallback(this@MpvPlayerCore)
// Critical: Ensure SurfaceView renders BEHIND Flutter's view
@@ -57,20 +110,27 @@ class MpvPlayerCore(private val activity: Activity) :
for (i in 0 until contentView.childCount) {
val child = contentView.getChildAt(i)
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
contentView.bringChildToFront(child)
// Look inside FlutterView for FlutterSurfaceView
for (j in 0 until child.childCount) {
val flutterChild = child.getChildAt(j)
if (flutterChild is SurfaceView) {
// Put Flutter in media overlay layer (above our video which is in normal layer)
flutterChild.setZOrderOnTop(true)
flutterChild.setZOrderMediaOverlay(true)
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
Log.d(TAG, "Set FlutterSurfaceView to MediaOverlay with TRANSLUCENT: ${flutterChild.javaClass.name}")
break
}
}
break
}
}
// Repeat after layout settles to catch late-added Flutter surfaces (release builds)
ensureFlutterOverlayOnTop()
overlayLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
ensureFlutterOverlayOnTop()
}
contentView.viewTreeObserver.addOnGlobalLayoutListener(overlayLayoutListener)
Log.d(TAG, "SurfaceView added to content view")
@@ -111,6 +171,10 @@ class MpvPlayerCore(private val activity: Activity) :
Log.d(TAG, "Surface created")
MPVLib.attachSurface(holder.surface)
MPVLib.setOptionString("force-window", "yes")
// Restore video output after surface is available
MPVLib.setPropertyString("vo", voInUse)
// Reassert overlay order whenever the surface is recreated
ensureFlutterOverlayOnTop()
}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
@@ -120,6 +184,8 @@ class MpvPlayerCore(private val activity: Activity) :
override fun surfaceDestroyed(holder: SurfaceHolder) {
Log.d(TAG, "Surface destroyed")
// Disable video output before detaching (like mpv-android)
MPVLib.setPropertyString("vo", "null")
MPVLib.setOptionString("force-window", "no")
MPVLib.detachSurface()
}
@@ -209,20 +275,6 @@ class MpvPlayerCore(private val activity: Activity) :
}
}
// Lifecycle handling
fun onPause() {
if (!isInitialized) return
Log.d(TAG, "onPause - disabling video")
setProperty("vid", "no")
}
fun onResume() {
if (!isInitialized) return
Log.d(TAG, "onResume - enabling video")
setProperty("vid", "auto")
}
// Cleanup
fun dispose() {
@@ -231,6 +283,10 @@ class MpvPlayerCore(private val activity: Activity) :
MPVLib.removeObserver(this)
surfaceView?.holder?.removeCallback(this)
overlayLayoutListener?.let { listener ->
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
contentView.viewTreeObserver.removeOnGlobalLayoutListener(listener)
}
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
surfaceView?.let { contentView.removeView(it) }
@@ -48,7 +48,6 @@ class MpvPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
activity = binding.activity
activityBinding = binding
binding.addOnUserLeaveHintListener { playerCore?.onPause() }
Log.d(TAG, "Attached to activity")
}
+4
View File
@@ -23,6 +23,7 @@ import 'services/data_aggregation_service.dart';
import 'services/server_registry.dart';
import 'utils/app_logger.dart';
import 'utils/orientation_helper.dart';
import 'utils/language_codes.dart';
import 'i18n/strings.g.dart';
void main() async {
@@ -52,6 +53,9 @@ void main() async {
// Initialize storage service
futures.add(StorageService.getInstance().then((_) {}));
// Initialize language codes for track selection
futures.add(LanguageCodes.initialize());
// Wait for all parallel services to complete
await Future.wait(futures);
+11 -2
View File
@@ -325,9 +325,18 @@ class _DiscoverScreenState extends State<DiscoverScreen>
// Wait for libraries and then fetch hubs
final librariesByServer = await librariesFuture;
// Fetch hubs using the pre-fetched libraries
// Get hidden libraries to filter from hubs
final hiddenLibrariesProvider = Provider.of<HiddenLibrariesProvider>(
context,
listen: false,
);
// Fetch hubs using the pre-fetched libraries and hidden keys
final allHubs = await multiServerProvider.aggregationService
.getHubsFromAllServers(librariesByServer: librariesByServer);
.getHubsFromAllServers(
librariesByServer: librariesByServer,
hiddenLibraryKeys: hiddenLibrariesProvider.hiddenLibraryKeys,
);
// Filter out duplicate hubs that we already fetch separately
final filteredHubs = allHubs.where((hub) {
@@ -240,9 +240,12 @@ class _PlaylistDetailScreenState
widget.playlist.ratingKey,
);
// Navigate to selected item (should be first in the queue response)
// Navigate to selected item
if (mounted) {
await navigateToVideoPlayer(context, metadata: playQueue.items!.first);
await navigateToVideoPlayer(
context,
metadata: playQueue.selectedItem ?? playQueue.items!.first,
);
}
} catch (e) {
appLogger.e('Failed to play from item', error: e);
@@ -134,6 +134,7 @@ class DataAggregationService {
Future<List<PlexHub>> getHubsFromAllServers({
int? limit,
Map<String, List<PlexLibrary>>? librariesByServer,
Set<String>? hiddenLibraryKeys,
}) async {
final clients = _serverManager.onlineClients;
@@ -171,6 +172,11 @@ class DataAggregationService {
if (library.hidden != null && library.hidden != 0) {
return false;
}
// Check app-level hidden libraries
if (hiddenLibraryKeys != null &&
hiddenLibraryKeys.contains(library.globalKey)) {
return false;
}
return true;
}).toList();
+1 -1
View File
@@ -823,7 +823,7 @@
repositoryURL = "https://github.com/edde746/MPVKit";
requirement = {
kind = revision;
revision = 0d0931fbbb25a3483a7edb46babd3f2f55abeefc;
revision = e6afd7fa47b6a0f55c29028bbebb4a05b43e779f;
};
};
/* End XCRemoteSwiftPackageReference section */
@@ -6,7 +6,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/edde746/MPVKit",
"state" : {
"revision" : "0d0931fbbb25a3483a7edb46babd3f2f55abeefc"
"revision" : "e6afd7fa47b6a0f55c29028bbebb4a05b43e779f"
}
}
],
@@ -6,7 +6,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/edde746/MPVKit",
"state" : {
"revision" : "0d0931fbbb25a3483a7edb46babd3f2f55abeefc"
"revision" : "e6afd7fa47b6a0f55c29028bbebb4a05b43e779f"
}
}
],
+1 -1
View File
@@ -1,7 +1,7 @@
name: plezy
description: "A beautiful Plex client for Flutter"
publish_to: "none"
version: 1.9.0+22
version: 1.9.1+23
environment:
sdk: ^3.8.1