Skip to content

Commit

Permalink
Merge pull request #556 from xiaoyaocz/dev
Browse files Browse the repository at this point in the history
Release 1.7.4 / TV 1.2.0
  • Loading branch information
xiaoyaocz authored Nov 29, 2024
2 parents b12df3c + 931e72d commit 4359b30
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 88 deletions.
9 changes: 9 additions & 0 deletions simple_live_app/lib/app/app_style.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
Expand All @@ -20,6 +22,7 @@ class AppStyle {
static ThemeData lightTheme = ThemeData(
colorScheme: AppColors.lightColorScheme,
useMaterial3: true,
fontFamily: Platform.isWindows ? "Microsoft YaHei" : null,
visualDensity: VisualDensity.standard,
appBarTheme: AppBarTheme(
//elevation: 0,
Expand Down Expand Up @@ -59,6 +62,12 @@ class AppStyle {
static ThemeData darkTheme = ThemeData.dark().copyWith(
colorScheme: AppColors.darkColorScheme,
visualDensity: VisualDensity.standard,
textTheme: ThemeData.dark().textTheme.apply(
fontFamily: Platform.isWindows ? "Microsoft YaHei" : null,
),
primaryTextTheme: ThemeData().textTheme.apply(
fontFamily: Platform.isWindows ? "Microsoft YaHei" : null,
),
appBarTheme: AppBarTheme(
//elevation: 0,

Expand Down
10 changes: 10 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 @@ -77,6 +77,9 @@ class AppSettingsController extends GetxController {
playerAutoPause.value = LocalStorageService.instance
.getValue(LocalStorageService.kPlayerAutoPause, false);

playerForceHttps.value = LocalStorageService.instance
.getValue(LocalStorageService.kPlayerForceHttps, false);

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

Expand Down Expand Up @@ -499,4 +502,11 @@ class AppSettingsController extends GetxController {
LocalStorageService.instance
.setValue(LocalStorageService.kUpdateFollowThreadCount, e);
}

var playerForceHttps = false.obs;
void setPlayerForceHttps(bool e) {
playerForceHttps.value = e;
LocalStorageService.instance
.setValue(LocalStorageService.kPlayerForceHttps, e);
}
}
15 changes: 11 additions & 4 deletions simple_live_app/lib/modules/live_room/live_room_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -416,24 +416,30 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver {
};
} else if (site.id == Constant.kHuya) {
headers = {
"referer": "https://www.huya.com",
"referer": "https://m.huya.com",
"user-agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0"
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/130.0.0.0"
};
}

var playurl = playUrls[currentLineIndex];
if (AppSettingsController.instance.playerForceHttps.value) {
playurl = playurl.replaceAll("http://", "https://");
}

player.open(
Media(
playUrls[currentLineIndex],
playurl,
httpHeaders: headers,
),
);

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

@override
void mediaEnd() async {
super.mediaEnd();
if (mediaErrorRetryCount < 2) {
Log.d("播放结束,尝试第${mediaErrorRetryCount + 1}次刷新");
if (mediaErrorRetryCount == 1) {
Expand All @@ -460,6 +466,7 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver {
int mediaErrorRetryCount = 0;
@override
void mediaError(String error) async {
super.mediaEnd();
if (mediaErrorRetryCount < 2) {
Log.d("播放失败,尝试第${mediaErrorRetryCount + 1}次刷新");
if (mediaErrorRetryCount == 1) {
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 @@ -260,6 +260,8 @@ class LiveRoomPage extends GetView<LiveRoomController> {
},
aspectRatio: aspectRatio,
fit: boxFit,
// 自己实现
wakelock: false,
),
Obx(
() => Visibility(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mixin PlayerSystemMixin on PlayerMixin, PlayerStateMixin, PlayerDanmakuMixin {
}

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

// 开始隐藏计时
resetHideControlsTimer();
Expand Down Expand Up @@ -650,6 +650,7 @@ class PlayerController extends BaseController
StreamSubscription? _widthSubscription;
StreamSubscription? _heightSubscription;
StreamSubscription? _logSubscription;
StreamSubscription? _playingSubscription;

void initStream() {
_errorSubscription = player.stream.error.listen((event) {
Expand All @@ -663,6 +664,13 @@ class PlayerController extends BaseController
mediaError(event);
});

_playingSubscription = player.stream.playing.listen((event) {
if (event) {
WakelockPlus.enable();
Log.d("Playing");
}
});

_completedSubscription = player.stream.completed.listen((event) {
if (event) {
mediaEnd();
Expand Down Expand Up @@ -692,11 +700,16 @@ class PlayerController extends BaseController
_heightSubscription?.cancel();
_logSubscription?.cancel();
_pipSubscription?.cancel();
_playingSubscription?.cancel();
}

void mediaEnd() {}
void mediaEnd() {
WakelockPlus.disable();
}

void mediaError(String error) {}
void mediaError(String error) {
WakelockPlus.disable();
}

void showDebugInfo() {
Utils.showBottomSheet(
Expand Down
11 changes: 11 additions & 0 deletions simple_live_app/lib/modules/settings/play_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ class PlaySettingsPage extends GetView<AppSettingsController> {
},
),
),
AppStyle.divider,
Obx(
() => SettingsSwitch(
title: "使用HTTPS链接",
subtitle: "将http链接替换为https",
value: controller.playerForceHttps.value,
onChanged: (e) {
controller.setPlayerForceHttps(e);
},
),
),
],
),
),
Expand Down
3 changes: 3 additions & 0 deletions simple_live_app/lib/services/local_storage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class LocalStorageService extends GetxService {
/// 播放器缓冲区大小
static const String kPlayerBufferSize = "PlayerBufferSize";

/// 播放器强制使用HTTPS
static const String kPlayerForceHttps = "PlayerForceHttps";

/// 自动全屏
static const String kAutoFullScreen = "AutoFullScreen";

Expand Down
42 changes: 4 additions & 38 deletions 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.7.3+10703
version: 1.7.4+10704
publish_to: none
description: "Simple Live APP"
environment:
Expand Down Expand Up @@ -65,50 +65,16 @@ dependencies:
signalr_netcore: ^1.3.9 #SignalR

# 视频播放
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./libs/universal/media_kit_libs_video
media_kit: ^1.1.11
media_kit_video: ^1.2.5
media_kit_libs_video: ^1.0.5

flutter:
sdk: flutter
flutter_localizations:
sdk: flutter


dependency_overrides:
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./libs/universal/media_kit_libs_video
media_kit_native_event_loop:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit_native_event_loop

dev_dependencies:
flutter_lints: ^2.0.0
build_runner: ^2.3.3
Expand Down
18 changes: 11 additions & 7 deletions simple_live_core/lib/src/huya_site.dart
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ class HuyaSite implements LiveSite {
// 通过ChatGPT转换的Dart代码
var query = Uri.splitQueryString(anticode);

query["t"] = "102";
query["ctype"] = "tars_mp";
query["t"] = "103";
query["ctype"] = "tars_mobile";

final wsTime = (DateTime.now().millisecondsSinceEpoch ~/ 1000 + 21600)
.toRadixString(16);
Expand All @@ -508,14 +508,18 @@ class HuyaSite implements LiveSite {
"ctype": query["ctype"]!,
"ver": "1",
"fs": query["fs"]!,
"sphdcdn": query["sphdcdn"] ?? "",
"sphdDC": query["sphdDC"] ?? "",
"sphd": query["sphd"] ?? "",
"exsphd": query["exsphd"] ?? "",
// "sphdcdn": query["sphdcdn"] ?? "",
// "sphdDC": query["sphdDC"] ?? "",
// "sphd": query["sphd"] ?? "",
// "exsphd": query["exsphd"] ?? "",
"dMod": "mseh-0",
"sdkPcdn": "1_1",
"uid": uid,
"uuid": getUUid(),
"t": query["t"]!,
"sv": "2401310322"
"sv": "202411221719",
"sdk_sid": "1732862566708",
"a_block": "0"
}).query;
}

Expand Down
40 changes: 4 additions & 36 deletions simple_live_tv_app/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: simple_live_tv_app
description: A new Flutter project.
publish_to: 'none'
version: 1.1.9+10109
version: 1.2.0+10200

environment:
sdk: '>=3.1.2 <4.0.0'
Expand Down Expand Up @@ -50,45 +50,13 @@ dependencies:
wakelock_plus: ^1.2.5 #屏幕常亮,media_kit中自带,但似乎不生效

# 视频播放
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./libs/universal/media_kit_libs_video
media_kit: ^1.1.11
media_kit_video: ^1.2.5
media_kit_libs_video: ^1.0.5

dependency_overrides:
fading_edge_scrollview: ^4.1.1
wakelock_plus: ^1.2.5
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./libs/universal/media_kit_libs_video
media_kit_native_event_loop:
git:
url: https://github.com/media-kit/media-kit.git
ref: main
path: ./media_kit_native_event_loop

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 4359b30

Please sign in to comment.