fix: eliminate video player blue screen on desktop with software rendering default and decoder toggle (v3.6.4)
This commit is contained in:
@@ -1,4 +1,14 @@
|
|||||||
const prismaChangelog = [
|
const prismaChangelog = [
|
||||||
|
PrismaChange(
|
||||||
|
version: '3.6.4',
|
||||||
|
title: 'Полное исправление воспроизведения видео на ПК (устранение синего экрана)',
|
||||||
|
bullets: [
|
||||||
|
'Программный рендеринг (S/W) по умолчанию для ПК: на десктопных платформах отключен проблемный OpenGL FBO мост аппаратного ускорения, вызывавший синий экран из-за отсутствия или конфликтов драйверов VAAPI/VDPAU в Linux/AppImage.',
|
||||||
|
'Переключатель декодера H/W / S/W в плеере: на верхней панели управления видеоплеером добавлена кнопка быстрого переключения между аппаратным (H/W) и программным (S/W) декодированием на лету.',
|
||||||
|
'Отображение постера-превью: под видеоплеером теперь отображается превью-постер на время буферизации, исключая появление пустых областей.',
|
||||||
|
'Безопасное превью в ленте: предпросмотр видео в карточках постов на ПК также переведен на надежный программный рендерер.',
|
||||||
|
],
|
||||||
|
),
|
||||||
PrismaChange(
|
PrismaChange(
|
||||||
version: '3.6.3',
|
version: '3.6.3',
|
||||||
title: 'Горизонтальный скролл колесиком мыши на ПК и исправление синего экрана в видеоплеере',
|
title: 'Горизонтальный скролл колесиком мыши на ПК и исправление синего экрана в видеоплеере',
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
String? _videoError;
|
String? _videoError;
|
||||||
bool _retriedFormatError = false;
|
bool _retriedFormatError = false;
|
||||||
bool _softwareDecodingFallback = false;
|
bool _softwareDecodingFallback = false;
|
||||||
|
late bool _useSoftwareDecoding =
|
||||||
|
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
|
||||||
Timer? _hideTimer;
|
Timer? _hideTimer;
|
||||||
StreamSubscription<String>? _errorSubscription;
|
StreamSubscription<String>? _errorSubscription;
|
||||||
StreamSubscription<Duration>? _positionSubscription;
|
StreamSubscription<Duration>? _positionSubscription;
|
||||||
@@ -109,6 +111,8 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
_videoError = null;
|
_videoError = null;
|
||||||
_retriedFormatError = false;
|
_retriedFormatError = false;
|
||||||
_softwareDecodingFallback = false;
|
_softwareDecodingFallback = false;
|
||||||
|
_useSoftwareDecoding =
|
||||||
|
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
|
||||||
_imageUrls = _buildImageUrls(widget.post);
|
_imageUrls = _buildImageUrls(widget.post);
|
||||||
_videoUrls = _buildVideoUrls(widget.post);
|
_videoUrls = _buildVideoUrls(widget.post);
|
||||||
if (_isPlayableMedia(widget.post) && _videoUrls.isNotEmpty) {
|
if (_isPlayableMedia(widget.post) && _videoUrls.isNotEmpty) {
|
||||||
@@ -226,6 +230,11 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
aspectRatio: widget.post.width > 0 && widget.post.height > 0
|
aspectRatio: widget.post.width > 0 && widget.post.height > 0
|
||||||
? widget.post.width / widget.post.height
|
? widget.post.width / widget.post.height
|
||||||
: 16 / 9,
|
: 16 / 9,
|
||||||
|
previewUrl: widget.post.previewUrl.isNotEmpty
|
||||||
|
? widget.post.previewUrl
|
||||||
|
: widget.post.sampleUrl,
|
||||||
|
isSoftwareDecoding: _useSoftwareDecoding,
|
||||||
|
onToggleDecoder: _toggleDecoderMode,
|
||||||
controlsVisible: _controlsVisible,
|
controlsVisible: _controlsVisible,
|
||||||
coverVideo: _coverVideo,
|
coverVideo: _coverVideo,
|
||||||
muted: _muted,
|
muted: _muted,
|
||||||
@@ -444,13 +453,12 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
void _initializeVideo() {
|
void _initializeVideo() {
|
||||||
MediaKit.ensureInitialized();
|
MediaKit.ensureInitialized();
|
||||||
_player = Player();
|
_player = Player();
|
||||||
|
final bool enableHw = !_useSoftwareDecoding && !_softwareDecodingFallback;
|
||||||
_controller = VideoController(
|
_controller = VideoController(
|
||||||
_player!,
|
_player!,
|
||||||
configuration: VideoControllerConfiguration(
|
configuration: VideoControllerConfiguration(
|
||||||
enableHardwareAcceleration: !_softwareDecodingFallback,
|
enableHardwareAcceleration: enableHw,
|
||||||
hwdec: _softwareDecodingFallback
|
hwdec: enableHw ? (Platform.isAndroid ? 'auto-safe' : 'auto') : 'no',
|
||||||
? 'no'
|
|
||||||
: (Platform.isAndroid ? 'auto-safe' : 'auto'),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
_applyVolume();
|
_applyVolume();
|
||||||
@@ -525,6 +533,7 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
lower.contains('failed to recognize file format'))) {
|
lower.contains('failed to recognize file format'))) {
|
||||||
_retriedFormatError = true;
|
_retriedFormatError = true;
|
||||||
_softwareDecodingFallback = true;
|
_softwareDecodingFallback = true;
|
||||||
|
_useSoftwareDecoding = true;
|
||||||
_disposeVideo();
|
_disposeVideo();
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 250));
|
await Future<void>.delayed(const Duration(milliseconds: 250));
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
@@ -542,6 +551,7 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
_videoIndex = 0;
|
_videoIndex = 0;
|
||||||
_retriedFormatError = false;
|
_retriedFormatError = false;
|
||||||
_softwareDecodingFallback = true;
|
_softwareDecodingFallback = true;
|
||||||
|
_useSoftwareDecoding = true;
|
||||||
_disposeVideo();
|
_disposeVideo();
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 150));
|
await Future<void>.delayed(const Duration(milliseconds: 150));
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
@@ -549,6 +559,26 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _toggleDecoderMode() {
|
||||||
|
setState(() {
|
||||||
|
_useSoftwareDecoding = !_useSoftwareDecoding;
|
||||||
|
_softwareDecodingFallback = false;
|
||||||
|
_retriedFormatError = false;
|
||||||
|
});
|
||||||
|
_disposeVideo();
|
||||||
|
_initializeVideo();
|
||||||
|
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
_useSoftwareDecoding
|
||||||
|
? 'Включено программное декодирование (S/W)'
|
||||||
|
: 'Включено аппаратное декодирование (H/W)',
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _disposeVideo() {
|
void _disposeVideo() {
|
||||||
_hideTimer?.cancel();
|
_hideTimer?.cancel();
|
||||||
_errorSubscription?.cancel();
|
_errorSubscription?.cancel();
|
||||||
@@ -690,6 +720,11 @@ class _PostMediaViewerState extends State<PostMediaViewer>
|
|||||||
halfVolume: _halfVolume,
|
halfVolume: _halfVolume,
|
||||||
coverVideo: _coverVideo,
|
coverVideo: _coverVideo,
|
||||||
initialVolume: _currentVolume,
|
initialVolume: _currentVolume,
|
||||||
|
previewUrl: widget.post.previewUrl.isNotEmpty
|
||||||
|
? widget.post.previewUrl
|
||||||
|
: widget.post.sampleUrl,
|
||||||
|
isSoftwareDecoding: _useSoftwareDecoding,
|
||||||
|
onToggleDecoder: _toggleDecoderMode,
|
||||||
errorMessage: _videoError,
|
errorMessage: _videoError,
|
||||||
onRetry: _retryVideo,
|
onRetry: _retryVideo,
|
||||||
onChanged: (snapshot) {
|
onChanged: (snapshot) {
|
||||||
@@ -886,6 +921,9 @@ class _FullscreenVideoPage extends StatefulWidget {
|
|||||||
required this.halfVolume,
|
required this.halfVolume,
|
||||||
required this.coverVideo,
|
required this.coverVideo,
|
||||||
this.initialVolume = 100.0,
|
this.initialVolume = 100.0,
|
||||||
|
this.previewUrl,
|
||||||
|
required this.isSoftwareDecoding,
|
||||||
|
required this.onToggleDecoder,
|
||||||
required this.errorMessage,
|
required this.errorMessage,
|
||||||
required this.onRetry,
|
required this.onRetry,
|
||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
@@ -900,6 +938,9 @@ class _FullscreenVideoPage extends StatefulWidget {
|
|||||||
final bool halfVolume;
|
final bool halfVolume;
|
||||||
final bool coverVideo;
|
final bool coverVideo;
|
||||||
final double initialVolume;
|
final double initialVolume;
|
||||||
|
final String? previewUrl;
|
||||||
|
final bool isSoftwareDecoding;
|
||||||
|
final VoidCallback onToggleDecoder;
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
final VoidCallback onRetry;
|
final VoidCallback onRetry;
|
||||||
final ValueChanged<VideoPlaybackSnapshot> onChanged;
|
final ValueChanged<VideoPlaybackSnapshot> onChanged;
|
||||||
@@ -1024,6 +1065,9 @@ class _FullscreenVideoPageState extends State<_FullscreenVideoPage> {
|
|||||||
player: widget.player,
|
player: widget.player,
|
||||||
controller: widget.controller,
|
controller: widget.controller,
|
||||||
aspectRatio: widget.aspectRatio,
|
aspectRatio: widget.aspectRatio,
|
||||||
|
previewUrl: widget.previewUrl,
|
||||||
|
isSoftwareDecoding: widget.isSoftwareDecoding,
|
||||||
|
onToggleDecoder: widget.onToggleDecoder,
|
||||||
controlsVisible: _controlsVisible,
|
controlsVisible: _controlsVisible,
|
||||||
coverVideo: _coverVideo,
|
coverVideo: _coverVideo,
|
||||||
muted: _muted,
|
muted: _muted,
|
||||||
@@ -1575,6 +1619,9 @@ class _VideoSurface extends StatefulWidget {
|
|||||||
required this.player,
|
required this.player,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.aspectRatio,
|
required this.aspectRatio,
|
||||||
|
this.previewUrl,
|
||||||
|
required this.isSoftwareDecoding,
|
||||||
|
required this.onToggleDecoder,
|
||||||
required this.controlsVisible,
|
required this.controlsVisible,
|
||||||
required this.coverVideo,
|
required this.coverVideo,
|
||||||
required this.muted,
|
required this.muted,
|
||||||
@@ -1599,6 +1646,9 @@ class _VideoSurface extends StatefulWidget {
|
|||||||
final Player player;
|
final Player player;
|
||||||
final VideoController controller;
|
final VideoController controller;
|
||||||
final double aspectRatio;
|
final double aspectRatio;
|
||||||
|
final String? previewUrl;
|
||||||
|
final bool isSoftwareDecoding;
|
||||||
|
final VoidCallback onToggleDecoder;
|
||||||
final bool controlsVisible;
|
final bool controlsVisible;
|
||||||
final bool coverVideo;
|
final bool coverVideo;
|
||||||
final bool muted;
|
final bool muted;
|
||||||
@@ -1757,15 +1807,22 @@ class _VideoSurfaceState extends State<_VideoSurface> {
|
|||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
ColoredBox(
|
if (widget.previewUrl != null && widget.previewUrl!.isNotEmpty)
|
||||||
color: Colors.black,
|
Positioned.fill(
|
||||||
child: Video(
|
child: CachedNetworkImage(
|
||||||
controller: widget.controller,
|
imageUrl: widget.previewUrl!,
|
||||||
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
|
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
|
||||||
controls: null,
|
memCacheWidth: 1920,
|
||||||
pauseUponEnteringBackgroundMode: false,
|
memCacheHeight: 1080,
|
||||||
resumeUponEnteringForegroundMode: false,
|
),
|
||||||
),
|
),
|
||||||
|
Video(
|
||||||
|
controller: widget.controller,
|
||||||
|
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
|
||||||
|
fill: Colors.transparent,
|
||||||
|
controls: null,
|
||||||
|
pauseUponEnteringBackgroundMode: false,
|
||||||
|
resumeUponEnteringForegroundMode: false,
|
||||||
),
|
),
|
||||||
if (_currentBrightness < 0.99)
|
if (_currentBrightness < 0.99)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
@@ -1844,6 +1901,8 @@ class _VideoSurfaceState extends State<_VideoSurface> {
|
|||||||
fullscreen: widget.fullscreen,
|
fullscreen: widget.fullscreen,
|
||||||
isLocked: _isLocked,
|
isLocked: _isLocked,
|
||||||
isLandscape: widget.isLandscape,
|
isLandscape: widget.isLandscape,
|
||||||
|
isSoftwareDecoding: widget.isSoftwareDecoding,
|
||||||
|
onToggleDecoder: widget.onToggleDecoder,
|
||||||
onToggleOrientation: widget.onToggleOrientation,
|
onToggleOrientation: widget.onToggleOrientation,
|
||||||
onToggleLock: () => setState(() => _isLocked = !_isLocked),
|
onToggleLock: () => setState(() => _isLocked = !_isLocked),
|
||||||
onToggleFit: widget.onToggleFit,
|
onToggleFit: widget.onToggleFit,
|
||||||
@@ -2655,6 +2714,8 @@ class _VideoControls extends StatefulWidget {
|
|||||||
required this.fullscreen,
|
required this.fullscreen,
|
||||||
required this.isLocked,
|
required this.isLocked,
|
||||||
this.isLandscape,
|
this.isLandscape,
|
||||||
|
required this.isSoftwareDecoding,
|
||||||
|
required this.onToggleDecoder,
|
||||||
this.onToggleOrientation,
|
this.onToggleOrientation,
|
||||||
required this.onToggleLock,
|
required this.onToggleLock,
|
||||||
required this.onToggleFit,
|
required this.onToggleFit,
|
||||||
@@ -2674,6 +2735,8 @@ class _VideoControls extends StatefulWidget {
|
|||||||
final bool fullscreen;
|
final bool fullscreen;
|
||||||
final bool isLocked;
|
final bool isLocked;
|
||||||
final bool? isLandscape;
|
final bool? isLandscape;
|
||||||
|
final bool isSoftwareDecoding;
|
||||||
|
final VoidCallback onToggleDecoder;
|
||||||
final VoidCallback? onToggleOrientation;
|
final VoidCallback? onToggleOrientation;
|
||||||
final VoidCallback onToggleLock;
|
final VoidCallback onToggleLock;
|
||||||
final VoidCallback onToggleFit;
|
final VoidCallback onToggleFit;
|
||||||
@@ -2773,6 +2836,17 @@ class _VideoControlsState extends State<_VideoControls> {
|
|||||||
onPressed: widget.onToggleLock,
|
onPressed: widget.onToggleLock,
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
_RoundControlButton(
|
||||||
|
tooltip: widget.isSoftwareDecoding
|
||||||
|
? 'Декодер: S/W (программный). Нажмите для переключения на H/W'
|
||||||
|
: 'Декодер: H/W (аппаратный). Нажмите для переключения на S/W',
|
||||||
|
selected: !widget.isSoftwareDecoding,
|
||||||
|
icon: widget.isSoftwareDecoding
|
||||||
|
? Icons.memory_rounded
|
||||||
|
: Icons.speed_rounded,
|
||||||
|
onPressed: widget.onToggleDecoder,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
_SpeedBadgeButton(
|
_SpeedBadgeButton(
|
||||||
currentRate: currentRate,
|
currentRate: currentRate,
|
||||||
onSelected: (newRate) => widget.player.setRate(newRate),
|
onSelected: (newRate) => widget.player.setRate(newRate),
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ class _DesktopShellState extends State<_DesktopShell>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'v3.6.3',
|
'v3.6.4',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
fontWeight:
|
fontWeight:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -590,7 +591,15 @@ class _FeedVideoPreviewState extends State<_FeedVideoPreview> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
MediaKit.ensureInitialized();
|
MediaKit.ensureInitialized();
|
||||||
_player = Player();
|
_player = Player();
|
||||||
_controller = VideoController(_player);
|
final isDesktop =
|
||||||
|
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
|
||||||
|
_controller = VideoController(
|
||||||
|
_player,
|
||||||
|
configuration: VideoControllerConfiguration(
|
||||||
|
enableHardwareAcceleration: !isDesktop,
|
||||||
|
hwdec: isDesktop ? 'no' : 'auto-safe',
|
||||||
|
),
|
||||||
|
);
|
||||||
_player.stream.error.listen((_) {
|
_player.stream.error.listen((_) {
|
||||||
if (mounted) setState(() => _failed = true);
|
if (mounted) setState(() => _failed = true);
|
||||||
});
|
});
|
||||||
@@ -633,15 +642,13 @@ class _FeedVideoPreviewState extends State<_FeedVideoPreview> {
|
|||||||
AnimatedOpacity(
|
AnimatedOpacity(
|
||||||
opacity: _ready ? 1 : 0,
|
opacity: _ready ? 1 : 0,
|
||||||
duration: AppMotion.duration(context, 180),
|
duration: AppMotion.duration(context, 180),
|
||||||
child: ColoredBox(
|
child: Video(
|
||||||
color: Colors.black,
|
controller: _controller,
|
||||||
child: Video(
|
fit: BoxFit.cover,
|
||||||
controller: _controller,
|
fill: Colors.transparent,
|
||||||
fit: BoxFit.cover,
|
controls: null,
|
||||||
controls: null,
|
pauseUponEnteringBackgroundMode: false,
|
||||||
pauseUponEnteringBackgroundMode: false,
|
resumeUponEnteringForegroundMode: false,
|
||||||
resumeUponEnteringForegroundMode: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
name: gel_rule_app
|
name: gel_rule_app
|
||||||
description: Local backend/core layer for a Flutter booru browser app.
|
description: Local backend/core layer for a Flutter booru browser app.
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 3.6.3+85
|
version: 3.6.4+86
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.3.0 <4.0.0"
|
sdk: ">=3.3.0 <4.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user