准备进入新的测试阶段,先做一个snapshot(此版本下不可用)
This commit is contained in:
@@ -4,17 +4,41 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.core.content.FileProvider
|
||||
import com.ryanheise.audioservice.AudioServiceActivity
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import java.io.File
|
||||
|
||||
class MainActivity : AudioServiceActivity() {
|
||||
class MainActivity : FlutterActivity() {
|
||||
|
||||
private val CHANNEL = "com.lxh.qingting_player/file_provider"
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// ⭐ 强制加载 libmediakitandroidhelper.so,触发 JNI_OnLoad,缓存 JavaVM
|
||||
try {
|
||||
System.loadLibrary("mediakitandroidhelper")
|
||||
Log.d("MainActivity", "✅ libmediakitandroidhelper loaded")
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
Log.e("MainActivity", "❌ libmediakitandroidhelper load failed", e)
|
||||
}
|
||||
|
||||
// ⭐ 可选:预加载 libmpv.so(让系统 linker 也可见,增强兼容性)
|
||||
try {
|
||||
System.loadLibrary("mpv")
|
||||
Log.d("MainActivity", "✅ libmpv loaded")
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
Log.e("MainActivity", "❌ libmpv load failed", e)
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setHighRefreshRate()
|
||||
}
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
|
||||
// FileProvider MethodChannel for sharing artwork via content:// URI
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
|
||||
.setMethodCallHandler { call, result ->
|
||||
if (call.method == "getContentUri") {
|
||||
@@ -46,20 +70,6 @@ class MainActivity : AudioServiceActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// 🔥 测试 libmpv.so 能否被系统加载
|
||||
try {
|
||||
System.loadLibrary("mpv")
|
||||
Log.e("MPV_TEST", "🔥 libmpv LOAD SUCCESS")
|
||||
} catch (e: Throwable) {
|
||||
Log.e("MPV_TEST", "🔥 libmpv LOAD FAILED", e)
|
||||
}
|
||||
|
||||
setHighRefreshRate()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setHighRefreshRate()
|
||||
@@ -77,17 +87,4 @@ class MainActivity : AudioServiceActivity() {
|
||||
Log.e("QTPlayer", "设置高刷失败: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearRefreshRate() {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val params = window.attributes
|
||||
params.preferredRefreshRate = 0f
|
||||
window.attributes = params
|
||||
Log.d("QTPlayer", "恢复默认刷新率")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("QTPlayer", "恢复默认刷新率失败: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user