Skip to content

Commit

Permalink
Merge pull request #72 from xiaoyaocz/dev
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
xiaoyaocz authored Aug 3, 2023
2 parents 0d73f87 + 91820ac commit 442bf33
Show file tree
Hide file tree
Showing 22 changed files with 483 additions and 1,395 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_app_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Flutter action
uses: subosito/flutter-action@v2
with:
flutter-version: '3.10.5'
flutter-version: '3.10.6'
cache: true
#更新Flutter的packages
- name: Restore packages
Expand Down
6 changes: 3 additions & 3 deletions assets/app_version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "1.1.1",
"version_num": 10101,
"version_desc": "1. 支持抖音直播平台\n2. 新增定时关闭功能\n3. 修复一些BUG",
"version": "1.2.0",
"version_num": 10200,
"version_desc": "1. 播放器增加兼容模式\n2. 修改虎牙直播间标题获取 #48\n3. 修复虎牙直播播放问题 #71\n4. 直播间全屏增加刷新按钮 #42\n5. 修复哔哩哔哩部分直播间无法观看问题 #59\n6. 修复弹幕默认开关设置无效问题 #65\n7. 增加进入直播间自动全屏选项 #41\n8. 增加弹幕关键词屏蔽功能 #70\n9. 增加双击全屏功能 #56",
"prerelease":false,
"download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases"
}
3 changes: 3 additions & 0 deletions simple_live_app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

/ios/Podfile.lock
pubspec.lock
2 changes: 1 addition & 1 deletion simple_live_app/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
95 changes: 0 additions & 95 deletions simple_live_app/ios/Podfile.lock

This file was deleted.

2 changes: 2 additions & 0 deletions simple_live_app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>FLTEnableImpeller</key>
<false />
</dict>
</plist>
34 changes: 34 additions & 0 deletions simple_live_app/lib/app/controller/app_settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ class AppSettingsController extends GetxController {
autoExitDuration.value = LocalStorageService.instance
.getValue(LocalStorageService.kAutoExitDuration, 60);

playerCompatMode.value = LocalStorageService.instance
.getValue(LocalStorageService.kPlayerCompatMode, false);

autoFullScreen.value = LocalStorageService.instance
.getValue(LocalStorageService.kAutoFullScreen, false);

// ignore: invalid_use_of_protected_member
shieldList.value = LocalStorageService.instance.shieldBox.values.toSet();

super.onInit();
}

Expand Down Expand Up @@ -170,4 +179,29 @@ class AppSettingsController extends GetxController {
LocalStorageService.instance
.setValue(LocalStorageService.kAutoExitDuration, e);
}

var playerCompatMode = false.obs;
void setPlayerCompatMode(bool e) {
playerCompatMode.value = e;
LocalStorageService.instance
.setValue(LocalStorageService.kPlayerCompatMode, e);
}

var autoFullScreen = false.obs;
void setAutoFullScreen(bool e) {
autoFullScreen.value = e;
LocalStorageService.instance
.setValue(LocalStorageService.kAutoFullScreen, e);
}

RxSet<String> shieldList = <String>{}.obs;
void addShieldList(String e) {
shieldList.add(e);
LocalStorageService.instance.shieldBox.put(e, e);
}

void removeShieldList(String e) {
shieldList.remove(e);
LocalStorageService.instance.shieldBox.delete(e);
}
}
83 changes: 54 additions & 29 deletions simple_live_app/lib/modules/live_room/live_room_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ class LiveRoomController extends BaseController {
late final player = Player();
late final videoController = VideoController(
player,
configuration: VideoControllerConfiguration(
enableHardwareAcceleration: settingsController.hardwareDecode.value,
),
configuration: settingsController.playerCompatMode.value
? const VideoControllerConfiguration(
vo: 'mediacodec_embed',
hwdec: 'mediacodec',
)
: VideoControllerConfiguration(
enableHardwareAcceleration: settingsController.hardwareDecode.value,
),
);

DanmakuView? danmakuView;
Expand All @@ -102,6 +107,7 @@ class LiveRoomController extends BaseController {
void onInit() {
initAutoExit();
playerListener();
enableDanmaku.value = settingsController.danmuEnable.value;
followed.value = DBService.instance.getFollowExist("${site.id}_$roomId");
setSystem();
loadData();
Expand Down Expand Up @@ -137,6 +143,10 @@ class LiveRoomController extends BaseController {

//屏幕常亮
Wakelock.enable();

if (settingsController.autoFullScreen.value) {
setFull();
}
}

/// 弹幕控制器初始化,初始化一些选项
Expand Down Expand Up @@ -179,6 +189,15 @@ class LiveRoomController extends BaseController {
if (messages.length > 200) {
messages.removeAt(0);
}

// 关键词屏蔽检查
for (var keyword in settingsController.shieldList) {
if (msg.message.contains(keyword)) {
Log.d("关键词:$keyword\n消息内容:${msg.message}");
return;
}
}

messages.add(msg);

WidgetsBinding.instance.addPostFrameCallback(
Expand Down Expand Up @@ -252,28 +271,33 @@ class LiveRoomController extends BaseController {
void getPlayQualites() async {
qualites.clear();
currentQuality = -1;
var playQualites =
await site.liveSite.getPlayQualites(detail: detail.value!);
try {
var playQualites =
await site.liveSite.getPlayQualites(detail: detail.value!);

if (playQualites.isEmpty) {
SmartDialog.showToast("无法读取播放清晰度");
return;
}
qualites.value = playQualites;

if (settingsController.qualityLevel.value == 2) {
//最高
currentQuality = 0;
} else if (settingsController.qualityLevel.value == 0) {
//最低
currentQuality = playQualites.length - 1;
} else {
//中间值
int middle = (playQualites.length / 2).floor();
currentQuality = middle;
}

if (playQualites.isEmpty) {
getPlayUrl();
} catch (e) {
Log.logPrint(e);
SmartDialog.showToast("无法读取播放清晰度");
return;
}
qualites.value = playQualites;

if (settingsController.qualityLevel.value == 2) {
//最高
currentQuality = 0;
} else if (settingsController.qualityLevel.value == 0) {
//最低
currentQuality = playQualites.length - 1;
} else {
//中间值
int middle = (playQualites.length / 2).floor();
currentQuality = middle;
}

getPlayUrl();
}

void getPlayUrl() async {
Expand Down Expand Up @@ -309,6 +333,7 @@ class LiveRoomController extends BaseController {
httpHeaders: headers,
),
);
Log.d("播放链接\r\n:${playUrls[currentUrl]}");
}

StreamSubscription? bufferingStream;
Expand All @@ -320,34 +345,34 @@ class LiveRoomController extends BaseController {

/// 事件监听
void playerListener() {
bufferingStream = player.streams.buffering.listen((event) {
bufferingStream = player.stream.buffering.listen((event) {
Log.w('Buffering:$event');
playerLoadding.value = event;
});

widthStream = player.streams.width.listen((event) {
widthStream = player.stream.width.listen((event) {
Log.w(
'width:$event W:${(player.state.width)} H:${(player.state.height)}');

isVertical.value =
(player.state.height ?? 9) > (player.state.width ?? 16);
});
heightStream = player.streams.height.listen((event) {
heightStream = player.stream.height.listen((event) {
Log.w(
'height:$event W:${(player.state.width)} H:${(player.state.height)}');
isVertical.value =
(player.state.height ?? 9) > (player.state.width ?? 16);
});
trackStream = player.streams.track.listen((event) {
trackStream = player.stream.track.listen((event) {
Log.w('Track:$event');
//接收到轨道信息后,隐藏加载
playerLoadding.value = false;
});
errorStream = player.streams.error.listen((event) {
Log.w('${event.code}: ${event.message}');
errorStream = player.stream.error.listen((event) {
Log.w(event);
mediaError();
});
endStream = player.streams.completed.listen((event) {
endStream = player.stream.completed.listen((event) {
if (event) {
mediaEnd();
}
Expand Down
23 changes: 23 additions & 0 deletions simple_live_app/lib/modules/live_room/live_room_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ class LiveRoomPage extends GetView<LiveRoomController> {
onTap: () {
controller.showControls.value = !controller.showControls.value;
},
onDoubleTap: () {
if (controller.fullScreen.value) {
controller.exitFull();
} else {
controller.setFull();
}
},
onVerticalDragStart: controller.onVerticalDragStart,
onVerticalDragUpdate: controller.onVerticalDragUpdate,
onVerticalDragEnd: controller.onVerticalDragEnd,
Expand Down Expand Up @@ -367,6 +374,13 @@ class LiveRoomPage extends GetView<LiveRoomController> {
controller.showQualites.value = false;
controller.showDanmuSettings.value = false;
},
onDoubleTap: () {
if (controller.fullScreen.value) {
controller.exitFull();
} else {
controller.setFull();
}
},
onVerticalDragStart: controller.onVerticalDragStart,
onVerticalDragUpdate: controller.onVerticalDragUpdate,
onVerticalDragEnd: controller.onVerticalDragEnd,
Expand Down Expand Up @@ -465,6 +479,15 @@ class LiveRoomPage extends GetView<LiveRoomController> {
),
child: Row(
children: [
IconButton(
onPressed: () {
controller.refreshRoom();
},
icon: const Icon(
Remix.refresh_line,
color: Colors.white,
),
),
Offstage(
offstage: controller.enableDanmaku.value,
child: IconButton(
Expand Down
Loading

0 comments on commit 442bf33

Please sign in to comment.