Exemplo n.º 1
0
 public void AddVideosFromDirectory(string path, bool recursive = true)
 {
     foreach (Video v in VideoMgr.GetVideosFromDirectory(path, recursive))
     {
         Videos.Add(v);
     }
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.FileName = "";
            ofd.Filter   = VideoMgr.GetAllowedFiletypesSelector();
            if (ofd.ShowDialog() != true)
            {
                return;
            }

            player.SetMediaFile(ofd.FileName);                  // TODO player event media changed -> setmediafile, volume, etc.
        }
Exemplo n.º 3
0
        private void btnAddFile_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.Multiselect = true;
            if (Directory.Exists(Properties.Settings.Default.VideoDir))
            {
                ofd.InitialDirectory = Properties.Settings.Default.VideoDir;
            }
            ofd.CheckFileExists = true;
            ofd.Filter          = VideoMgr.GetAllowedFiletypesSelector();
            bool?res = ofd.ShowDialog();

            if (res.HasValue && res.Value)
            {
                Playlist.ActivePlaylist.AddVideos(ofd.FileNames);
            }
        }
Exemplo n.º 4
0
        private void mainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // AppData folder
            Properties.Settings.Default.AppDataFolder =
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                System.IO.Path.DirectorySeparatorChar + Properties.Settings.Default.GeneralProductName;
#if DEBUG
            Properties.Settings.Default.AppDataFolder =
                @"C:\Users\Franz\Documents\codeprojects\VideoManager\VideoManager\local";
#endif
            Properties.Settings.Default.ConnectionString = "data source=\"" +
                                                           Properties.Settings.Default.AppDataFolder + System.IO.Path.DirectorySeparatorChar +
                                                           Properties.Settings.Default.DatabaseFilename + "\"";

            //Database.FillFromDirectory(@"C:\Users\Franz\Documents\codeprojects\VideoManager\VideoManager\local\test", false);


            // init windows
            settingsWindow = new SettingsWindow();


            // init libraries
            if (!VideoMgr.InitLibraryPath())
            {
                MessageBox.Show("DLLs not found. Please enter the path to your VLC libraries!");
                settingsWindow.ShowDialog();
            }

            if (VideoMgr.InitLibraryPath())
            {
                Utils.SetDllDirectory(Properties.Settings.Default.LibraryPath);
            }
            else
            {
                MessageBox.Show("DLLs still not found. Exiting...");
                Application.Current.Shutdown();
                return;
            }

            string pluginPath = Environment.GetEnvironmentVariable("VLC_PLUGIN_PATH");
            if (pluginPath == null)
            {
                MessageBox.Show("You have to set the environment variable VLC_PLUGIN_PATH to " +
                                Properties.Settings.Default.LibraryPath + " and restart " +
                                Properties.Settings.Default.GeneralProductName + "!");
                Application.Current.Shutdown();
                return;
            }


            // restore old window state
            if (Properties.Settings.Default.WindowWidth > 0 && Properties.Settings.Default.WindowHeight > 0)
            {
                this.Width  = Properties.Settings.Default.WindowWidth;
                this.Height = Properties.Settings.Default.WindowHeight;
                if (Properties.Settings.Default.WasMaximized)
                {
                    this.WindowState = System.Windows.WindowState.Maximized;
                }
                this.Left = Properties.Settings.Default.WindowLeft;
                this.Top  = Properties.Settings.Default.WindowTop;
                double plWidth = Properties.Settings.Default.PlaylistWidth;
                this.mainGrid.ColumnDefinitions[2].Width =
                    new GridLength(this.mainGrid.ActualWidth - this.gridSplitter.ActualWidth - plWidth);
                this.mainGrid.ColumnDefinitions[0].Width = new GridLength(plWidth);
            }


            // init VLC
            player = new VlcMediaPlayer();

            player.Drawable = wfh.Child.Handle;

            player.PlayingStatusChanged += new VlcMediaPlayer.PlayingStatusChangedHandler(PlayingStatusChanged);
            player.LengthChanged        += new VlcMediaPlayer.LengthChangedHandler(LengthChanged);
            player.PositionChanged      += new VlcMediaPlayer.PositionChangedHandler(PositionChanged);
            player.TimeChanged          += new VlcMediaPlayer.TimeChangedHandler(TimeChanged);

            player.SetVolume(sliVolume.Value);


            // init input
            EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyDownEvent, new KeyEventHandler(keyDown), false);


            // init UI
            sliVolume.Value = Properties.Settings.Default.Volume;


            // init database
            if (!Page.LoadPagesFromDatabase() || Page.GetDefaultPage() == null)
            {
                Page p = new Page(null, "YouTube", "http://youtube.com/", "YT");
                p.SaveToDatabase();
                if (p.ID.HasValue)
                {
                    Properties.Settings.Default.DefaultPageId = p.ID.Value;
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Default Page didn't receive an ID!");
                }
            }

            // init playlist
            Playlist.ActivePlaylist = new Playlist();
            dgPlaylist.ItemsSource  = Playlist.ActivePlaylist.Videos;
        }