mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
fix: remove Android emulator detection from MPV player (#1369)
This commit is contained in:
@@ -33,23 +33,6 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "MpvPlayerView"
|
private const val TAG = "MpvPlayerView"
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect if running on an Android emulator.
|
|
||||||
* MPV player has EGL/OpenGL compatibility issues on emulators.
|
|
||||||
*/
|
|
||||||
private fun isEmulator(): Boolean {
|
|
||||||
return (Build.FINGERPRINT.startsWith("generic")
|
|
||||||
|| Build.FINGERPRINT.startsWith("unknown")
|
|
||||||
|| Build.MODEL.contains("google_sdk")
|
|
||||||
|| Build.MODEL.contains("Emulator")
|
|
||||||
|| Build.MODEL.contains("Android SDK built for x86")
|
|
||||||
|| Build.MANUFACTURER.contains("Genymotion")
|
|
||||||
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|
|
||||||
|| "google_sdk" == Build.PRODUCT
|
|
||||||
|| Build.HARDWARE.contains("goldfish")
|
|
||||||
|| Build.HARDWARE.contains("ranchu"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event dispatchers
|
// Event dispatchers
|
||||||
@@ -104,21 +87,14 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the renderer (skip on emulators to avoid EGL crashes)
|
// Start the renderer
|
||||||
if (isEmulator()) {
|
try {
|
||||||
Log.w(TAG, "Running on emulator - MPV player disabled due to EGL/OpenGL compatibility issues")
|
renderer?.start()
|
||||||
// Don't start renderer on emulator, will show error when trying to play
|
} catch (e: Exception) {
|
||||||
} else {
|
Log.e(TAG, "Failed to start renderer: ${e.message}")
|
||||||
try {
|
onError(mapOf("error" to "Failed to start renderer: ${e.message}"))
|
||||||
renderer?.start()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Failed to start renderer: ${e.message}")
|
|
||||||
onError(mapOf("error" to "Failed to start renderer: ${e.message}"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isOnEmulator: Boolean = isEmulator()
|
|
||||||
|
|
||||||
// MARK: - SurfaceHolder.Callback
|
// MARK: - SurfaceHolder.Callback
|
||||||
|
|
||||||
@@ -149,13 +125,6 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|||||||
// MARK: - Video Loading
|
// MARK: - Video Loading
|
||||||
|
|
||||||
fun loadVideo(config: VideoLoadConfig) {
|
fun loadVideo(config: VideoLoadConfig) {
|
||||||
// Block video loading on emulators
|
|
||||||
if (isOnEmulator) {
|
|
||||||
Log.w(TAG, "Cannot load video on emulator - MPV player not supported")
|
|
||||||
onError(mapOf("error" to "MPV player is not supported on emulators. Please test on a real device."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip reload if same URL is already playing
|
// Skip reload if same URL is already playing
|
||||||
if (currentUrl == config.url) {
|
if (currentUrl == config.url) {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user