mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-19 05:06:21 +02:00
feat: Implement TV recording management with API endpoints, a data model, and a scheduling service that uses FFmpeg to record streams.
This commit is contained in:
1 parent
33c6385d7e
commit
13647a35da
6 files changed
+70
-347
No files matched your search
@@ -3,8 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../../features/iptv/screens/player_screen.dart';
|
||||
export '../../../../features/iptv/screens/player_screen.dart' show StreamType;
|
||||
import '../../../../core/models/playlist_config.dart';
|
||||
import '../../../../features/iptv/widgets/lite_player_view.dart';
|
||||
import '../../../../features/iptv/providers/xtream_provider.dart';
|
||||
|
||||
class MobilePlayerScreen extends ConsumerWidget {
|
||||
final String streamId;
|
||||
@@ -12,7 +10,8 @@ class MobilePlayerScreen extends ConsumerWidget {
|
||||
final StreamType streamType;
|
||||
final String containerExtension;
|
||||
final PlaylistConfig playlist;
|
||||
final List<dynamic>? channels; // New: List of channels for zapping
|
||||
final List<dynamic>? channels;
|
||||
final double? startTime;
|
||||
|
||||
const MobilePlayerScreen({
|
||||
super.key,
|
||||
@@ -22,100 +21,22 @@ class MobilePlayerScreen extends ConsumerWidget {
|
||||
this.streamType = StreamType.live,
|
||||
this.containerExtension = 'mp4',
|
||||
this.channels,
|
||||
this.startTime,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final service = ref.read(xtreamServiceProvider(playlist));
|
||||
String streamUrl = '';
|
||||
|
||||
if (streamType == StreamType.live) {
|
||||
streamUrl = service.getLiveStreamUrl(streamId);
|
||||
} else if (streamType == StreamType.vod) {
|
||||
streamUrl = service.getVodStreamUrl(streamId, containerExtension);
|
||||
} else if (streamType == StreamType.series) {
|
||||
streamUrl = service.getSeriesStreamUrl(streamId, containerExtension);
|
||||
}
|
||||
|
||||
// Zapping logic
|
||||
VoidCallback? onNext;
|
||||
VoidCallback? onPrevious;
|
||||
|
||||
if (channels != null && channels!.isNotEmpty) {
|
||||
final currentIndex = channels!.indexWhere((c) {
|
||||
try {
|
||||
// Supports Channel/Movie (.streamId) and Episode (.id)
|
||||
final cId = (c.streamId ?? c.id).toString();
|
||||
return cId == streamId;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (currentIndex != -1) {
|
||||
void navigateTo(int index) {
|
||||
final item = channels![index % channels!.length];
|
||||
String nId = '';
|
||||
String nTitle = '';
|
||||
String nExt = containerExtension;
|
||||
|
||||
try {
|
||||
// ID Extraction
|
||||
nId = (item.streamId ?? item.id).toString();
|
||||
// Title Extraction (name for channels/movies, title for episodes)
|
||||
nTitle = item.name ?? item.title ?? 'Unknown';
|
||||
|
||||
// Format series title predictably
|
||||
if (streamType == StreamType.series && title.contains(' - ')) {
|
||||
final prefix = title.split(' - ').first;
|
||||
nTitle = '$prefix - Episode ${item.episodeNum ?? ""}';
|
||||
}
|
||||
|
||||
nExt = item.containerExtension ?? containerExtension;
|
||||
} catch (_) {}
|
||||
|
||||
if (nId.isEmpty) return;
|
||||
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MobilePlayerScreen(
|
||||
streamId: nId,
|
||||
title: nTitle,
|
||||
playlist: playlist,
|
||||
streamType: streamType,
|
||||
containerExtension: nExt,
|
||||
channels: channels,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onNext = () => navigateTo(currentIndex + 1);
|
||||
onPrevious = () => navigateTo(currentIndex - 1 + channels!.length);
|
||||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
title: Text(title,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16)),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
body: SizedBox.expand(
|
||||
child: LitePlayerView(
|
||||
streamUrl: streamUrl,
|
||||
isLive: streamType == StreamType.live,
|
||||
onNext: onNext,
|
||||
onPrevious: onPrevious,
|
||||
),
|
||||
),
|
||||
// Use the premium PlayerScreen which handles IFrames and custom overlays
|
||||
// This removes the redundant AppBar and fixes full-screen/controls issues
|
||||
return PlayerScreen(
|
||||
key: ValueKey('player-$streamId'),
|
||||
streamId: streamId,
|
||||
title: title,
|
||||
playlist: playlist,
|
||||
streamType: streamType,
|
||||
containerExtension: containerExtension,
|
||||
channels: channels,
|
||||
startTime: startTime,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user