Example #1
0
        public static MediaFile OpenFile(object parent)
        {
            MediaFile          mediaFile;
            IGUIToolkit        gui        = Config.GUIToolkit;
            IMultimediaToolkit multimedia = Config.MultimediaToolkit;
            string             filename;

            filename = gui.OpenFile(Catalog.GetString("Open file"), null, null);
            if (filename == null)
            {
                return(null);
            }

            mediaFile = DiscoverFile(filename, parent);
            if (mediaFile != null)
            {
                try {
                    if (multimedia.FileNeedsRemux(mediaFile))
                    {
                        if (!Config.SupportsFullHD)
                        {
                            string msg = Catalog.GetString("This file is not in a supported format, " +
                                                           "convert it with the video conversion tool");
                            throw new Exception(msg);
                        }
                        else
                        {
                            string q = Catalog.GetString("This file needs to be converted into a more suitable format." +
                                                         "(This step will only take a few minutes)");
                            if (gui.QuestionMessage(q, null, parent))
                            {
                                string newFilename = multimedia.RemuxFile(mediaFile, parent);
                                if (newFilename != null)
                                {
                                    mediaFile = multimedia.DiscoverFile(newFilename);
                                }
                                else
                                {
                                    mediaFile = null;
                                }
                            }
                            else
                            {
                                mediaFile = null;
                            }
                        }
                    }
                } catch (Exception ex) {
                    gui.ErrorMessage(ex.Message, parent);
                    mediaFile = null;
                }
            }
            return(mediaFile);
        }
Example #2
0
        public static MediaFile OpenFile(object parent)
        {
            MediaFile          mediaFile;
            IGUIToolkit        gui        = App.Current.GUIToolkit;
            IMultimediaToolkit multimedia = App.Current.MultimediaToolkit;
            string             filename;

            filename = App.Current.Dialogs.OpenFile(Catalog.GetString("Open file"), null, null);
            if (filename == null)
            {
                return(null);
            }

            mediaFile = DiscoverFile(filename, parent);
            if (mediaFile != null)
            {
                try {
                    if (multimedia.FileNeedsRemux(mediaFile))
                    {
                        string q = Catalog.GetString("This file needs to be converted into a more suitable format." +
                                                     "(This step will only take a few minutes)");
                        if (App.Current.Dialogs.QuestionMessage(q, null, parent).Result)
                        {
                            string newFilename = multimedia.RemuxFile(mediaFile, parent);
                            if (newFilename != null)
                            {
                                mediaFile = multimedia.DiscoverFile(newFilename);
                            }
                            else
                            {
                                mediaFile = null;
                            }
                        }
                        else
                        {
                            mediaFile = null;
                        }
                    }
                } catch (Exception ex) {
                    App.Current.Dialogs.ErrorMessage(ex.Message, parent);
                    mediaFile = null;
                }
            }
            return(mediaFile);
        }