mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-11 17:29:26 +02:00
feat: add native video player screen for IPTV using media_kit with performance optimizations
This commit is contained in:
1 parent
9cc0f5eacb
commit
58e7e208c3
1 file changed
+9
-7
@@ -87,7 +87,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
_controlsTimer?.cancel();
|
_controlsTimer?.cancel();
|
||||||
_startClock(); // Ensure clock runs when controls are shown
|
_startClock(); // Ensure clock runs when controls are shown
|
||||||
if (_showControls && _isPlaying) {
|
if (_showControls && _isPlaying) {
|
||||||
_controlsTimer = Timer(const Duration(seconds: 10), () {
|
_controlsTimer = Timer(const Duration(seconds: 5), () {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() => _showControls = false);
|
setState(() => _showControls = false);
|
||||||
_stopClock(); // Save CPU when hidden
|
_stopClock(); // Save CPU when hidden
|
||||||
@@ -651,7 +651,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
if (_showControls) return false; // Let Focus handle navigation
|
if (_showControls) return false; // Let Focus handle navigation
|
||||||
|
|
||||||
if (widget.streamType != StreamType.live) {
|
if (widget.streamType != StreamType.live) {
|
||||||
final newPos = _position - const Duration(seconds: 10);
|
final newPos = _position - const Duration(seconds: 5);
|
||||||
_player.seek(newPos < Duration.zero ? Duration.zero : newPos);
|
_player.seek(newPos < Duration.zero ? Duration.zero : newPos);
|
||||||
_onUserInteraction();
|
_onUserInteraction();
|
||||||
}
|
}
|
||||||
@@ -663,7 +663,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
if (_showControls) return false; // Let Focus handle navigation
|
if (_showControls) return false; // Let Focus handle navigation
|
||||||
|
|
||||||
if (widget.streamType != StreamType.live) {
|
if (widget.streamType != StreamType.live) {
|
||||||
final newPos = _position + const Duration(seconds: 10);
|
final newPos = _position + const Duration(seconds: 5);
|
||||||
if (newPos < _duration) {
|
if (newPos < _duration) {
|
||||||
_player.seek(newPos);
|
_player.seek(newPos);
|
||||||
}
|
}
|
||||||
@@ -868,7 +868,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
focusNode: _prevFocusNode,
|
focusNode: _prevFocusNode,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final pos = await _player.stream.position.first;
|
final pos = await _player.stream.position.first;
|
||||||
_player.seek(pos - const Duration(seconds: 10));
|
_player.seek(pos - const Duration(seconds: 5));
|
||||||
_resetControlsTimer();
|
_resetControlsTimer();
|
||||||
},
|
},
|
||||||
onFocus: _resetControlsTimer,
|
onFocus: _resetControlsTimer,
|
||||||
@@ -877,7 +877,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
icon: const Icon(Icons.replay_10, color: Colors.white, size: 48),
|
icon: const Icon(Icons.replay_10, color: Colors.white, size: 48),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final pos = await _player.stream.position.first;
|
final pos = await _player.stream.position.first;
|
||||||
_player.seek(pos - const Duration(seconds: 10));
|
_player.seek(pos - const Duration(seconds: 5));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -920,7 +920,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
focusNode: _nextFocusNode,
|
focusNode: _nextFocusNode,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final pos = await _player.stream.position.first;
|
final pos = await _player.stream.position.first;
|
||||||
_player.seek(pos + const Duration(seconds: 10));
|
_player.seek(pos + const Duration(seconds: 5));
|
||||||
_resetControlsTimer();
|
_resetControlsTimer();
|
||||||
},
|
},
|
||||||
onFocus: _resetControlsTimer,
|
onFocus: _resetControlsTimer,
|
||||||
@@ -929,7 +929,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
icon: const Icon(Icons.forward_10, color: Colors.white, size: 48),
|
icon: const Icon(Icons.forward_10, color: Colors.white, size: 48),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final pos = await _player.stream.position.first;
|
final pos = await _player.stream.position.first;
|
||||||
_player.seek(pos + const Duration(seconds: 10));
|
_player.seek(pos + const Duration(seconds: 5));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1027,6 +1027,8 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
value: _position.inSeconds.toDouble().clamp(0, _duration.inSeconds.toDouble()),
|
value: _position.inSeconds.toDouble().clamp(0, _duration.inSeconds.toDouble()),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: _duration.inSeconds.toDouble(),
|
max: _duration.inSeconds.toDouble(),
|
||||||
|
// Add divisions for precise seeking (1 step = 10 seconds)
|
||||||
|
divisions: _duration.inSeconds > 0 ? (_duration.inSeconds / 10).ceil() : null,
|
||||||
activeColor: AppColors.primary,
|
activeColor: AppColors.primary,
|
||||||
inactiveColor: Colors.white24,
|
inactiveColor: Colors.white24,
|
||||||
onChangeStart: (_) => _isSeeking = true,
|
onChangeStart: (_) => _isSeeking = true,
|
||||||
|
|||||||
Reference in new issue
Block a user