-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d3d309
commit 2c5eeaa
Showing
47 changed files
with
1,993 additions
and
869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
// 使用 IntelliSense 了解相关属性。 | ||
// 悬停以查看现有属性的描述。 | ||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "my_tv", | ||
"request": "launch", | ||
"type": "dart" | ||
}, | ||
{ | ||
"name": "my_tv (profile mode)", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "profile" | ||
}, | ||
{ | ||
"name": "my_tv (release mode)", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "release" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#Sun Mar 31 18:39:28 CST 2024 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library enums; | ||
|
||
export 'iptv_settings.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:my_tv/common/index.dart'; | ||
|
||
/// 直播设置 | ||
enum IPTVSetting { | ||
/// 初始直播源序号 | ||
initialIPTVIdx, | ||
|
||
/// 换台反转 | ||
channelChangeFlip, | ||
|
||
/// 直播源类型 | ||
iptvType, | ||
|
||
/// 直播源缓存时间 | ||
iptvCacheTime, | ||
} | ||
|
||
/// 直播源类型 | ||
enum IPTVSettingIPTVType { | ||
/// 完整 | ||
full, | ||
|
||
/// 精简 | ||
simple, | ||
} | ||
|
||
extension IPTVSettingIPTVTypeExtension on IPTVSettingIPTVType { | ||
String get name { | ||
switch (this) { | ||
case IPTVSettingIPTVType.full: | ||
return '完整'; | ||
case IPTVSettingIPTVType.simple: | ||
return '精简'; | ||
} | ||
} | ||
} | ||
|
||
/// 直播设置 | ||
class IPTVSettings { | ||
static int get initialIPTVIdx => Global.prefs.getInt(IPTVSetting.initialIPTVIdx.toString()) ?? 0; | ||
static set initialIPTVIdx(int value) => Global.prefs.setInt(IPTVSetting.initialIPTVIdx.toString(), value); | ||
|
||
static bool get channelChangeFlip => Global.prefs.getBool(IPTVSetting.channelChangeFlip.toString()) ?? false; | ||
static set channelChangeFlip(bool value) => Global.prefs.setBool(IPTVSetting.channelChangeFlip.toString(), value); | ||
|
||
static IPTVSettingIPTVType get iptvType => | ||
IPTVSettingIPTVType.values[Global.prefs.getInt(IPTVSetting.iptvType.toString()) ?? 0]; | ||
static set iptvType(IPTVSettingIPTVType value) => Global.prefs.setInt(IPTVSetting.iptvType.toString(), value.index); | ||
|
||
static int get iptvCacheTime => Global.prefs.getInt(IPTVSetting.iptvCacheTime.toString()) ?? 0; | ||
static set iptvCacheTime(int value) => Global.prefs.setInt(IPTVSetting.iptvCacheTime.toString(), value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library stores; | ||
|
||
export './iptv.dart'; | ||
export './player.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:mobx/mobx.dart'; | ||
import 'package:my_tv/common/index.dart'; | ||
|
||
part 'iptv.g.dart'; | ||
|
||
class IPTVStore = IPTVStoreBase with _$IPTVStore; | ||
|
||
abstract class IPTVStoreBase with Store { | ||
/// 直播源分组列表 | ||
@observable | ||
List<IPTVGroup> iptvGroupList = []; | ||
|
||
/// 直播源列表 | ||
@observable | ||
List<IPTV> iptvList = []; | ||
|
||
/// 当前直播源 | ||
@observable | ||
IPTV currentIPTV = IPTV(idx: 0, channel: 0, groupIdx: 0, name: '', url: ''); | ||
|
||
/// 显示iptv信息 | ||
@observable | ||
bool iptvInfoVisible = false; | ||
|
||
/// 选台频道号 | ||
@observable | ||
String channelNo = ''; | ||
|
||
/// 确认选台定时器 | ||
Timer? confirmChannelTimer; | ||
|
||
/// 获取上一个直播源 | ||
IPTV getPrevIPTV({IPTV? iptv}) { | ||
final prevIdx = iptvList.indexOf(iptv ?? currentIPTV) - 1; | ||
return prevIdx < 0 ? iptvList.last : iptvList.elementAt(prevIdx); | ||
} | ||
|
||
/// 获取下一个直播源 | ||
IPTV getNextIPTV({IPTV? iptv}) { | ||
final nextIdx = iptvList.indexOf(iptv ?? currentIPTV) + 1; | ||
return nextIdx >= iptvList.length ? iptvList.first : iptvList.elementAt(nextIdx); | ||
} | ||
|
||
/// 获取上一个分组直播源 | ||
IPTV getPrevGroupIPTV({IPTV? iptv}) { | ||
final prevIdx = (iptv?.groupIdx ?? currentIPTV.groupIdx) - 1; | ||
return prevIdx < 0 ? iptvGroupList.last.list.first : iptvGroupList.elementAt(prevIdx).list.first; | ||
} | ||
|
||
/// 获取下一个分组直播源 | ||
IPTV getNextGroupIPTV({IPTV? iptv}) { | ||
final nextIdx = (iptv?.groupIdx ?? currentIPTV.groupIdx) + 1; | ||
return nextIdx >= iptvGroupList.length | ||
? iptvGroupList.first.list.first | ||
: iptvGroupList.elementAt(nextIdx).list.first; | ||
} | ||
|
||
/// 刷新直播源列表 | ||
@action | ||
Future<void> refreshIPTVList() async { | ||
iptvGroupList = IPTVUtil.parseFromM3u(await IPTVUtil.fetchM3u()); | ||
iptvList = iptvGroupList.expand((e) => e.list).toList(); | ||
} | ||
|
||
void inputChannelNo(String no) { | ||
confirmChannelTimer?.cancel(); | ||
|
||
channelNo += no; | ||
confirmChannelTimer = Timer(Duration(seconds: 4 - channelNo.length), () { | ||
final channel = int.tryParse(channelNo) ?? 0; | ||
final iptv = iptvList.firstWhere((e) => e.channel == channel, orElse: () => currentIPTV); | ||
currentIPTV = iptv; | ||
channelNo = ''; | ||
}); | ||
} | ||
} |
Oops, something went wrong.