mirror of
https://github.com/K3vinb5/Unyo.git
synced 2026-06-13 13:49:43 +00:00
rewrite: Updated flutter version once again and fixed video aspect ratio
This commit is contained in:
@@ -58,6 +58,7 @@ class VideoCubit extends Cubit<VideoState> with EffectMixin<VideoState> {
|
||||
@override
|
||||
Future<void> close() {
|
||||
if (_videoServiceInitialized) {
|
||||
_videoService.setPreventSleep(false);
|
||||
_videoService.dispose();
|
||||
}
|
||||
_loggedUserSubscription.cancel();
|
||||
@@ -73,6 +74,7 @@ class VideoCubit extends Cubit<VideoState> with EffectMixin<VideoState> {
|
||||
});
|
||||
_videoInfoSubscription = _videoInfoNotifier.videoInfoStream.listen((videoInfo) {
|
||||
_videoService = VideoService(video: videoInfo.currentVideo, playlistIndex: videoInfo.playlistIndex, lowLatency: false);
|
||||
_videoService.setPreventSleep(true);
|
||||
_videoServiceInitialized = true;
|
||||
emit(state.copyWith(videoInfo: videoInfo, isLoading: false));
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// External dependencies
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -14,6 +15,7 @@ import 'package:unyo/core/services/api/http/api_response.dart';
|
||||
import 'package:unyo/core/services/api/http/empty_api_response.dart';
|
||||
import 'package:unyo/core/services/api/http/http_service.dart';
|
||||
import 'package:unyo/core/di/locator.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class VideoService {
|
||||
@@ -21,11 +23,11 @@ class VideoService {
|
||||
final Logger _logger = sl<Logger>();
|
||||
final HttpService _httpService = sl<HttpService>();
|
||||
|
||||
// Properties
|
||||
ext.Video _video;
|
||||
// This will be used for getting the correct video out of a playlist from a magnet / torrent
|
||||
int _playlistIndex;
|
||||
late final mdk.Player _player;
|
||||
late Timer seekTimer;
|
||||
final List<ext.Track> captionTracks = [];
|
||||
final List<ext.Track> audioTracks = [];
|
||||
ClosedCaptionFile? _currentCaptionFile;
|
||||
@@ -178,6 +180,11 @@ class VideoService {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool setPreventSleep(bool preventSleep) {
|
||||
WakelockPlus.enable();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool updateTexture() {
|
||||
_player.updateTexture();
|
||||
return true;
|
||||
@@ -207,8 +214,8 @@ class VideoService {
|
||||
}
|
||||
void _configurePlayer() {
|
||||
_player.setProperty(
|
||||
'avformat.protocol_whitelist',
|
||||
'file,http,https,tcp,tls,udp,rtp,rtmp,rtmpe,rtmps,rtmpt,rtmpte,crypto,data',
|
||||
'avio.protocol_whitelist',
|
||||
'file,ftp,rtmp,http,https,tls,rtp,tcp,udp,crypto,httpproxy,data,concatf,concat,subfile'
|
||||
);
|
||||
_player.setProperty('video.decoder', 'shader_resource=0');
|
||||
_player.setProperty('avformat.strict', 'experimental');
|
||||
|
||||
@@ -43,29 +43,6 @@ void main() async {
|
||||
windowManager.focus();
|
||||
windowManager.setPreventClose(true);
|
||||
});
|
||||
// Setup Video Player
|
||||
if (Platform.isWindows) {
|
||||
fvp.registerWith(
|
||||
options: {
|
||||
'platforms': ['windows'],
|
||||
'video.decoders': ['MFT:d3d=11', 'CUDA', 'DXVA', 'FFmpeg'],
|
||||
},
|
||||
);
|
||||
} else if (Platform.isMacOS) {
|
||||
fvp.registerWith(
|
||||
options: {
|
||||
'platforms': ['macos'],
|
||||
'video.decoders': ['VT', 'FFmpeg'],
|
||||
},
|
||||
);
|
||||
} else if (Platform.isLinux) {
|
||||
fvp.registerWith(
|
||||
options: {
|
||||
'platforms': ['linux'],
|
||||
'video.decoders': ['VAAPI', 'CUDA', 'VDPAU', 'FFmpeg'],
|
||||
},
|
||||
);
|
||||
}
|
||||
//Run Flutter app with localization and screen utilities
|
||||
runApp(
|
||||
EasyLocalization(
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:unyo/core/services/video/video_service.dart';
|
||||
|
||||
class UnyoVideoTexture extends StatefulWidget {
|
||||
final VideoService videoService;
|
||||
|
||||
const UnyoVideoTexture({super.key, required this.videoService});
|
||||
|
||||
@override
|
||||
@@ -11,10 +12,13 @@ class UnyoVideoTexture extends StatefulWidget {
|
||||
|
||||
class _UnyoVideoTextureState extends State<UnyoVideoTexture> {
|
||||
late VideoService _videoService;
|
||||
late double aspectRatio;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_videoService = widget.videoService;
|
||||
aspectRatio = _videoService.aspectRatio;
|
||||
_videoService.updateTexture();
|
||||
}
|
||||
|
||||
@@ -26,15 +30,16 @@ class _UnyoVideoTextureState extends State<UnyoVideoTexture> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ValueListenableBuilder<int?>(
|
||||
valueListenable: _videoService.textureId,
|
||||
builder: (context, id, _) => id == null ? const SizedBox.shrink() : Texture(textureId: id),
|
||||
),
|
||||
),
|
||||
],
|
||||
return Center(
|
||||
child: ValueListenableBuilder<int?>(
|
||||
valueListenable: _videoService.textureId,
|
||||
builder: (context, id, _) => id == null
|
||||
? const SizedBox.shrink()
|
||||
: AspectRatio(
|
||||
aspectRatio: aspectRatio,
|
||||
child: Texture(textureId: id),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,25 @@ import Foundation
|
||||
import bonsoir_darwin
|
||||
import dynamic_color
|
||||
import fvp
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import screen_retriever_macos
|
||||
import shared_preferences_foundation
|
||||
import url_launcher_macos
|
||||
import video_player_avfoundation
|
||||
import wakelock_plus
|
||||
import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
SwiftBonsoirPlugin.register(with: registry.registrar(forPlugin: "SwiftBonsoirPlugin"))
|
||||
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
||||
FvpPlugin.register(with: registry.registrar(forPlugin: "FvpPlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
||||
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
|
||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||
}
|
||||
|
||||
16
pubspec.yaml
16
pubspec.yaml
@@ -6,8 +6,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: ">=3.9.0"
|
||||
flutter: ">=3.35.1"
|
||||
sdk: ">=3.10.0"
|
||||
flutter: ">=3.38.1"
|
||||
|
||||
# List your package dependencies below. Run `flutter pub outdated` to check for updates.
|
||||
dependencies:
|
||||
@@ -67,10 +67,11 @@ dependencies:
|
||||
# FFI/Native Integration
|
||||
system_info3: ^4.0.2
|
||||
jni: ^0.14.2
|
||||
meta: ^1.16.0
|
||||
meta: ^1.17.0
|
||||
jwt_decoder: ^2.0.1
|
||||
k3vinb5_aniyomi_bridge:
|
||||
path: ../k3vinb5_aniyomi_bridge
|
||||
wakelock_plus: ^1.4.0
|
||||
|
||||
# Dev dependencies
|
||||
dev_dependencies:
|
||||
@@ -81,20 +82,11 @@ dev_dependencies:
|
||||
bloc_lint: ^0.3.5
|
||||
# Testing
|
||||
bloc_test: ^10.0.0
|
||||
test: 1.26.0
|
||||
# Code generation
|
||||
hive_ce_generator: ^1.9.2
|
||||
json_serializable: ^6.9.5
|
||||
build_runner: ^2.10.4
|
||||
|
||||
dependency_overrides:
|
||||
# Align with Flutter 3.35 (Dart 3.9) toolchain and flutter_test's test_api/matcher
|
||||
analyzer: 8.4.1
|
||||
_fe_analyzer_shared: 91.0.0
|
||||
matcher: 0.12.17
|
||||
test_api: 0.7.6
|
||||
test: 1.26.0
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
# The following line ensures the Material Icons font is included so you can use the material Icons class.
|
||||
|
||||
Reference in New Issue
Block a user