Skip to content

Commit

Permalink
Merge pull request #346 from xiaoyaocz/dev
Browse files Browse the repository at this point in the history
Release 1.5.3 / TV 1.0.3
  • Loading branch information
xiaoyaocz authored Mar 13, 2024
2 parents 55335a0 + f5741af commit b53e81a
Show file tree
Hide file tree
Showing 13 changed files with 632 additions and 509 deletions.
4 changes: 2 additions & 2 deletions assets/app_version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.5.2",
"version_num": 10502,
"version": "1.5.3",
"version_num": 10503,
"version_desc": "- 修复虎牙播放中断问题 #339 @lemonfog\n- 支持多端数据同步\n- Linux使用mimalloc防止内存泄漏 #328 @madoka773",
"prerelease":false,
"download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases"
Expand Down
4 changes: 2 additions & 2 deletions assets/tv_app_version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0.2",
"version_num": 10002,
"version": "1.0.3",
"version_num": 10003,
"version_desc": "- 修复虎牙播放中断问题\n- 优化使用体验",
"prerelease":false,
"download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases"
Expand Down
3 changes: 2 additions & 1 deletion simple_live_app/lib/modules/sync/sync_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class SyncController extends BaseController {
var addressList = (result as String).split(";");
if (addressList.length >= 2) {
//弹窗选择
showPickerAddress(addressList);
} else {
addressController.text = result;
//connect();
Expand Down Expand Up @@ -113,7 +114,7 @@ class SyncController extends BaseController {
version: QrVersions.auto,
backgroundColor: Colors.white,
padding: AppStyle.edgeInsetsA12,
size: 240,
size: 200,
),
),
),
Expand Down
39 changes: 24 additions & 15 deletions simple_live_app/lib/services/sync_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SyncService extends GetxService {
return;
}
//处理Hello的广播
if (data["type"] == "Hello SimpleLive") {
if (data["type"] == "hello") {
//如果http服务已经启动,就回复自己的信息
if (httpRunning.value) {
sendInfo();
Expand Down Expand Up @@ -156,24 +156,33 @@ class SyncService extends GetxService {
/// - 如果是wifi,直接获取wifi的IP
/// - 如果是有线,获取所有的IP,找到全部的IP
Future<String> getLocalIP() async {
var ip = await networkInfo.getWifiIP();
if (ip == null || ip.isEmpty) {
var interfaces = await NetworkInterface.list();
var ipList = <String>[];
for (var interface in interfaces) {
for (var addr in interface.addresses) {
if (addr.type.name == 'IPv4' &&
!addr.address.startsWith('127') &&
!addr.isMulticast &&
!addr.isLoopback) {
ipList.add(addr.address);
break;
String? ip = "";
try {
ip = await networkInfo.getWifiIP();
} catch (e) {
Log.logPrint(e);
}
try {
if (ip == null || ip.isEmpty) {
var interfaces = await NetworkInterface.list();
var ipList = <String>[];
for (var interface in interfaces) {
for (var addr in interface.addresses) {
if (addr.type.name == 'IPv4' &&
!addr.address.startsWith('127') &&
!addr.isMulticast &&
!addr.isLoopback) {
ipList.add(addr.address);
break;
}
}
}
ip = ipList.join(';');
}
ip = ipList.join(';');
} catch (e) {
Log.logPrint(e);
}
return ip;
return ip ?? "";
}

/// 初始化HTTP服务
Expand Down
2 changes: 1 addition & 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.5.2+10502
version: 1.5.3+10503
publish_to: none
description: "Simple Live APP"
environment:
Expand Down
2 changes: 1 addition & 1 deletion simple_live_core/lib/src/huya_site.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class HuyaSite implements LiveSite {
var query = Uri.splitQueryString(anticode);

query["t"] = "102";
query["ctype"] = "huya_live";
query["ctype"] = "tars_mp";

final wsTime = (DateTime.now().millisecondsSinceEpoch ~/ 1000 + 21600)
.toRadixString(16);
Expand Down
25 changes: 5 additions & 20 deletions simple_live_tv_app/lib/app/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,27 +204,12 @@ class Utils {
useSystem: useSystem,
maskColor: Colors.transparent,
animationTime: const Duration(milliseconds: 200),
builder: (context) => KeyboardListener(
focusNode: FocusNode(),
//autofocus: true,
onKeyEvent: (e) {
if (e is KeyDownEvent) {
return;
}
if (e.logicalKey == LogicalKeyboardKey.escape ||
e.logicalKey == LogicalKeyboardKey.goBack ||
e.logicalKey == LogicalKeyboardKey.backspace) {
hideRightDialog();
}
},
child: Container(
width: width + MediaQuery.of(context).padding.right,
padding: EdgeInsets.only(right: MediaQuery.of(context).padding.right),
decoration: BoxDecoration(
color: Get.theme.cardColor,
),
child: child,
builder: (context) => Container(
width: width,
decoration: BoxDecoration(
color: Get.theme.cardColor,
),
child: child,
),
);
}
Expand Down
115 changes: 74 additions & 41 deletions simple_live_tv_app/lib/modules/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:get/get.dart';
Expand Down Expand Up @@ -133,13 +134,13 @@ class HomePage extends GetView<HomeController> {
height: 64.w,
child: Center(
child: Icon(
Icons.live_tv,
Icons.favorite_border,
color: Colors.white,
size: 40.w,
size: 56.w,
),
),
),
AppStyle.hGap16,
AppStyle.hGap24,
Expanded(
child: Text(
"我的关注",
Expand Down Expand Up @@ -254,48 +255,80 @@ class HomePage extends GetView<HomeController> {
Utils.showRightDialog(
useSystem: true,
width: 700.w,
child: Stack(
child: Column(
children: [
Obx(
() => ListView.separated(
itemCount: FollowUserService.instance.list.length,
separatorBuilder: (_, __) => AppStyle.vGap24,
padding: AppStyle.edgeInsetsA40,
itemBuilder: (_, i) {
var item = FollowUserService.instance.list[i];
var foucsNode = AppFocusNode();
return HighlightListTile(
autofocus: i == 0,
leading: NetImage(
item.face,
width: 64.w,
height: 64.w,
borderRadius: 64.w,
AppStyle.vGap24,
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AppStyle.hGap48,
HighlightButton(
focusNode: AppFocusNode(),
iconData: Icons.arrow_back,
text: "返回",
onTap: () {
Utils.hideRightDialog();
},
),
AppStyle.hGap32,
Text(
"关注管理",
style: AppStyle.titleStyleWhite.copyWith(
fontSize: 36.w,
fontWeight: FontWeight.bold,
),
),
AppStyle.hGap24,
const Spacer(),
],
),
Expanded(
child: Stack(
children: [
Obx(
() => ListView.separated(
itemCount: FollowUserService.instance.list.length,
separatorBuilder: (_, __) => AppStyle.vGap24,
padding: AppStyle.edgeInsetsA40,
itemBuilder: (_, i) {
var item = FollowUserService.instance.list[i];
var foucsNode = AppFocusNode();
return HighlightListTile(
autofocus: i == 0,
leading: NetImage(
item.face,
width: 64.w,
height: 64.w,
borderRadius: 64.w,
),
title: item.userName,
focusNode: foucsNode,
trailing: Obx(
() => Icon(
Icons.delete_outline_outlined,
size: 40.w,
color: foucsNode.isFoucsed.value
? Colors.black
: Colors.white,
),
),
onTap: () {
FollowUserService.instance
.removeItem(item, refresh: false);
},
);
},
),
title: item.userName,
focusNode: foucsNode,
trailing: Obx(
() => Icon(
Icons.delete_outline_outlined,
size: 40.w,
color: foucsNode.isFoucsed.value
? Colors.black
: Colors.white,
),
Obx(
() => Visibility(
visible: FollowUserService.instance.list.isEmpty,
child: const AppEmptyWidget(
text: "关注列表为空,快去关注一些主播吧",
),
),
onTap: () {
FollowUserService.instance.removeItem(item, refresh: false);
},
);
},
),
),
Obx(
() => Visibility(
visible: FollowUserService.instance.list.isEmpty,
child: const AppEmptyWidget(
text: "关注列表为空,快去关注一些主播吧",
),
),
],
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver {
});
}

/// 双击退出Flag
bool doubleClickExit = false;

/// 双击退出Timer
Timer? doubleClickTimer;

@override
void onInit() {
initTimer();
Expand Down
49 changes: 37 additions & 12 deletions simple_live_tv_app/lib/modules/live_room/live_room_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:simple_live_tv_app/app/app_style.dart';
Expand All @@ -13,14 +16,33 @@ class LiveRoomPage extends GetView<LiveRoomController> {

@override
Widget build(BuildContext context) {
return KeyboardListener(
focusNode: controller.focusNode,
autofocus: true,
onKeyEvent: onKeyEvent,
child: Scaffold(
backgroundColor: Colors.black,
body: Obx(
() => buildMediaPlayer(),
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (!didPop) {
//双击返回键退出
if (controller.doubleClickExit) {
controller.doubleClickTimer?.cancel();
Get.back();
return;
}
controller.doubleClickExit = true;
SmartDialog.showToast("再按一次退出播放器");
controller.doubleClickTimer = Timer(const Duration(seconds: 2), () {
controller.doubleClickExit = false;
controller.doubleClickTimer!.cancel();
});
}
},
child: KeyboardListener(
focusNode: controller.focusNode,
autofocus: true,
onKeyEvent: onKeyEvent,
child: Scaffold(
backgroundColor: Colors.black,
body: Obx(
() => buildMediaPlayer(),
),
),
),
);
Expand All @@ -31,10 +53,13 @@ class LiveRoomPage extends GetView<LiveRoomController> {
return;
}
Log.logPrint(key);
if (key.logicalKey == LogicalKeyboardKey.escape) {
Get.back();
return;
}

// if (key.logicalKey == LogicalKeyboardKey.escape ||
// key.logicalKey == LogicalKeyboardKey.backspace ||
// key.logicalKey == LogicalKeyboardKey.goBack) {
// // Get.back();
// return;
// }
// 点击OK、Enter、Select键时显示/隐藏控制器
if (key.logicalKey == LogicalKeyboardKey.select ||
key.logicalKey == LogicalKeyboardKey.enter ||
Expand Down
Loading

0 comments on commit b53e81a

Please sign in to comment.