Skip to content

Commit

Permalink
Feat: external player
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Aug 29, 2023
1 parent 4fd068f commit c38df32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
5 changes: 1 addition & 4 deletions lib/pages/settings/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,12 @@ class _SettingsPageState extends State<SettingsPage> {
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",
};
}(),
Expand Down
19 changes: 6 additions & 13 deletions lib/utils/external_player.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:android_intent_plus/android_intent.dart';
import 'package:url_launcher/url_launcher_string.dart';

Expand All @@ -6,18 +8,11 @@ Future<void> 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;
}
Expand All @@ -27,10 +22,8 @@ Future<void> launchMobileExternalPlayer(String playUrl, String player) async {
Future<void> 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");
Expand Down

0 comments on commit c38df32

Please sign in to comment.