Skip to content

Commit f26b1a3

Browse files
committed
fix(*)
1 parent 736f8e7 commit f26b1a3

5 files changed

Lines changed: 5 additions & 136 deletions

File tree

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@
7575
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileProvider" android:exported="false" android:grantUriPermissions="true" tools:replace="android:authorities">
7676
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" tools:replace="android:resource" />
7777
</provider>
78-
<service android:name=".BetterPlayerService" android:foregroundServiceType="mediaPlayback" android:exported="false">
79-
</service>
8078
<!-- 注册服务 -->
8179
<service android:name="com.pravera.flutter_foreground_task.service.ForegroundService" android:foregroundServiceType="mediaPlayback" android:exported="false" />
8280
</application>

android/app/src/main/kotlin/com/mystyle/pure_live/BetterPlayerService.kt

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
11
package com.mystyle.purelive
22

3-
import android.content.Intent
4-
import android.os.Build
5-
import android.os.Bundle
63
import io.flutter.embedding.android.FlutterActivity
74

8-
class MainActivity : FlutterActivity() {
9-
10-
override fun onCreate(savedInstanceState: Bundle?) {
11-
super.onCreate(savedInstanceState)
12-
startNotificationService()
13-
}
14-
15-
override fun onDestroy() {
16-
super.onDestroy()
17-
stopNotificationService()
18-
}
19-
20-
///TODO: Call this method via channel after remote notification start
21-
private fun startNotificationService() {
22-
try {
23-
val intent = Intent(this, BetterPlayerService::class.java)
24-
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
25-
startForegroundService(intent)
26-
} else {
27-
startService(intent)
28-
}
29-
} catch (exception: Exception) {
30-
}
31-
}
32-
33-
///TODO: Call this method via channel after remote notification stop
34-
private fun stopNotificationService() {
35-
try {
36-
val intent = Intent(this, BetterPlayerService::class.java)
37-
stopService(intent)
38-
} catch (exception: Exception) {
39-
40-
}
41-
}
42-
}
5+
class MainActivity : FlutterActivity()

lib/player/adapters/video_player_adapter.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BetterPlayerAdapter implements UnifiedPlayer {
2929
BetterPlayerConfiguration betterPlayerConfiguration = BetterPlayerConfiguration(
3030
autoPlay: true,
3131
fit: BoxFit.contain,
32-
handleLifecycle: false,
32+
handleLifecycle: true,
3333
fullScreenByDefault: false,
3434
autoDispose: false,
3535
looping: false,
@@ -102,16 +102,7 @@ class BetterPlayerAdapter implements UnifiedPlayer {
102102
url,
103103
headers: headers,
104104
liveStream: true,
105-
notificationConfiguration: room != null
106-
? BetterPlayerNotificationConfiguration(
107-
showNotification: true,
108-
title: room.nick ?? "",
109-
author: room.title ?? "",
110-
imageUrl: room.cover,
111-
notificationChannelName: "VideoPlayer",
112-
activityName: "MainActivity",
113-
)
114-
: const BetterPlayerNotificationConfiguration(showNotification: false),
105+
notificationConfiguration: const BetterPlayerNotificationConfiguration(showNotification: false),
115106
);
116107

117108
await _controller!.setupDataSource(dataSource);

lib/player/core/player_manager.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,8 @@ class PlayerManager {
256256
try {
257257
_stateSubject.add(PlayerState.preparing);
258258

259-
if (_currentPlayer is! BetterPlayerAdapter) {
260-
await player.setDataSource(url, playUrls, headers);
261-
BackgroundService.startService(room?.nick ?? "", room?.title ?? "");
262-
} else {
263-
await player.setDataSource(url, playUrls, headers, room: room);
264-
}
259+
await player.setDataSource(url, playUrls, headers);
260+
BackgroundService.startService(room?.nick ?? "", room?.title ?? "");
265261

266262
videoKey.value = ValueKey("video_${DateTime.now().millisecondsSinceEpoch}");
267263

0 commit comments

Comments
 (0)