mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-10 03:00:13 +08:00
cache live stream pref
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -209,6 +209,7 @@ class LiveRoomController extends GetxController {
|
|||||||
startLiveTimer();
|
startLiveTimer();
|
||||||
isPortrait.value = response.isPortrait ?? false;
|
isPortrait.value = response.isPortrait ?? false;
|
||||||
stream = playurl.stream;
|
stream = playurl.stream;
|
||||||
|
_initStreamIndex();
|
||||||
await initLiveUrl(
|
await initLiveUrl(
|
||||||
streamIndex: streamIndex,
|
streamIndex: streamIndex,
|
||||||
formatIndex: formatIndex,
|
formatIndex: formatIndex,
|
||||||
@@ -227,6 +228,32 @@ class LiveRoomController extends GetxController {
|
|||||||
int codecIndex = 0;
|
int codecIndex = 0;
|
||||||
int liveUrlIndex = 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({
|
Future<void>? initLiveUrl({
|
||||||
int streamIndex = 0,
|
int streamIndex = 0,
|
||||||
int formatIndex = 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/size_ext.dart';
|
||||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||||
import 'package:PiliPlus/utils/platform_utils.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:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -432,6 +434,14 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
|||||||
codecIndex: codec.$1,
|
codecIndex: codec.$1,
|
||||||
liveUrlIndex: url.$1,
|
liveUrlIndex: url.$1,
|
||||||
);
|
);
|
||||||
|
GStorage.setting.put(
|
||||||
|
SettingBoxKey.liveStream,
|
||||||
|
[
|
||||||
|
stream.$2.protocolName,
|
||||||
|
format.$2.formatName,
|
||||||
|
codec.$2.codecName,
|
||||||
|
],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ abstract final class SettingBoxKey {
|
|||||||
touchSlopH = 'touchSlopH',
|
touchSlopH = 'touchSlopH',
|
||||||
floatingNavBar = 'floatingNavBar',
|
floatingNavBar = 'floatingNavBar',
|
||||||
removeSafeArea = 'removeSafeArea',
|
removeSafeArea = 'removeSafeArea',
|
||||||
angleDegrees = 'angleDegrees';
|
angleDegrees = 'angleDegrees',
|
||||||
|
liveStream = 'liveStream';
|
||||||
|
|
||||||
static const String minimizeOnExit = 'minimizeOnExit',
|
static const String minimizeOnExit = 'minimizeOnExit',
|
||||||
windowSize = 'windowSize',
|
windowSize = 'windowSize',
|
||||||
|
|||||||
@@ -1014,4 +1014,6 @@ abstract final class Pref {
|
|||||||
|
|
||||||
static double get maxVolume => // desktop
|
static double get maxVolume => // desktop
|
||||||
_setting.get(SettingBoxKey.maxVolume, defaultValue: 2.0);
|
_setting.get(SettingBoxKey.maxVolume, defaultValue: 2.0);
|
||||||
|
|
||||||
|
static List? get liveStream => _setting.get(SettingBoxKey.liveStream);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user