From d7b9f2f2a8122e0d37f027634249b149a8033dff Mon Sep 17 00:00:00 2001 From: xiaoyaocz Date: Thu, 3 Aug 2023 16:10:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=97=B4=E4=BD=93=E9=AA=8C=20#73?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live_room/live_room_controller.dart | 19 +++++++++++++++++-- .../lib/modules/live_room/live_room_page.dart | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/simple_live_app/lib/modules/live_room/live_room_controller.dart b/simple_live_app/lib/modules/live_room/live_room_controller.dart index 0814fac2..06d918f8 100644 --- a/simple_live_app/lib/modules/live_room/live_room_controller.dart +++ b/simple_live_app/lib/modules/live_room/live_room_controller.dart @@ -103,6 +103,8 @@ class LiveRoomController extends BaseController { /// 显示播放控制 Rx showControls = true.obs; + Timer? hideControlsTimer; + @override void onInit() { initAutoExit(); @@ -145,8 +147,17 @@ class LiveRoomController extends BaseController { Wakelock.enable(); if (settingsController.autoFullScreen.value) { + //如果是抖音直接设置成竖屏 + if (site.id == "douyin") { + isVertical.value = true; + } setFull(); } + + hideControlsTimer = Timer(const Duration(milliseconds: 3000), () { + //3秒后隐藏控制UI + showControls.value = false; + }); } /// 弹幕控制器初始化,初始化一些选项 @@ -317,7 +328,7 @@ class LiveRoomController extends BaseController { setPlayer(); } - void setPlayer() { + void setPlayer() async { currentUrlInfo.value = "线路${currentUrl + 1}"; Map headers = {}; if (site.id == "bilibili") { @@ -333,6 +344,7 @@ class LiveRoomController extends BaseController { httpHeaders: headers, ), ); + Log.d("播放链接\r\n:${playUrls[currentUrl]}"); } @@ -357,6 +369,7 @@ class LiveRoomController extends BaseController { isVertical.value = (player.state.height ?? 9) > (player.state.width ?? 16); }); + heightStream = player.stream.height.listen((event) { Log.w( 'height:$event W:${(player.state.width)} H:${(player.state.height)}'); @@ -370,8 +383,10 @@ class LiveRoomController extends BaseController { }); errorStream = player.stream.error.listen((event) { Log.w(event); - mediaError(); + // 切换清晰度时会触发此事件,暂时不做处理 + // mediaError(); }); + endStream = player.stream.completed.listen((event) { if (event) { mediaEnd(); diff --git a/simple_live_app/lib/modules/live_room/live_room_page.dart b/simple_live_app/lib/modules/live_room/live_room_page.dart index 80838c57..929195b7 100644 --- a/simple_live_app/lib/modules/live_room/live_room_page.dart +++ b/simple_live_app/lib/modules/live_room/live_room_page.dart @@ -186,6 +186,7 @@ class LiveRoomPage extends GetView { Positioned.fill( child: GestureDetector( onTap: () { + controller.hideControlsTimer?.cancel(); controller.showControls.value = !controller.showControls.value; }, onDoubleTap: () { @@ -369,6 +370,7 @@ class LiveRoomPage extends GetView { Positioned.fill( child: GestureDetector( onTap: () { + controller.hideControlsTimer?.cancel(); controller.showControls.value = !controller.showControls.value; controller.showLines.value = false; controller.showQualites.value = false; From aeab170600eab59f290666093338844724da0b05 Mon Sep 17 00:00:00 2001 From: xiaoyaocz Date: Thu, 3 Aug 2023 17:00:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=85=B3=E6=B3=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=20#19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/models/db/follow_user.dart | 9 +++ .../follow_user/follow_user_controller.dart | 62 +++++++++++++++++++ .../user/follow_user/follow_user_page.dart | 45 ++++++++++++++ simple_live_app/pubspec.yaml | 1 + 4 files changed, 117 insertions(+) diff --git a/simple_live_app/lib/models/db/follow_user.dart b/simple_live_app/lib/models/db/follow_user.dart index 13c3f99c..605bf9a9 100644 --- a/simple_live_app/lib/models/db/follow_user.dart +++ b/simple_live_app/lib/models/db/follow_user.dart @@ -36,4 +36,13 @@ class FollowUser { /// 直播状态 /// 0=未知(加载中) 1=未开播 2=直播中 Rx liveStatus = 0.obs; + + factory FollowUser.fromJson(Map json) => FollowUser( + id: json['id'], + roomId: json['roomId'], + siteId: json['siteId'], + userName: json['userName'], + face: json['face'], + addTime: DateTime.parse(json['addTime']), + ); } diff --git a/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart b/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart index 83faab98..770b6e20 100644 --- a/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart +++ b/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart @@ -1,5 +1,9 @@ import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:simple_live_app/app/constant.dart'; import 'package:simple_live_app/app/controller/base_controller.dart'; import 'package:simple_live_app/app/event_bus.dart'; @@ -57,4 +61,62 @@ class FollowUserController extends BasePageController { subscription?.cancel(); super.onClose(); } + + void exportList() async { + if (list.isEmpty) { + SmartDialog.showToast("列表为空"); + return; + } + var dir = await FilePicker.platform.getDirectoryPath(); + if (dir == null) { + return; + } + try { + var jsonFile = File( + '$dir/SimpleLive_${DateTime.now().millisecondsSinceEpoch ~/ 1000}.json'); + var data = list + .map( + (item) => { + "siteId": item.siteId, + "id": item.id, + "roomId": item.roomId, + "userName": item.userName, + "face": item.face, + "addTime": item.addTime.toString(), + }, + ) + .toList(); + + await jsonFile.writeAsString(jsonEncode(data)); + SmartDialog.showToast("已导出关注列表"); + } catch (e) { + Log.logPrint(e); + SmartDialog.showToast("导出失败"); + } + } + + void inputList() async { + var file = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['json'], + ); + if (file == null) { + return; + } + try { + var jsonFile = File(file.files.single.path!); + var data = jsonDecode(await jsonFile.readAsString()); + + for (var item in data) { + var user = FollowUser.fromJson(item); + DBService.instance.followBox.put(user.id, user); + } + SmartDialog.showToast("导入成功"); + } catch (e) { + Log.logPrint(e); + SmartDialog.showToast("导入失败"); + } finally { + refreshData(); + } + } } diff --git a/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart b/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart index ee774909..e70da9c6 100644 --- a/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart +++ b/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:remixicon/remixicon.dart'; import 'package:simple_live_app/app/app_style.dart'; import 'package:simple_live_app/app/sites.dart'; import 'package:simple_live_app/modules/user/follow_user/follow_user_controller.dart'; @@ -18,6 +19,43 @@ class FollowUserPage extends GetView { return Scaffold( appBar: AppBar( title: const Text("关注用户"), + actions: [ + PopupMenuButton( + itemBuilder: (context) { + return const [ + PopupMenuItem( + value: 0, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Remix.save_2_line), + AppStyle.hGap12, + Text("导出列表") + ], + ), + ), + PopupMenuItem( + value: 1, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Remix.folder_open_line), + AppStyle.hGap12, + Text("导入列表") + ], + ), + ), + ]; + }, + onSelected: (value) { + if (value == 0) { + controller.exportList(); + } else if (value == 1) { + controller.inputList(); + } + }, + ), + ], ), body: PageGridView( crossAxisSpacing: 12, @@ -28,6 +66,7 @@ class FollowUserPage extends GetView { var item = controller.list[i]; var site = Sites.supportSites.firstWhere((x) => x.id == item.siteId); return ListTile( + contentPadding: AppStyle.edgeInsetsL16.copyWith(right: 4), leading: NetImage( item.face, width: 48, @@ -92,6 +131,12 @@ class FollowUserPage extends GetView { ), ], ), + trailing: IconButton( + onPressed: () { + controller.removeItem(item); + }, + icon: const Icon(Remix.dislike_line), + ), onTap: () { AppNavigator.toLiveRoomDetail(site: site, roomId: item.roomId); }, diff --git a/simple_live_app/pubspec.yaml b/simple_live_app/pubspec.yaml index bf489402..7d6fb232 100644 --- a/simple_live_app/pubspec.yaml +++ b/simple_live_app/pubspec.yaml @@ -45,6 +45,7 @@ dependencies: screen_brightness: ^0.2.2 #亮度控制 auto_orientation: ^2.3.1 #屏幕方向 wakelock: ^0.6.2 #屏幕常亮 + file_picker: ^5.3.3 #文件选择 # 视频播放 media_kit: ^1.1.1 From b4e1b4c7bf0bf5aae0618a750383f2104139d5a2 Mon Sep 17 00:00:00 2001 From: xiaoyaocz Date: Thu, 3 Aug 2023 17:05:47 +0800 Subject: [PATCH 3/3] release 1.2.1 --- assets/app_version.json | 6 +++--- simple_live_app/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/app_version.json b/assets/app_version.json index b1de1b83..0fba996c 100644 --- a/assets/app_version.json +++ b/assets/app_version.json @@ -1,7 +1,7 @@ { - "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", + "version": "1.2.1", + "version_num": 10201, + "version_desc": "1. 播放器增加兼容模式\n2. 修改虎牙直播间标题获取 #48\n3. 修复虎牙直播播放问题 #71\n4. 直播间全屏增加刷新按钮 #42\n5. 修复哔哩哔哩部分直播间无法观看问题 #59\n6. 修复弹幕默认开关设置无效问题 #65\n7. 增加进入直播间自动全屏选项 #41\n8. 增加弹幕关键词屏蔽功能 #70\n9. 增加双击全屏功能 #56\n10. 关注列表支持导入导出 #19", "prerelease":false, "download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases" } \ No newline at end of file diff --git a/simple_live_app/pubspec.yaml b/simple_live_app/pubspec.yaml index 7d6fb232..fbfa13b9 100644 --- a/simple_live_app/pubspec.yaml +++ b/simple_live_app/pubspec.yaml @@ -1,5 +1,5 @@ name: simple_live_app -version: 1.2.0+10200 +version: 1.2.1+10201 publish_to: none description: "Simple Live APP" environment: