Skip to content

Commit

Permalink
Merge pull request #75 from xiaoyaocz/dev
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
xiaoyaocz authored Aug 3, 2023
2 parents 442bf33 + b4e1b4c commit cd07f1b
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 6 deletions.
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.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"
}
9 changes: 9 additions & 0 deletions simple_live_app/lib/models/db/follow_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ class FollowUser {
/// 直播状态
/// 0=未知(加载中) 1=未开播 2=直播中
Rx<int> liveStatus = 0.obs;

factory FollowUser.fromJson(Map<String, dynamic> json) => FollowUser(
id: json['id'],
roomId: json['roomId'],
siteId: json['siteId'],
userName: json['userName'],
face: json['face'],
addTime: DateTime.parse(json['addTime']),
);
}
19 changes: 17 additions & 2 deletions simple_live_app/lib/modules/live_room/live_room_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class LiveRoomController extends BaseController {
/// 显示播放控制
Rx<bool> showControls = true.obs;

Timer? hideControlsTimer;

@override
void onInit() {
initAutoExit();
Expand Down Expand Up @@ -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;
});
}

/// 弹幕控制器初始化,初始化一些选项
Expand Down Expand Up @@ -317,7 +328,7 @@ class LiveRoomController extends BaseController {
setPlayer();
}

void setPlayer() {
void setPlayer() async {
currentUrlInfo.value = "线路${currentUrl + 1}";
Map<String, String> headers = {};
if (site.id == "bilibili") {
Expand All @@ -333,6 +344,7 @@ class LiveRoomController extends BaseController {
httpHeaders: headers,
),
);

Log.d("播放链接\r\n:${playUrls[currentUrl]}");
}

Expand All @@ -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)}');
Expand All @@ -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();
Expand Down
2 changes: 2 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 @@ -186,6 +186,7 @@ class LiveRoomPage extends GetView<LiveRoomController> {
Positioned.fill(
child: GestureDetector(
onTap: () {
controller.hideControlsTimer?.cancel();
controller.showControls.value = !controller.showControls.value;
},
onDoubleTap: () {
Expand Down Expand Up @@ -369,6 +370,7 @@ class LiveRoomPage extends GetView<LiveRoomController> {
Positioned.fill(
child: GestureDetector(
onTap: () {
controller.hideControlsTimer?.cancel();
controller.showControls.value = !controller.showControls.value;
controller.showLines.value = false;
controller.showQualites.value = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -57,4 +61,62 @@ class FollowUserController extends BasePageController<FollowUser> {
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();
}
}
}
45 changes: 45 additions & 0 deletions simple_live_app/lib/modules/user/follow_user/follow_user_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,6 +19,43 @@ class FollowUserPage extends GetView<FollowUserController> {
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,
Expand All @@ -28,6 +66,7 @@ class FollowUserPage extends GetView<FollowUserController> {
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,
Expand Down Expand Up @@ -92,6 +131,12 @@ class FollowUserPage extends GetView<FollowUserController> {
),
],
),
trailing: IconButton(
onPressed: () {
controller.removeItem(item);
},
icon: const Icon(Remix.dislike_line),
),
onTap: () {
AppNavigator.toLiveRoomDetail(site: site, roomId: item.roomId);
},
Expand Down
3 changes: 2 additions & 1 deletion simple_live_app/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cd07f1b

Please sign in to comment.