From c38df32e00b74feb99eb71cc0eec8c4160603bd6 Mon Sep 17 00:00:00 2001 From: MiaoMint <1981324730@qq.com> Date: Tue, 29 Aug 2023 11:01:46 +0800 Subject: [PATCH] Feat: external player --- lib/pages/settings/view.dart | 5 +---- lib/utils/external_player.dart | 19 ++++++------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/pages/settings/view.dart b/lib/pages/settings/view.dart index b274b9c5..aab2d11d 100644 --- a/lib/pages/settings/view.dart +++ b/lib/pages/settings/view.dart @@ -215,15 +215,12 @@ class _SettingsPageState extends State { return { "settings.external-player-builtin".i18n: "built-in", "VLC": "vlc", - "MXPlayer": "mxplayer", - "NPlayer": "nplayer", - "MPV": "mpv", + "Other": "other", }; } return { "settings.external-player-builtin".i18n: "built-in", "VLC": "vlc", - "MPV": "mpv", "PotPlayer": "potplayer", }; }(), diff --git a/lib/utils/external_player.dart b/lib/utils/external_player.dart index c4502931..45c5b609 100644 --- a/lib/utils/external_player.dart +++ b/lib/utils/external_player.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:android_intent_plus/android_intent.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -6,18 +8,11 @@ Future launchMobileExternalPlayer(String playUrl, String player) async { case "vlc": await _launchExternalPlayer("vlc://$playUrl"); break; - case "mxplayer": - await AndroidIntent( - action: 'action_view', - data: playUrl, - package: 'com.mxtech.videoplayer.ad', - ).launch(); - break; - case "mpv": + case "other": await AndroidIntent( action: 'action_view', data: playUrl, - package: 'is.xyz.mpv', + type: 'video/*', ).launch(); break; } @@ -27,10 +22,8 @@ Future launchMobileExternalPlayer(String playUrl, String player) async { Future launchDesktopExternalPlayer(String playUrl, String player) async { switch (player) { case "vlc": - await _launchExternalPlayer("vlc://$playUrl"); - break; - case "mpv": - await _launchExternalPlayer("mpv://$playUrl"); + const vlc = 'C:\\Program Files\\VideoLAN\\VLC\\vlc.exe'; + await Process.run(vlc, [playUrl]); break; case "potplayer": await _launchExternalPlayer("potplayer://$playUrl");