mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-19 21:18:06 +02:00
feat: Implement streaming handlers for live MPEG-TS proxy and VOD HLS transcoding via FFmpeg, and add a release build script.
This commit is contained in:
1 parent
c7ba52b88d
commit
8128174ac3
26 files changed
+1529
-927
No files matched your search
@@ -31,7 +31,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
Icons.live_tv_rounded,
|
||||
Icons.movie_rounded,
|
||||
Icons.tv_rounded,
|
||||
Icons.settings_rounded
|
||||
Icons.settings_rounded,
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
@@ -58,7 +58,7 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
bool _isInitialized = false;
|
||||
bool _isLoading = true;
|
||||
StreamSubscription? _messageSubscription;
|
||||
String _aspectRatio = 'contain';
|
||||
final String _aspectRatio = 'contain';
|
||||
bool _isSeeking = false;
|
||||
String _viewId = 'iptv-player';
|
||||
String? _currentStreamUrl;
|
||||
@@ -70,7 +70,8 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.channels != null) {
|
||||
_currentIndex = widget.channels!.indexWhere((c) => c.streamId == widget.streamId);
|
||||
_currentIndex =
|
||||
widget.channels!.indexWhere((c) => c.streamId == widget.streamId);
|
||||
if (_currentIndex == -1) _currentIndex = 0;
|
||||
}
|
||||
// Show controls at start, then auto-hide after timeout
|
||||
@@ -87,7 +88,8 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _initializePlayer({double? startTimeOverride, bool isChannelSwitch = false}) async {
|
||||
Future<void> _initializePlayer(
|
||||
{double? startTimeOverride, bool isChannelSwitch = false}) async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_statusMessage = 'Loading...';
|
||||
@@ -96,12 +98,12 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
try {
|
||||
// Determine Stream ID (Initial or Current Index)
|
||||
final currentStreamId = isChannelSwitch && widget.channels != null
|
||||
? widget.channels![_currentIndex].streamId
|
||||
? widget.channels![_currentIndex].streamId
|
||||
: widget.streamId;
|
||||
|
||||
_viewId = 'iptv-player-$currentStreamId-${DateTime.now().millisecondsSinceEpoch}';
|
||||
|
||||
|
||||
_viewId =
|
||||
'iptv-player-$currentStreamId-${DateTime.now().millisecondsSinceEpoch}';
|
||||
|
||||
final service = ref.read(xtreamServiceProvider(widget.playlist));
|
||||
String streamUrl = '';
|
||||
|
||||
@@ -110,34 +112,37 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
if (widget.streamType == StreamType.live) {
|
||||
streamUrl = service.getLiveStreamUrl(currentStreamId);
|
||||
} else if (widget.streamType == StreamType.vod) {
|
||||
streamUrl = service.getVodStreamUrl(currentStreamId, widget.containerExtension);
|
||||
streamUrl =
|
||||
service.getVodStreamUrl(currentStreamId, widget.containerExtension);
|
||||
} else if (widget.streamType == StreamType.series) {
|
||||
streamUrl = service.getSeriesStreamUrl(currentStreamId, widget.containerExtension);
|
||||
streamUrl = service.getSeriesStreamUrl(
|
||||
currentStreamId, widget.containerExtension);
|
||||
}
|
||||
|
||||
// Store URL for Lite Player
|
||||
_currentStreamUrl = streamUrl;
|
||||
|
||||
final encodedUrl = Uri.encodeComponent(streamUrl);
|
||||
final streamTypeParam = widget.streamType == StreamType.live ? 'live' : 'vod';
|
||||
|
||||
final streamTypeParam =
|
||||
widget.streamType == StreamType.live ? 'live' : 'vod';
|
||||
|
||||
// Force player choice based on stream type:
|
||||
// - Live TV: Player Lite (simple TS playback with mpegts.js)
|
||||
// - VOD/Series: Player Standard (fuller controls, HLS support)
|
||||
final isLiveTV = widget.streamType == StreamType.live;
|
||||
// Cache buster to force reload of updated player.html
|
||||
final cacheBuster = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
var playerSrc = isLiveTV
|
||||
? 'player_lite.html?url=$encodedUrl&type=live&v=$cacheBuster'
|
||||
|
||||
var playerSrc = isLiveTV
|
||||
? 'player_lite.html?url=$encodedUrl&type=live&v=$cacheBuster'
|
||||
: 'player.html?url=$encodedUrl&type=vod&v=$cacheBuster';
|
||||
|
||||
|
||||
if (startTimeOverride != null) {
|
||||
playerSrc += '&t=$startTimeOverride';
|
||||
}
|
||||
|
||||
|
||||
if (widget.duration != null) {
|
||||
playerSrc += '&duration=${widget.duration!.inSeconds}';
|
||||
playerSrc += '&duration=${widget.duration!.inSeconds}';
|
||||
}
|
||||
|
||||
// Register View Factory (Only needed for Standard Player, but safe to do always or conditionally)
|
||||
@@ -157,7 +162,7 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
_isInitialized = true;
|
||||
_isLoading = false;
|
||||
});
|
||||
|
||||
|
||||
// Force unmute on load (after a short delay to ensure iframe is ready)
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
if (mounted) {
|
||||
@@ -185,24 +190,23 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
final currentTime = (data['currentTime'] as num).toDouble();
|
||||
final rawDuration = (data['duration'] as num).toDouble();
|
||||
final duration = rawDuration.isFinite ? rawDuration : 0.0;
|
||||
|
||||
|
||||
// Only update position if user is NOT dragging the slider
|
||||
if (!_isSeeking) {
|
||||
setState(() {
|
||||
_currentPosition = currentTime;
|
||||
_totalDuration = duration > 0 ? duration : 1;
|
||||
});
|
||||
}
|
||||
|
||||
// Update watch history if relevant
|
||||
if (currentTime > 0) {
|
||||
ref.read(playbackPositionsProvider.notifier).savePosition(
|
||||
widget.streamId,
|
||||
currentTime,
|
||||
duration
|
||||
);
|
||||
setState(() {
|
||||
_currentPosition = currentTime;
|
||||
_totalDuration = duration > 0 ? duration : 1;
|
||||
});
|
||||
}
|
||||
|
||||
// Update watch history if relevant
|
||||
if (currentTime > 0) {
|
||||
ref.read(playbackPositionsProvider.notifier).savePosition(
|
||||
widget.streamId,
|
||||
currentTime,
|
||||
duration,
|
||||
);
|
||||
}
|
||||
} else if (type == 'playback_status') {
|
||||
setState(() => _isPlaying = data['status'] == 'playing');
|
||||
} else if (type == 'user_activity') {
|
||||
@@ -213,7 +217,8 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
|
||||
void _sendMessage(Map<String, dynamic> message) {
|
||||
if (_isInitialized) {
|
||||
final iframe = html.document.getElementById(_viewId) as html.IFrameElement?;
|
||||
final iframe =
|
||||
html.document.getElementById(_viewId) as html.IFrameElement?;
|
||||
iframe?.contentWindow?.postMessage(message, '*');
|
||||
}
|
||||
}
|
||||
@@ -272,7 +277,7 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
_initializePlayer(isChannelSwitch: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String _formatDuration(Duration d) {
|
||||
String twoDigits(int n) => n.toString().padLeft(2, '0');
|
||||
final hours = twoDigits(d.inHours);
|
||||
@@ -306,8 +311,7 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// Video Player (iframe with native controls)
|
||||
if (_isInitialized)
|
||||
HtmlElementView(viewType: _viewId),
|
||||
if (_isInitialized) HtmlElementView(viewType: _viewId),
|
||||
|
||||
// Top Bar: Back Button + Title (with auto-hide)
|
||||
AnimatedPositioned(
|
||||
@@ -326,21 +330,24 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
customBorder: const CircleBorder(),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: Icon(Icons.arrow_back_rounded, color: Colors.white),
|
||||
child: Icon(Icons.arrow_back_rounded,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.channels != null
|
||||
? widget.channels![_currentIndex].name
|
||||
widget.channels != null
|
||||
? widget.channels![_currentIndex].name
|
||||
: widget.title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
shadows: [Shadow(blurRadius: 4, color: Colors.black)],
|
||||
shadows: [
|
||||
Shadow(blurRadius: 4, color: Colors.black)
|
||||
],
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -355,8 +362,10 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Icon(
|
||||
_isMuted ? Icons.volume_off_rounded : Icons.volume_up_rounded,
|
||||
color: Colors.white
|
||||
_isMuted
|
||||
? Icons.volume_off_rounded
|
||||
: Icons.volume_up_rounded,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -385,7 +394,8 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
customBorder: const CircleBorder(),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(14),
|
||||
child: Icon(Icons.keyboard_arrow_up, color: Colors.white, size: 28),
|
||||
child: Icon(Icons.keyboard_arrow_up,
|
||||
color: Colors.white, size: 28),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -399,7 +409,8 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
customBorder: const CircleBorder(),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(14),
|
||||
child: Icon(Icons.keyboard_arrow_down, color: Colors.white, size: 28),
|
||||
child: Icon(Icons.keyboard_arrow_down,
|
||||
color: Colors.white, size: 28),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -418,8 +429,8 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
child: PointerInterceptor(
|
||||
child: EpgOverlay(
|
||||
playlist: widget.playlist,
|
||||
streamId: widget.channels != null
|
||||
? widget.channels![_currentIndex].streamId
|
||||
streamId: widget.channels != null
|
||||
? widget.channels![_currentIndex].streamId
|
||||
: widget.streamId,
|
||||
),
|
||||
),
|
||||
@@ -438,8 +449,7 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 1. Video Player Layer
|
||||
if (_isInitialized)
|
||||
HtmlElementView(viewType: _viewId),
|
||||
if (_isInitialized) HtmlElementView(viewType: _viewId),
|
||||
|
||||
// 2. Interaction Layer
|
||||
Positioned.fill(
|
||||
@@ -469,184 +479,225 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
color: Colors.black.withOpacity(0.3), // Dim background
|
||||
child: Stack(
|
||||
children: [
|
||||
// Top Bar (Back + Title)
|
||||
Positioned(
|
||||
top: 24,
|
||||
left: 24,
|
||||
right: 24,
|
||||
child: Row(
|
||||
children: [
|
||||
TvFocusableCard(
|
||||
onTap: () => Navigator.pop(context),
|
||||
borderRadius: 50,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.arrow_back_rounded, color: Colors.white),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
widget.channels != null
|
||||
? widget.channels![_currentIndex].name
|
||||
: widget.title,
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
if (widget.streamType == StreamType.live && widget.channels != null)
|
||||
Text(
|
||||
'Live TV',
|
||||
style: GoogleFonts.inter(fontSize: 14, color: AppColors.live, fontWeight: FontWeight.bold)
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Top Bar (Back + Title)
|
||||
Positioned(
|
||||
top: 24,
|
||||
left: 24,
|
||||
right: 24,
|
||||
child: Row(
|
||||
children: [
|
||||
TvFocusableCard(
|
||||
onTap: () => Navigator.pop(context),
|
||||
borderRadius: 50,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.arrow_back_rounded,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
widget.channels != null
|
||||
? widget.channels![_currentIndex].name
|
||||
: widget.title,
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
if (widget.streamType == StreamType.live &&
|
||||
widget.channels != null)
|
||||
Text(
|
||||
'Live TV',
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 14,
|
||||
color: AppColors.live,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Center Play/Pause (Animated)
|
||||
Center(
|
||||
child: _isLoading
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
: TvFocusableCard(
|
||||
onTap: _togglePlayPause,
|
||||
borderRadius: 100,
|
||||
scaleFactor: 1.2,
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white.withOpacity(0.3)),
|
||||
),
|
||||
child: Icon(
|
||||
_isPlaying ? Icons.pause_rounded : Icons.play_arrow_rounded,
|
||||
color: Colors.white,
|
||||
size: 48,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Center Play/Pause (Animated)
|
||||
Center(
|
||||
child: _isLoading
|
||||
? const CircularProgressIndicator(
|
||||
color: Colors.white)
|
||||
: TvFocusableCard(
|
||||
onTap: _togglePlayPause,
|
||||
borderRadius: 100,
|
||||
scaleFactor: 1.2,
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.3)),
|
||||
),
|
||||
child: Icon(
|
||||
_isPlaying
|
||||
? Icons.pause_rounded
|
||||
: Icons.play_arrow_rounded,
|
||||
color: Colors.white,
|
||||
size: 48,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// EPG Overlay
|
||||
if (widget.streamType == StreamType.live)
|
||||
Positioned(
|
||||
bottom: 140,
|
||||
left: 40,
|
||||
child: EpgOverlay(
|
||||
streamId: widget.channels != null
|
||||
? widget.channels![_currentIndex].streamId
|
||||
: widget.streamId,
|
||||
playlist: widget.playlist,
|
||||
),
|
||||
),
|
||||
// EPG Overlay
|
||||
if (widget.streamType == StreamType.live)
|
||||
Positioned(
|
||||
bottom: 140,
|
||||
left: 40,
|
||||
child: EpgOverlay(
|
||||
streamId: widget.channels != null
|
||||
? widget.channels![_currentIndex].streamId
|
||||
: widget.streamId,
|
||||
playlist: widget.playlist,
|
||||
),
|
||||
),
|
||||
|
||||
// Bottom Control Bar
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
left: 40,
|
||||
right: 40,
|
||||
child: GlassContainer(
|
||||
borderRadius: 24,
|
||||
opacity: 0.8,
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Progress Bar (if not live)
|
||||
if (widget.streamType != StreamType.live)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(_formatDuration(Duration(seconds: _currentPosition.toInt())), style: const TextStyle(color: Colors.white70)),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: SliderTheme(
|
||||
data: SliderThemeData(
|
||||
trackHeight: 4,
|
||||
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 8),
|
||||
overlayShape: const RoundSliderOverlayShape(overlayRadius: 16),
|
||||
activeTrackColor: AppColors.primary,
|
||||
inactiveTrackColor: Colors.white24,
|
||||
thumbColor: Colors.white,
|
||||
),
|
||||
child: Slider(
|
||||
value: _currentPosition,
|
||||
min: 0,
|
||||
max: _totalDuration,
|
||||
onChangeStart: (value) {
|
||||
setState(() => _isSeeking = true);
|
||||
},
|
||||
onChanged: (value) {
|
||||
// Update UI immediately (optimistic update)
|
||||
setState(() => _currentPosition = value);
|
||||
},
|
||||
onChangeEnd: (value) {
|
||||
_sendMessage({'type': 'seek', 'value': value});
|
||||
// Small delay to prevent jitter from incoming messages
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
if (mounted) setState(() => _isSeeking = false);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(_formatDuration(Duration(seconds: _totalDuration.toInt())), style: const TextStyle(color: Colors.white70)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Controls Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Channel Zapping for Live TV
|
||||
if (widget.streamType == StreamType.live && widget.channels != null) ...[
|
||||
_buildTvControl(Icons.navigate_before_rounded, _previousChannel),
|
||||
const SizedBox(width: 32),
|
||||
_buildTvControl(Icons.navigate_next_rounded, _nextChannel),
|
||||
],
|
||||
|
||||
// Controls for VOD (Keep Skip buttons, they act as Prev/Next track if playlist or maybe seek)
|
||||
// The user said: "only for live tv, other buttons skip/prev must allow changing channel"
|
||||
// This implies for VOD they might want seek? But existing buttons were skip_previous/skip_next.
|
||||
// We keep them for VOD if channels list is present, or just hide them if not needed.
|
||||
// For now, I will restore them for VOD as well if channels > 0 (playlist mode)
|
||||
if (widget.streamType != StreamType.live && widget.channels != null && widget.channels!.isNotEmpty) ...[
|
||||
_buildTvControl(Icons.skip_previous_rounded, _previousChannel),
|
||||
const SizedBox(width: 32),
|
||||
_buildTvControl(Icons.skip_next_rounded, _nextChannel),
|
||||
],
|
||||
|
||||
const Spacer(),
|
||||
// Volume/Mute button
|
||||
_buildTvControl(
|
||||
_isMuted ? Icons.volume_off_rounded : Icons.volume_up_rounded,
|
||||
_toggleMute
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
_buildTvControl(Icons.subtitles_rounded, () {}),
|
||||
const SizedBox(width: 16),
|
||||
_buildTvControl(Icons.aspect_ratio_rounded, _toggleFullscreen),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Bottom Control Bar
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
left: 40,
|
||||
right: 40,
|
||||
child: GlassContainer(
|
||||
borderRadius: 24,
|
||||
opacity: 0.8,
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Progress Bar (if not live)
|
||||
if (widget.streamType != StreamType.live)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
_formatDuration(Duration(
|
||||
seconds:
|
||||
_currentPosition.toInt())),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70)),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: SliderTheme(
|
||||
data: const SliderThemeData(
|
||||
trackHeight: 4,
|
||||
thumbShape: RoundSliderThumbShape(
|
||||
enabledThumbRadius: 8),
|
||||
overlayShape:
|
||||
RoundSliderOverlayShape(
|
||||
overlayRadius: 16),
|
||||
activeTrackColor: AppColors.primary,
|
||||
inactiveTrackColor: Colors.white24,
|
||||
thumbColor: Colors.white,
|
||||
),
|
||||
child: Slider(
|
||||
value: _currentPosition,
|
||||
min: 0,
|
||||
max: _totalDuration,
|
||||
onChangeStart: (value) {
|
||||
setState(() => _isSeeking = true);
|
||||
},
|
||||
onChanged: (value) {
|
||||
// Update UI immediately (optimistic update)
|
||||
setState(() =>
|
||||
_currentPosition = value);
|
||||
},
|
||||
onChangeEnd: (value) {
|
||||
_sendMessage({
|
||||
'type': 'seek',
|
||||
'value': value
|
||||
});
|
||||
// Small delay to prevent jitter from incoming messages
|
||||
Future.delayed(
|
||||
const Duration(
|
||||
milliseconds: 500), () {
|
||||
if (mounted)
|
||||
setState(
|
||||
() => _isSeeking = false);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
_formatDuration(Duration(
|
||||
seconds: _totalDuration.toInt())),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Controls Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Channel Zapping for Live TV
|
||||
if (widget.streamType == StreamType.live &&
|
||||
widget.channels != null) ...[
|
||||
_buildTvControl(
|
||||
Icons.navigate_before_rounded,
|
||||
_previousChannel),
|
||||
const SizedBox(width: 32),
|
||||
_buildTvControl(Icons.navigate_next_rounded,
|
||||
_nextChannel),
|
||||
],
|
||||
|
||||
// Controls for VOD (Keep Skip buttons, they act as Prev/Next track if playlist or maybe seek)
|
||||
// The user said: "only for live tv, other buttons skip/prev must allow changing channel"
|
||||
// This implies for VOD they might want seek? But existing buttons were skip_previous/skip_next.
|
||||
// We keep them for VOD if channels list is present, or just hide them if not needed.
|
||||
// For now, I will restore them for VOD as well if channels > 0 (playlist mode)
|
||||
if (widget.streamType != StreamType.live &&
|
||||
widget.channels != null &&
|
||||
widget.channels!.isNotEmpty) ...[
|
||||
_buildTvControl(Icons.skip_previous_rounded,
|
||||
_previousChannel),
|
||||
const SizedBox(width: 32),
|
||||
_buildTvControl(
|
||||
Icons.skip_next_rounded, _nextChannel),
|
||||
],
|
||||
|
||||
const Spacer(),
|
||||
// Volume/Mute button
|
||||
_buildTvControl(
|
||||
_isMuted
|
||||
? Icons.volume_off_rounded
|
||||
: Icons.volume_up_rounded,
|
||||
_toggleMute,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
_buildTvControl(
|
||||
Icons.subtitles_rounded, () {}),
|
||||
const SizedBox(width: 16),
|
||||
_buildTvControl(Icons.aspect_ratio_rounded,
|
||||
_toggleFullscreen),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -656,7 +707,7 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildTvControl(IconData icon, VoidCallback onTap) {
|
||||
return TvFocusableCard(
|
||||
onTap: onTap,
|
||||
|
||||
@@ -26,14 +26,16 @@ class PlaylistSelectionScreen extends ConsumerWidget {
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'Select Playlist',
|
||||
style: GoogleFonts.roboto(fontWeight: FontWeight.w600, color: Colors.white),
|
||||
style: GoogleFonts.roboto(
|
||||
fontWeight: FontWeight.w600, color: Colors.white),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
if (currentUser?.isAdmin ?? false)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.admin_panel_settings, color: Colors.white70),
|
||||
icon:
|
||||
const Icon(Icons.admin_panel_settings, color: Colors.white70),
|
||||
onPressed: () => context.go('/admin'),
|
||||
tooltip: 'Admin Panel',
|
||||
),
|
||||
@@ -69,7 +71,9 @@ class PlaylistSelectionScreen extends ConsumerWidget {
|
||||
children: [
|
||||
Icon(Icons.error_outline, size: 64, color: Colors.red.shade400),
|
||||
const SizedBox(height: 16),
|
||||
Text('Error loading playlists', style: GoogleFonts.roboto(fontSize: 18, color: Colors.white70)),
|
||||
Text('Error loading playlists',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 18, color: Colors.white70)),
|
||||
const SizedBox(height: 8),
|
||||
ElevatedButton(
|
||||
onPressed: () => ref.refresh(playlistsProvider),
|
||||
@@ -84,7 +88,7 @@ class PlaylistSelectionScreen extends ConsumerWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
const Icon(
|
||||
Icons.playlist_remove,
|
||||
size: 64,
|
||||
color: Colors.white24,
|
||||
@@ -113,7 +117,8 @@ class PlaylistSelectionScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(24, 100, 24, 24), // Top padding for transparent AppBar
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
24, 100, 24, 24), // Top padding for transparent AppBar
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 24,
|
||||
@@ -165,23 +170,25 @@ class _PlaylistCardState extends State<_PlaylistCard> {
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
decoration: BoxDecoration(
|
||||
color: _isHovered
|
||||
? Colors.white.withOpacity(0.15)
|
||||
color: _isHovered
|
||||
? Colors.white.withOpacity(0.15)
|
||||
: Colors.white.withOpacity(0.05), // Glass effect
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: _isHovered
|
||||
? Colors.white.withOpacity(0.5)
|
||||
color: _isHovered
|
||||
? Colors.white.withOpacity(0.5)
|
||||
: Colors.white.withOpacity(0.1),
|
||||
width: 1.5,
|
||||
),
|
||||
boxShadow: _isHovered ? [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
] : [],
|
||||
boxShadow: _isHovered
|
||||
? [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
]
|
||||
: [],
|
||||
),
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
@@ -204,7 +211,8 @@ class _PlaylistCardState extends State<_PlaylistCard> {
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
widget.playlist.name,
|
||||
style: GoogleFonts.outfit( // Using Outfit for modern look
|
||||
style: GoogleFonts.outfit(
|
||||
// Using Outfit for modern look
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
@@ -229,4 +237,3 @@ class _PlaylistCardState extends State<_PlaylistCard> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user