@@ -66,7 +66,7 @@ public class MainPlayer : MpvClient
6666 public event Action < int > ? PlaylistPosChanged ;
6767 public event Action < Size > ? VideoSizeChanged ;
6868
69- public void Init ( IntPtr formHandle , bool processCommandLineArguments = true )
69+ public void Init ( IntPtr formHandle , bool processCommandLine )
7070 {
7171 App . ApplyShowMenuFix ( ) ;
7272
@@ -93,7 +93,10 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
9393 }
9494
9595 if ( formHandle != IntPtr . Zero )
96+ {
97+ SetPropertyString ( "force-window" , "yes" ) ;
9698 SetPropertyLong ( "wid" , formHandle . ToInt64 ( ) ) ;
99+ }
97100
98101 SetPropertyInt ( "osd-duration" , 2000 ) ;
99102
@@ -104,7 +107,6 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
104107 SetPropertyString ( "screenshot-directory" , "~~desktop/" ) ;
105108 SetPropertyString ( "osd-playing-msg" , "${media-title}" ) ;
106109 SetPropertyString ( "osc" , "yes" ) ;
107- SetPropertyString ( "force-window" , "yes" ) ;
108110 SetPropertyString ( "config-dir" , ConfigFolder ) ;
109111 SetPropertyString ( "config" , "yes" ) ;
110112
@@ -113,8 +115,8 @@ public void Init(IntPtr formHandle, bool processCommandLineArguments = true)
113115 if ( ! string . IsNullOrEmpty ( UsedInputConfContent ) )
114116 SetPropertyString ( "input-conf" , @"memory://" + UsedInputConfContent ) ;
115117
116- if ( processCommandLineArguments )
117- ProcessCommandLineArgs ( ) ;
118+ if ( processCommandLine )
119+ CommandLine . ProcessCommandLineArgsPreInit ( ) ;
118120
119121 if ( CommandLine . Contains ( "config-dir" ) )
120122 {
@@ -415,67 +417,6 @@ void ProcessBluRayLogMessage(string msg)
415417
416418 public void SetBluRayTitle ( int id ) => LoadFiles ( new [ ] { @"bd://" + id } , false , false ) ;
417419
418- public void ProcessCommandLineArgs ( )
419- {
420- foreach ( var pair in CommandLine . Arguments )
421- {
422- if ( pair . Name . EndsWith ( "-add" ) ||
423- pair . Name . EndsWith ( "-set" ) ||
424- pair . Name . EndsWith ( "-pre" ) ||
425- pair . Name . EndsWith ( "-clr" ) ||
426- pair . Name . EndsWith ( "-append" ) ||
427- pair . Name . EndsWith ( "-remove" ) ||
428- pair . Name . EndsWith ( "-toggle" ) )
429-
430- continue ;
431-
432- ProcessProperty ( pair . Name , pair . Value ) ;
433-
434- if ( ! App . ProcessProperty ( pair . Name , pair . Value ) )
435- SetPropertyString ( pair . Name , pair . Value ) ;
436- }
437- }
438-
439- public void ProcessCommandLineArgsPost ( )
440- {
441- foreach ( var pair in CommandLine . Arguments )
442- {
443- if ( pair . Name . EndsWith ( "-add" ) )
444- CommandV ( "change-list" , pair . Name [ ..^ 4 ] , "add" , pair . Value ) ;
445- else if ( pair . Name . EndsWith ( "-set" ) )
446- CommandV ( "change-list" , pair . Name [ ..^ 4 ] , "set" , pair . Value ) ;
447- else if ( pair . Name . EndsWith ( "-append" ) )
448- CommandV ( "change-list" , pair . Name [ ..^ 7 ] , "append" , pair . Value ) ;
449- else if ( pair . Name . EndsWith ( "-pre" ) )
450- CommandV ( "change-list" , pair . Name [ ..^ 4 ] , "pre" , pair . Value ) ;
451- else if ( pair . Name . EndsWith ( "-clr" ) )
452- CommandV ( "change-list" , pair . Name [ ..^ 4 ] , "clr" , "" ) ;
453- else if ( pair . Name . EndsWith ( "-remove" ) )
454- CommandV ( "change-list" , pair . Name [ ..^ 7 ] , "remove" , pair . Value ) ;
455- else if ( pair . Name . EndsWith ( "-toggle" ) )
456- CommandV ( "change-list" , pair . Name [ ..^ 7 ] , "toggle" , pair . Value ) ;
457- }
458- }
459-
460- public void ProcessCommandLineFiles ( )
461- {
462- List < string > files = new List < string > ( ) ;
463-
464- foreach ( string arg in Environment . GetCommandLineArgs ( ) . Skip ( 1 ) )
465- if ( ! arg . StartsWith ( "--" ) && ( arg == "-" || arg . Contains ( "://" ) ||
466- arg . Contains ( ":\\ " ) || arg . StartsWith ( "\\ \\ " ) || File . Exists ( arg ) ) )
467-
468- files . Add ( arg ) ;
469-
470- LoadFiles ( files . ToArray ( ) , ! App . Queue , App . Queue ) ;
471-
472- if ( App . CommandLine . Contains ( "--shuffle" ) )
473- {
474- Command ( "playlist-shuffle" ) ;
475- SetPropertyInt ( "playlist-pos" , 0 ) ;
476- }
477- }
478-
479420 public DateTime LastLoad ;
480421
481422 public void LoadFiles ( string [ ] ? files , bool loadFolder , bool append )
0 commit comments