mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
feat: Add initial IPTV player with HLS.js and mpegts.js support, including UI and parent communication.
This commit is contained in:
1 parent
0c087e0b34
commit
41c4ab05aa
6 files changed
+127
-49
No files matched your search
@@ -62,6 +62,7 @@ class _SettingsKeys {
|
||||
static const String showClock = 'show_clock';
|
||||
static const String preferredAspectRatio = 'aspect_ratio';
|
||||
static const String playerType = 'player_type';
|
||||
static const String forceVodTranscoding = 'force_vod_transcoding';
|
||||
}
|
||||
|
||||
/// Settings state for IPTV preferences with persistence
|
||||
@@ -84,6 +85,9 @@ class IptvSettings {
|
||||
final bool showClock;
|
||||
final String preferredAspectRatio;
|
||||
final PlayerType playerType;
|
||||
|
||||
// VOD Settings
|
||||
final bool forceVodTranscoding;
|
||||
|
||||
const IptvSettings({
|
||||
// Filters
|
||||
@@ -102,6 +106,8 @@ class IptvSettings {
|
||||
this.showClock = false,
|
||||
this.preferredAspectRatio = 'contain',
|
||||
this.playerType = PlayerType.standard,
|
||||
// VOD defaults
|
||||
this.forceVodTranscoding = false,
|
||||
});
|
||||
|
||||
IptvSettings copyWith({
|
||||
@@ -118,6 +124,7 @@ class IptvSettings {
|
||||
bool? showClock,
|
||||
String? preferredAspectRatio,
|
||||
PlayerType? playerType,
|
||||
bool? forceVodTranscoding,
|
||||
}) {
|
||||
return IptvSettings(
|
||||
liveTvCategoryFilter: liveTvCategoryFilter ?? this.liveTvCategoryFilter,
|
||||
@@ -133,6 +140,7 @@ class IptvSettings {
|
||||
showClock: showClock ?? this.showClock,
|
||||
preferredAspectRatio: preferredAspectRatio ?? this.preferredAspectRatio,
|
||||
playerType: playerType ?? this.playerType,
|
||||
forceVodTranscoding: forceVodTranscoding ?? this.forceVodTranscoding,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -298,6 +306,7 @@ class IptvSettingsNotifier extends StateNotifier<IptvSettings> {
|
||||
preferredAspectRatio: getValue<String>(_SettingsKeys.preferredAspectRatio),
|
||||
playerType: remoteSettings[_SettingsKeys.playerType] != null
|
||||
? PlayerType.values[remoteSettings[_SettingsKeys.playerType] as int] : null,
|
||||
forceVodTranscoding: getValue<bool>(_SettingsKeys.forceVodTranscoding),
|
||||
);
|
||||
}
|
||||
_initialized = true;
|
||||
@@ -328,6 +337,7 @@ class IptvSettingsNotifier extends StateNotifier<IptvSettings> {
|
||||
_SettingsKeys.showClock: state.showClock,
|
||||
_SettingsKeys.preferredAspectRatio: state.preferredAspectRatio,
|
||||
_SettingsKeys.playerType: state.playerType.index,
|
||||
_SettingsKeys.forceVodTranscoding: state.forceVodTranscoding,
|
||||
};
|
||||
|
||||
print('[SettingsProvider] _saveToApi: Saving settings...');
|
||||
@@ -422,6 +432,12 @@ class IptvSettingsNotifier extends StateNotifier<IptvSettings> {
|
||||
// Legacy methods
|
||||
void setCategoryFilter(String filter) => setLiveTvFilter(filter);
|
||||
void clearCategoryFilter() => clearLiveTvFilter();
|
||||
|
||||
// VOD Settings
|
||||
void setForceVodTranscoding(bool value) {
|
||||
state = state.copyWith(forceVodTranscoding: value);
|
||||
_saveToApi();
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for IPTV settings
|
||||
|
||||
@@ -102,20 +102,23 @@ class _PlayerScreenState extends ConsumerState<PlayerScreen> {
|
||||
final service = ref.read(xtreamServiceProvider(widget.playlist));
|
||||
String streamUrl = '';
|
||||
|
||||
// Get settings for VOD transcoding preference
|
||||
final playerSettings = ref.read(iptvSettingsProvider);
|
||||
final forceTranscoding = playerSettings.forceVodTranscoding;
|
||||
|
||||
// Generate Stream URL based on type
|
||||
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, forceTranscoding: forceTranscoding);
|
||||
} else if (widget.streamType == StreamType.series) {
|
||||
streamUrl = service.getSeriesStreamUrl(currentStreamId, widget.containerExtension);
|
||||
streamUrl = service.getSeriesStreamUrl(currentStreamId, widget.containerExtension, forceTranscoding: forceTranscoding);
|
||||
}
|
||||
|
||||
// Store URL for Lite Player
|
||||
_currentStreamUrl = streamUrl;
|
||||
|
||||
final encodedUrl = Uri.encodeComponent(streamUrl);
|
||||
final playerSettings = ref.read(iptvSettingsProvider);
|
||||
final streamTypeParam = widget.streamType == StreamType.live ? 'live' : 'vod';
|
||||
var playerSrc = playerSettings.playerType == PlayerType.lite
|
||||
? 'player_lite.html?url=$encodedUrl&type=$streamTypeParam'
|
||||
|
||||
@@ -69,27 +69,43 @@ class XtreamService {
|
||||
}
|
||||
|
||||
/// Generate stream URL for VOD (movies)
|
||||
String getVodStreamUrl(String streamId, String containerExtension) {
|
||||
///
|
||||
/// [forceTranscoding] - If true, uses FFmpeg to transcode audio (guaranteed sound)
|
||||
/// If false, uses direct URL (enables seeking but may lack audio on AC3/DTS)
|
||||
String getVodStreamUrl(String streamId, String containerExtension, {bool forceTranscoding = false}) {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
|
||||
// Use FFmpeg HLS transcoding for guaranteed audio compatibility + seeking
|
||||
final url = '${_currentPlaylist!.dns}/movie/${_currentPlaylist!.username}/${_currentPlaylist!.password}/$streamId.$containerExtension';
|
||||
|
||||
final baseUrl = html.window.location.origin;
|
||||
final encodedUrl = Uri.encodeComponent(url);
|
||||
return '$baseUrl/api/stream/$streamId?url=$encodedUrl';
|
||||
if (forceTranscoding) {
|
||||
// Use FFmpeg transcoding for guaranteed audio (no seeking)
|
||||
final baseUrl = html.window.location.origin;
|
||||
final encodedUrl = Uri.encodeComponent(url);
|
||||
return '$baseUrl/api/stream/$streamId?url=$encodedUrl';
|
||||
} else {
|
||||
// Direct URL for seeking (audio only if AAC/MP3)
|
||||
return _wrapWithProxy(url);
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate stream URL for series episodes
|
||||
String getSeriesStreamUrl(String streamId, String containerExtension) {
|
||||
///
|
||||
/// [forceTranscoding] - If true, uses FFmpeg to transcode audio (guaranteed sound)
|
||||
/// If false, uses direct URL (enables seeking but may lack audio on AC3/DTS)
|
||||
String getSeriesStreamUrl(String streamId, String containerExtension, {bool forceTranscoding = false}) {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
|
||||
// Use FFmpeg HLS transcoding for guaranteed audio compatibility + seeking
|
||||
final url = '${_currentPlaylist!.dns}/series/${_currentPlaylist!.username}/${_currentPlaylist!.password}/$streamId.$containerExtension';
|
||||
|
||||
final baseUrl = html.window.location.origin;
|
||||
final encodedUrl = Uri.encodeComponent(url);
|
||||
return '$baseUrl/api/stream/$streamId?url=$encodedUrl';
|
||||
if (forceTranscoding) {
|
||||
// Use FFmpeg transcoding for guaranteed audio (no seeking)
|
||||
final baseUrl = html.window.location.origin;
|
||||
final encodedUrl = Uri.encodeComponent(url);
|
||||
return '$baseUrl/api/stream/$streamId?url=$encodedUrl';
|
||||
} else {
|
||||
// Direct URL for seeking (audio only if AAC/MP3)
|
||||
return _wrapWithProxy(url);
|
||||
}
|
||||
}
|
||||
|
||||
/// Authenticate and get server info
|
||||
|
||||
@@ -167,6 +167,20 @@ class StreamingSettingsTab extends ConsumerWidget {
|
||||
activeColor: Colors.blueAccent,
|
||||
onChanged: (v) => notifier.setPreferDirectPlay(v),
|
||||
),
|
||||
Divider(height: 1, color: Colors.white.withOpacity(0.1)),
|
||||
SwitchListTile(
|
||||
title: Text(
|
||||
'Forcer audio VOD (Films/Séries)',
|
||||
style: GoogleFonts.roboto(fontSize: 14, color: Colors.white),
|
||||
),
|
||||
subtitle: Text(
|
||||
'Active FFmpeg pour garantir le son\n⚠️ Désactive le seeking',
|
||||
style: GoogleFonts.roboto(fontSize: 12, color: Colors.white54),
|
||||
),
|
||||
value: settings.forceVodTranscoding,
|
||||
activeColor: Colors.orangeAccent,
|
||||
onChanged: (v) => notifier.setForceVodTranscoding(v),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Reference in new issue
Block a user