Exemplo n.º 1
0
        // ASync method to avoid mediaportal video treatment sleep
        public void loadPlayingPresetASync(AnimeEpisodeVM curEpisode, string fileName)
        {
            // Create an instance of the FFDShowHelper class.
            FFDShowHelper ffdshowHelper = new FFDShowHelper();
            // Create the delegate.
            AsyncloadPlayingPresetCaller caller = new AsyncloadPlayingPresetCaller(loadPlayingPreset);
            // Initiate the asychronous call.
            IAsyncResult result = caller.BeginInvoke(curEpisode, fileName, null, null);

            Thread.Sleep(0);
            debug("Main thread " + Thread.CurrentThread.ManagedThreadId + " does some work.");
            // Call EndInvoke to wait for the asynchronous call to complete,
            // and to retrieve the results.
            //            string returnValue = caller.EndInvoke(result);
            //            caller.EndInvoke(result);
        }
 // ASync method to avoid mediaportal video treatment sleep
 public void loadPlayingPresetASync(AnimeEpisodeVM curEpisode, string fileName)
 {
     // Create an instance of the FFDShowHelper class.
     FFDShowHelper ffdshowHelper = new FFDShowHelper();
     // Create the delegate.
     AsyncloadPlayingPresetCaller caller = new AsyncloadPlayingPresetCaller(loadPlayingPreset);
     // Initiate the asychronous call.
     IAsyncResult result = caller.BeginInvoke(curEpisode, fileName, null, null);
     Thread.Sleep(0);
     debug("Main thread " + Thread.CurrentThread.ManagedThreadId + " does some work.");
     // Call EndInvoke to wait for the asynchronous call to complete,
     // and to retrieve the results.
     //            string returnValue = caller.EndInvoke(result);
     //            caller.EndInvoke(result);
 }
Exemplo n.º 3
0
        void OnPlayBackStarted(MediaPortal.Player.g_Player.MediaType type, string filename)
        {
            if (PlayBackOpIsOfConcern(type, filename))
            {
                LogPlayBackOp("started", filename);

                // really stupid, you have to wait until the player itself sets the properties (a few seconds) and after that set them
                w.RunWorkerAsync(false);

                // ffdshow preset auto loading
                FFDShowHelper ffdshowHelper = new FFDShowHelper();
                // ASync call to avoid mediaportal video treatment sleep
                ffdshowHelper.loadPlayingPresetASync(curEpisode, filename);
            }
        }
Exemplo n.º 4
0
        private bool ShowContextMenuPostProcessing(string previousMenu)
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            if (dlg == null)
                return true;

            GUIListItem currentitem = this.m_Facade.SelectedListItem;
            if (currentitem == null)
                return true;

            AnimeGroupVM grp = currentitem.TVTag as AnimeGroupVM;
            List<AnimeEpisodeVM> episodes = new List<AnimeEpisodeVM>();
            if (grp == null)
            {
                AnimeSeriesVM ser = currentitem.TVTag as AnimeSeriesVM;
                if (ser == null)
                {
                    AnimeEpisodeVM ep = currentitem.TVTag as AnimeEpisodeVM;
                    episodes.Add(ep);
                }
                else
                {
                    foreach (AnimeEpisodeVM ep in ser.AllEpisodes)
                    {
                        episodes.Add(ep);
                    }
                }
            }
            else
            {
                List<AnimeSeriesVM> seriesList = grp.AllSeries;
                foreach (AnimeSeriesVM ser in seriesList)
                {
                    foreach (AnimeEpisodeVM ep in ser.AllEpisodes)
                    {
                        episodes.Add(ep);
                    }
                }

            }

            if (episodes == null)
                return true;

            //keep showing the dialog until the user closes it
            string currentMenu = "Associate with a ffdshow raw preset";
            int selectedLabel = 0;
            int intLabel = 0;

            FFDShowHelper ffdshowHelper = new FFDShowHelper();
            List<string> presets = ffdshowHelper.Presets;

            string selectedPreset = ffdshowHelper.findSelectedPresetForMenu(episodes);

            while (true)
            {
                dlg.Reset();
                dlg.SetHeading(currentMenu);

                if (previousMenu != string.Empty)
                {
                    dlg.Add("<<< " + previousMenu);
                    intLabel++;
                }

                dlg.Add("Remove old preset association");
                intLabel++;
                foreach (string preset in presets)
                {
                    dlg.Add("Set preset: " + preset);
                    // preset selected
                    if (selectedPreset == preset)
                        selectedLabel = intLabel;

                    intLabel++;
                }

                dlg.SelectedLabel = selectedLabel;
                dlg.DoModal(GUIWindowManager.ActiveWindow);
                selectedLabel = dlg.SelectedLabel;

                int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0);

                if (selection == 0)
                {
                    //show previous
                    return true;
                }
                else if (selection == -1)
                {
                    //close menu
                    return false;
                }
                else
                {
                    string message = "";
                    if (selection == 1)
                    {
                        //DB remove preset
                        ffdshowHelper.deletePreset(episodes);
                        message = "Old preset successfully removed.";
                    }
                    else
                    {
                        //DB associate serie/group with preset
                        string choosenPreset = presets.ToArray()[selection - 2];
                        ffdshowHelper.addPreset(episodes, choosenPreset);
                        message = "Preset \"" + choosenPreset + "\" successfully added.";
                    }
                    Utils.DialogMsg("Confirmation", message);
                    return false;
                }
            }
        }
        private ContextMenuAction ShowContextMenuPostProcessing(string previousMenu)
        {
            GUIListItem currentitem = m_Facade.SelectedListItem;
              if (currentitem == null)
            return ContextMenuAction.Exit;

              AnimeGroupVM grp = currentitem.TVTag as AnimeGroupVM;
              List<AnimeEpisodeVM> episodes = new List<AnimeEpisodeVM>();
              if (grp == null)
              {
            AnimeSeriesVM ser = currentitem.TVTag as AnimeSeriesVM;
            if (ser == null)
            {
              AnimeEpisodeVM ep = currentitem.TVTag as AnimeEpisodeVM;
              episodes.Add(ep);
            }
            else
            {
              foreach (AnimeEpisodeVM ep in ser.AllEpisodes)
              {
            episodes.Add(ep);
              }
            }
              }
              else
              {
            List<AnimeSeriesVM> seriesList = grp.AllSeries;
            foreach (AnimeSeriesVM ser in seriesList)
            {
              foreach (AnimeEpisodeVM ep in ser.AllEpisodes)
              {
            episodes.Add(ep);
              }
            }

              }

              //keep showing the dialog until the user closes it
              string currentMenu = "Associate with a ffdshow raw preset";
              int selectedLabel = 0;
              int intLabel = 0;

              FFDShowHelper ffdshowHelper = new FFDShowHelper();
              List<string> presets = ffdshowHelper.Presets;

              string selectedPreset = ffdshowHelper.findSelectedPresetForMenu(episodes);

              ContextMenu cmenu = new ContextMenu(Translation.AssociateFFDshowPreset, previousmenu: previousMenu);
              cmenu.AddAction(Translation.RemoveOldPresetAssociation, () =>
              {
            ffdshowHelper.deletePreset(episodes);
            Utils.DialogMsg(Translation.Confirmation, Translation.OldPresetRemove);
              });
              foreach (string preset in presets)
              {
            string local = preset;
            cmenu.AddAction(Translation.SetPreset + ": " + preset, () =>
            {
              ffdshowHelper.addPreset(episodes, local);
              Utils.DialogMsg(Translation.Confirmation, string.Format(Translation.PresetAdded, local));
            }, local == selectedPreset);
              }
              return cmenu.Show();
        }