mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-18 00:10:13 +08:00
cache live stream pref
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -198,6 +198,7 @@ class LiveRoomController extends GetxController {
|
||||
startLiveTimer();
|
||||
isPortrait.value = response.isPortrait ?? false;
|
||||
stream = playurl.stream;
|
||||
_initStreamIndex();
|
||||
await initLiveUrl(
|
||||
streamIndex: streamIndex,
|
||||
formatIndex: formatIndex,
|
||||
@@ -216,6 +217,32 @@ class LiveRoomController extends GetxController {
|
||||
int codecIndex = 0;
|
||||
int liveUrlIndex = 0;
|
||||
|
||||
void _initStreamIndex() {
|
||||
final pref = Pref.liveStream;
|
||||
if (pref != null) {
|
||||
try {
|
||||
final protocolName = pref[0];
|
||||
final formatName = pref[1];
|
||||
final codecName = pref[2];
|
||||
for (var i in stream.indexed) {
|
||||
if (i.$2.protocolName == protocolName) {
|
||||
streamIndex = i.$1;
|
||||
for (var j in i.$2.format.indexed) {
|
||||
if (j.$2.formatName == formatName) {
|
||||
formatIndex = j.$1;
|
||||
for (var k in j.$2.codec.indexed) {
|
||||
if (k.$2.codecName == codecName) {
|
||||
codecIndex = k.$1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void>? initLiveUrl({
|
||||
int streamIndex = 0,
|
||||
int formatIndex = 0,
|
||||
|
||||
@@ -18,6 +18,8 @@ import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -432,6 +434,14 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
||||
codecIndex: codec.$1,
|
||||
liveUrlIndex: url.$1,
|
||||
);
|
||||
GStorage.setting.put(
|
||||
SettingBoxKey.liveStream,
|
||||
[
|
||||
stream.$2.protocolName,
|
||||
format.$2.formatName,
|
||||
codec.$2.codecName,
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
|
||||
@@ -57,7 +57,8 @@ abstract final class SettingBoxKey {
|
||||
enableImgMenu = 'enableImgMenu',
|
||||
touchSlopH = 'touchSlopH',
|
||||
floatingNavBar = 'floatingNavBar',
|
||||
angleDegrees = 'angleDegrees';
|
||||
angleDegrees = 'angleDegrees',
|
||||
liveStream = 'liveStream';
|
||||
|
||||
static const String windowSize = 'windowSize',
|
||||
windowPosition = 'windowPosition',
|
||||
|
||||
@@ -553,4 +553,6 @@ abstract final class Pref {
|
||||
|
||||
static double get maxVolume => // desktop
|
||||
_setting.get(SettingBoxKey.maxVolume, defaultValue: 2.0);
|
||||
|
||||
static List? get liveStream => _setting.get(SettingBoxKey.liveStream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user