コード例 #1
0
        public static MediaFile DiscoverFile(string filename, object parent)
        {
            MediaFile   mediaFile = null;
            IBusyDialog busy      = null;

            try {
                Exception ex = null;
                busy = Config.GUIToolkit.BusyDialog(Catalog.GetString("Analyzing video file:") + "\n" +
                                                    filename, parent);
                Task task = new Task(() => {
                    try {
                        mediaFile = Config.MultimediaToolkit.DiscoverFile(filename);
                    } catch (Exception e) {
                        ex = e;
                    }
                    Config.GUIToolkit.Invoke(delegate {
                        busy.Destroy();
                    });
                });
                task.Start();
                busy.ShowSync();

                if (ex != null)
                {
                    throw ex;
                }
                else if (mediaFile == null)
                {
                    throw new Exception(Catalog.GetString("Timeout parsing file."));
                }
                else if (!mediaFile.HasVideo || mediaFile.VideoCodec == "")
                {
                    throw new Exception(Catalog.GetString("This file doesn't contain a video stream."));
                }
                else if (mediaFile.HasVideo && mediaFile.Duration.MSeconds == 0)
                {
                    throw new Exception(Catalog.GetString("This file contains a video stream but its length is 0."));
                }
            } catch (Exception ex) {
                busy.Destroy();
                Config.GUIToolkit.ErrorMessage(ex.Message, parent);
                return(null);
            }
            return(mediaFile);
        }
コード例 #2
0
        public static MediaFile DiscoverFile(string filename, object parent)
        {
            MediaFile   mediaFile = null;
            IBusyDialog busy      = null;

            try {
                Exception ex = null;
                busy = App.Current.Dialogs.BusyDialog(Catalog.GetString("Analyzing video file:") + "\n" +
                                                      filename, parent);
                System.Action action = () => {
                    try {
                        mediaFile = App.Current.MultimediaToolkit.DiscoverFile(filename);
                    } catch (Exception e) {
                        ex = e;
                    }
                };
                busy.ShowSync(action);

                if (ex != null)
                {
                    throw ex;
                }
                else if (mediaFile == null)
                {
                    throw new Exception(Catalog.GetString("Timeout parsing file."));
                }
                else if (!mediaFile.HasVideo || mediaFile.VideoCodec == "")
                {
                    throw new Exception(Catalog.GetString("This file doesn't contain a video stream."));
                }
                else if (mediaFile.HasVideo && mediaFile.Duration.MSeconds == 0)
                {
                    throw new Exception(Catalog.GetString("This file contains a video stream but its length is 0."));
                }
            } catch (Exception ex) {
                busy.Destroy();
                App.Current.Dialogs.ErrorMessage(ex.Message, parent);
                return(null);
            }
            return(mediaFile);
        }
コード例 #3
0
        void HandleRescanClicked(object sender, EventArgs e)
        {
            IDatabase db = SelectedDB;

            if (db != null)
            {
                IBusyDialog busy = Config.GUIToolkit.BusyDialog(Catalog.GetString("Scanning database..."), this);
                Task        task = new Task(() => {
                    try {
                        db.Reload();
                    } catch (Exception ex) {
                        Log.Exception(ex);
                    }
                    Config.GUIToolkit.Invoke(delegate {
                        busy.Destroy();
                    });
                });
                task.Start();
                busy.ShowSync();
                Config.GUIToolkit.InfoMessage(Catalog.GetString("Database scanned succesfully."));
            }
        }