예제 #1
0
        static void Main(string[] args)
        {
            Options options = new Options();

            try
            {
                options.Load(args);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            catch (NotSupportedException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            MediaFile[] files = MediaFileScanner.GetFromFolder(System.IO.Directory.GetCurrentDirectory(), options.Filter,
                                                               options.Extensions.ToArray());
            if (files.Length == 0)
            {
                MessageBox.Show("No files to play");
                return;
            }

            IMediaFileIterator mediaFiles = createIterator(options, files);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            PlayerOptions playerOptions = new PlayerOptions(options.AutoNext);
            var           playerWindow  = new PlayerWindow(mediaFiles, playerOptions);

            playerWindow.OnMediaSkipped += new OnMediaSkippedDelegate(playerWindow_OnMediaSkipped);
            if (options.DeleteAfterWatch)
            {
                playerWindow.OnMediaEnded += new OnMediaEndedDelegate(playerWindow_OnMediaEnded);
            }
            Application.Run(playerWindow);
        }
예제 #2
0
        public PlayerWindow(IMediaFileIterator files, PlayerOptions options)
        {
            mOptions       = options;
            mFiles         = files;
            mFilesIterator = mFiles.GetEnumerator();
            InitializeComponent();

            var playerPath = Application.StartupPath;

            mPlayerFactory    = new MediaPlayerFactory(playerPath);
            mPlayer           = mPlayerFactory.CreatePlayer <IDiskPlayer>();
            mPlayerController = new PlayerController(mPlayer, mPlayerFactory);

            mPlayer.Events.MediaEnded    += new EventHandler(Events_MediaEnded);
            mPlayer.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);
            mPlayer.Events.PlayerPaused  += new EventHandler(Events_PlayerPaused);
            mPlayer.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);

            mPlayer.WindowHandle    = Handle;
            mPlayer.KeyInputEnabled = false;

            KeyDown += new KeyEventHandler(playerWindow_KeyDown);
        }