通知中心封面图显示

部分界面的信息更新
缓存系统初步引入
即将进入播放列表更新
This commit is contained in:
2026-08-25 23:09:17 +08:00
parent 0e8921742c
commit f2b4d1f46d
16 changed files with 454 additions and 161 deletions
+35 -24
View File
@@ -1,51 +1,50 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 权限不变 -->
<uses-permission android:name="android.permission.INTERNET"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lxh.qingting_player">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:label="清听"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="清听"
android:usesCleartextTraffic="true"
android:foregroundServiceType="mediaPlayback">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- ⭐ 关键:AudioService 必须同时声明 MediaBrowserService 和 MEDIA_BUTTON -->
<!-- AudioService -->
<service
android:name="com.ryanheise.audioservice.AudioService"
android:foregroundServiceType="mediaPlayback"
android:exported="true">
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<!-- 媒体浏览器服务(MediaButtonReceiver 需要) -->
<action android:name="android.media.browse.MediaBrowserService" />
<!-- 媒体按钮(通知栏、蓝牙、耳机按键) -->
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>
<!-- MediaButtonReceiver 接收系统媒体按钮事件 -->
<!-- MediaButtonReceiver -->
<receiver
android:name="com.ryanheise.audioservice.MediaButtonReceiver"
android:exported="true">
@@ -53,16 +52,28 @@
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<!-- FileProvider for artwork -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain" />
</intent>
</queries>
</manifest>
@@ -3,9 +3,50 @@ package com.lxh.qingting_player
import android.os.Build
import android.os.Bundle
import android.util.Log
import com.ryanheise.audioservice.AudioServiceActivity // ⭐ 改用这个
import androidx.core.content.FileProvider
import com.ryanheise.audioservice.AudioServiceActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import java.io.File
class MainActivity : AudioServiceActivity() { // ⭐ 继承 AudioServiceActivity
class MainActivity : AudioServiceActivity() {
private val CHANNEL = "com.lxh.qingting_player/file_provider"
// ⭐ 关键:注册 MethodChannel
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
.setMethodCallHandler { call, result ->
if (call.method == "getContentUri") {
val path = call.argument<String>("path")
if (path != null && path.isNotEmpty()) {
try {
val file = File(path)
if (!file.exists()) {
result.error("FILE_NOT_FOUND", "File does not exist: $path", null)
return@setMethodCallHandler
}
val uri = FileProvider.getUriForFile(
this,
"${packageName}.fileprovider",
file
)
Log.d("QTPlayer", "📢 [FileProvider] content URI: $uri")
result.success(uri.toString())
} catch (e: Exception) {
Log.e("QTPlayer", "❌ [FileProvider] error: ${e.message}")
result.error("ERROR", e.message, null)
}
} else {
result.error("INVALID_PATH", "path is null or empty", null)
}
} else {
result.notImplemented()
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<!-- app_flutter 目录(getApplicationDocumentsDirectory -->
<files-path name="app_flutter" path="../app_flutter/" />
<!-- 封面图目录 -->
<files-path name="artworks" path="../app_flutter/artworks/" />
<!-- 缓存目录 -->
<cache-path name="cache" path="." />
<!-- 外部文件目录(备用) -->
<external-files-path name="external" path="." />
</paths>