Example #1
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);

            if (control == btnSavedPlaylists)
            {
                OnShowSavedPlaylists(m_strPlayListPath);
            }

            if (control == btnPlayDVD)
            {
                ISelectDVDHandler selectDVDHandler;
                if (GlobalServiceProvider.IsRegistered <ISelectDVDHandler>())
                {
                    selectDVDHandler = GlobalServiceProvider.Get <ISelectDVDHandler>();
                }
                else
                {
                    selectDVDHandler = new SelectDVDHandler();
                    GlobalServiceProvider.Add <ISelectDVDHandler>(selectDVDHandler);
                }
                string dvdToPlay = selectDVDHandler.ShowSelectDVDDialog(GetID);
                if (dvdToPlay != null)
                {
                    OnPlayDVD(dvdToPlay, GetID);
                }
                return;
            }
        }
        protected void OnPlayDVD(String drive, int parentId)
        {
            ISelectDVDHandler selectDVDHandler;

            if (GlobalServiceProvider.IsRegistered <ISelectDVDHandler>())
            {
                selectDVDHandler = GlobalServiceProvider.Get <ISelectDVDHandler>();
            }
            else
            {
                selectDVDHandler = new SelectDVDHandler();
                GlobalServiceProvider.Add <ISelectDVDHandler>(selectDVDHandler);
            }
            selectDVDHandler.OnPlayDVD(drive, GetID);
        }
Example #3
0
        public override bool OnMessage(GUIMessage message)
        {
            Log.Info("DVDFullscreen: Message: {0}", message.Message.ToString());
            if (message.Message == GUIMessage.MessageType.GUI_MSG_WINDOW_INIT)
            {
                if (!bINIT_from_MyVideosFullScreen)
                {
                    //if viz is on, this hides the DVD select dialog: GUIWindowManager.ReplaceWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
                    ISelectDVDHandler selectDVDHandler;
                    if (GlobalServiceProvider.IsRegistered <ISelectDVDHandler>())
                    {
                        selectDVDHandler = GlobalServiceProvider.Get <ISelectDVDHandler>();
                    }
                    else
                    {
                        selectDVDHandler = new SelectDVDHandler();
                        GlobalServiceProvider.Add <ISelectDVDHandler>(selectDVDHandler);
                    }

                    string dvdToPlay = selectDVDHandler.ShowSelectDVDDialog(GetID);
                    if (dvdToPlay == null || !selectDVDHandler.OnPlayDVD(dvdToPlay, GetID))
                    {
                        Log.Info("DVDFullscreen: Returning from DVD screen");
                        GUIWindowManager.ShowPreviousWindow();

                        /*GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, this.GetID, 0, 0, GetID, 0, null);
                         * return this.OnMessage(msg);	// Send a de-init msg*/
                    }
                    else
                    {
                        g_Player.ShowFullScreenWindow();
                        bINIT_from_MyVideosFullScreen = true;
                    }
                }
                else
                {
                    bINIT_from_MyVideosFullScreen = false;
                    Log.Info("DVDFullscreen: Returning from DVD screen");
                    GUIWindowManager.ShowPreviousWindow();
                }
                return(true);
            }
            return(base.OnMessage(message));
        }
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);

            if (control == btnSavedPlaylists)
            {
                OnShowSavedPlaylists(m_strPlayListPath);
            }

            if (control == btnPlayDVD)
            {
                ISelectDVDHandler selectDVDHandler;
                if (GlobalServiceProvider.IsRegistered <ISelectDVDHandler>())
                {
                    selectDVDHandler = GlobalServiceProvider.Get <ISelectDVDHandler>();
                }
                else
                {
                    selectDVDHandler = new SelectDVDHandler();
                    GlobalServiceProvider.Add <ISelectDVDHandler>(selectDVDHandler);
                }
                string dvdToPlay = selectDVDHandler.ShowSelectDVDDialog(GetID);
                if (dvdToPlay != null)
                {
                    OnPlayDVD(dvdToPlay, GetID);
                }
                return;
            }

            if (control == btnScanNew)
            {
                // Check Internet connection
                if (!Win32API.IsConnectedToInternet())
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    dlgOk.SetHeading(257);
                    dlgOk.SetLine(1, GUILocalizeStrings.Get(703));
                    dlgOk.DoModal(GUIWindowManager.ActiveWindow);
                    return;
                }

                OnSearchNew();
            }
        }
    public override bool OnMessage(GUIMessage message)
    {
      Log.Info("DVDFullscreen: Message: {0}", message.Message.ToString());
      if (message.Message == GUIMessage.MessageType.GUI_MSG_WINDOW_INIT)
      {
        if (!bINIT_from_MyVideosFullScreen)
        {
          //if viz is on, this hides the DVD select dialog: GUIWindowManager.ReplaceWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
          ISelectDVDHandler selectDVDHandler;
          if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
          {
            selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
          }
          else
          {
            selectDVDHandler = new SelectDVDHandler();
            GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
          }

          string dvdToPlay = selectDVDHandler.ShowSelectDVDDialog(GetID);
          if (dvdToPlay == null || !selectDVDHandler.OnPlayDVD(dvdToPlay, GetID))
          {
            Log.Info("DVDFullscreen: Returning from DVD screen");
            GUIWindowManager.ShowPreviousWindow();
            /*GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, this.GetID, 0, 0, GetID, 0, null);
            return this.OnMessage(msg);	// Send a de-init msg*/
          }
          else
          {
            g_Player.ShowFullScreenWindow();
            bINIT_from_MyVideosFullScreen = true;
          }
        }
        else
        {
          bINIT_from_MyVideosFullScreen = false;
          Log.Info("DVDFullscreen: Returning from DVD screen");
          GUIWindowManager.ShowPreviousWindow();
        }
        return true;
      }
      return base.OnMessage(message);
    }
Example #6
0
    protected override void OnPageLoad()
    {
      GUIWindowManager.ShowPreviousWindow();

      ISelectDVDHandler selectDVDHandler;
      if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
      {
        selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
      }
      else
      {
        selectDVDHandler = new SelectDVDHandler();
        GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
      }

      string dvdToPlay = selectDVDHandler.ShowSelectDriveDialog(GetID, false);
      if (!String.IsNullOrEmpty(dvdToPlay) && !g_Player.CurrentFile.StartsWith(dvdToPlay))
      {
        MediaPortal.Ripper.AutoPlay.ExamineCD(dvdToPlay, true);
      }
    }
Example #7
0
        protected override void OnPageLoad()
        {
            GUIWindowManager.ShowPreviousWindow();

            ISelectDVDHandler selectDVDHandler;

            if (GlobalServiceProvider.IsRegistered <ISelectDVDHandler>())
            {
                selectDVDHandler = GlobalServiceProvider.Get <ISelectDVDHandler>();
            }
            else
            {
                selectDVDHandler = new SelectDVDHandler();
                GlobalServiceProvider.Add <ISelectDVDHandler>(selectDVDHandler);
            }

            string dvdToPlay = selectDVDHandler.ShowSelectDriveDialog(GetID, false);

            if (!String.IsNullOrEmpty(dvdToPlay) && !g_Player.CurrentFile.StartsWith(dvdToPlay))
            {
                MediaPortal.Ripper.AutoPlay.ExamineCD(dvdToPlay, true);
            }
        }
Example #8
0
    protected override void OnShowContextMenu()
    {
      GUIListItem item = facadeLayout.SelectedListItem;
      int itemNo = facadeLayout.SelectedListItemIndex;
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      
      if (dlg == null)
      {
        return;
      }

      dlg.Reset();
      dlg.SetHeading(498); // menu

      if (item == null)
      {
        dlg.AddLocalizedString(868); // Reset virtual directory
      }
      else if (item.IsRemote || (item.IsFolder) && (item.Label == ".."))
      {
        return;
      }
      else
      {
        IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

        if (!facadeLayout.Focus)
        {
          // Menu button context menuu
          if (!_virtualDirectory.IsRemote(_currentFolder))
          {
            dlg.AddLocalizedString(102); //Scan
            dlg.AddLocalizedString(368); //IMDB
          }
        }
        else
        {
          // DVD & files
          if ((Path.GetFileName(item.Path) != string.Empty) || Util.Utils.IsDVD(item.Path))
          {
            // DVD disc drive
            if (Util.Utils.IsDVD(item.Path))
            {
              if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO") ||
                  File.Exists(item.Path + @"\BDMV\index.bdmv"))
              {
                dlg.AddLocalizedString(341); //play
              }
              else
              {
                dlg.AddLocalizedString(926); //Queue
                dlg.AddLocalizedString(102); //Scan
              }

              dlg.AddLocalizedString(368); //IMDB
              dlg.AddLocalizedString(654); //Eject
            }
            // Folder
            else if (item.IsFolder)
            {
              bool useMediaInfo = false;

              if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
              {
                dlg.AddLocalizedString(208); //play
                useMediaInfo = true;
              }

              if (!VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
              {
                // Simple folder
                if (!item.IsBdDvdFolder)
                {
                  dlg.AddLocalizedString(1204); // Play All in selected folder
                  dlg.AddLocalizedString(926); //Queue
                  dlg.AddLocalizedString(102); //Scan 
                  dlg.AddLocalizedString(1280); // Scan using nfo files
                }
                // DVD folder
                else if (item.IsBdDvdFolder)
                {
                  useMediaInfo = true;
                  dlg.AddLocalizedString(208); //play             
                  dlg.AddLocalizedString(926); //Queue
                  dlg.AddLocalizedString(368); //IMDB
                  
                  if (movie != null && !movie.IsEmpty)
                  {
                    if (item.IsPlayed)
                    {
                      {
                        dlg.AddLocalizedString(830); //Reset watched status for DVD folder
                      }
                    }
                    else
                    {
                      dlg.AddLocalizedString(1260); // Set watched status
                    }
                  }
                }
              }

              if (Util.Utils.getDriveType(item.Path) == 5)
              {
                dlg.AddLocalizedString(654); //Eject            
              }

              if (!IsFolderPinProtected(item.Path) && _fileMenuEnabled)
              {
                dlg.AddLocalizedString(500); // FileMenu            
              }

              if (useMediaInfo)
              {
                dlg.AddLocalizedString(1264); //Media info
              }
            }
            else
            {
              dlg.AddLocalizedString(208); //Play
              dlg.AddLocalizedString(926); //Queue
              dlg.AddLocalizedString(368); //IMDB

              if (item.IsPlayed)
              {
                dlg.AddLocalizedString(830); //Reset watched status
              }
              else
              {
                dlg.AddLocalizedString(1260); // Set watched status
              }

              if (!IsFolderPinProtected(item.Path) && !item.IsRemote && _fileMenuEnabled)
              {
                dlg.AddLocalizedString(500); // FileMenu
              }
              dlg.AddLocalizedString(1264); //Media info
            }
          }
          else if (Util.Utils.IsNetwork(item.Path)) // Process network root with drive letter
          {
            dlg.AddLocalizedString(1204); // Play All in selected folder
          }
        }
        if (!_mapSettings.Stack)
        {
          dlg.AddLocalizedString(346); //Stack
        }
        else
        {
          dlg.AddLocalizedString(347); //Unstack
        }
        if (Util.Utils.IsRemovable(item.Path))
        {
          dlg.AddLocalizedString(831);
        }

        dlg.AddLocalizedString(1299); // Refresh current directory
        dlg.AddLocalizedString(1262); // Update grabber scripts
        dlg.AddLocalizedString(1307); // Update internal grabber scripts
        dlg.AddLocalizedString(1263); // Set default grabber
      }

      dlg.DoModal(GetID);

      if (dlg.SelectedId == -1)
      {
        return;
      }
      switch (dlg.SelectedId)
      {
        case 368: // IMDB
          OnInfo(itemNo);
          break;

        case 208: // play
          _playClicked = true;
          OnClick(itemNo);
          break;

        case 926: // add to playlist
          OnQueueItem(itemNo);
          break;

        case 136: // show playlist
          GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_PLAYLIST);
          break;

        case 654: // Eject
          if (Util.Utils.getDriveType(item.Path) != 5)
          {
            Util.Utils.EjectCDROM();
          }
          else
          {
            Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
          }
          LoadDirectory(string.Empty);
          break;

        case 341: //Play dvd
          OnPlayDVD(item.Path, GetID);
          break;

        case 346: //Stack
          _mapSettings.Stack = true;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 347: //Unstack
          _mapSettings.Stack = false;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 102: //Scan
          if (_doNotUseDatabase)
          {
            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
            dlgOk.SetHeading(string.Empty);
            dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);
            return;
          }

          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }

          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          
          int currentIndex = facadeLayout.SelectedListItemIndex;

          if (_useOnlyNfoScraper)
          {
            ArrayList scanNfoFiles = new ArrayList();
            GetNfoFiles(item.Path, ref scanNfoFiles);
            IMDBFetcher scanFetcher = new IMDBFetcher(this);
            scanFetcher.FetchNfo(scanNfoFiles, true, false);
            // Send global message that movie is refreshed/scanned
            GUIMessage scanNfoMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
            GUIWindowManager.SendMessage(scanNfoMsg);
            LoadDirectory(_currentFolder);
            facadeLayout.SelectedListItemIndex = currentIndex;
          }
          else
          {
            ArrayList availablePaths = new ArrayList();
            availablePaths.Add(item.Path);
            IMDBFetcher.ScanIMDB(this, availablePaths, _isFuzzyMatching, _scanSkipExisting, _getActors, false);
            // Send global message that movie is refreshed/scanned
            GUIMessage scanMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
            GUIWindowManager.SendMessage(scanMsg);
            LoadDirectory(_currentFolder);
            facadeLayout.SelectedListItemIndex = currentIndex;
          }
          break;

        case 1280: //Scan using nfo files
          if (_doNotUseDatabase)
          {
            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
            dlgOk.SetHeading(string.Empty);
            dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);
            return;
          }

          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }

          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          
          currentIndex = facadeLayout.SelectedListItemIndex;
          ArrayList nfoFiles = new ArrayList();
          GetNfoFiles(item.Path, ref nfoFiles);
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
          // Send global message that movie is refreshed/scanned
          GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
          GUIWindowManager.SendMessage(msg);
          LoadDirectory(_currentFolder);
          facadeLayout.SelectedListItemIndex = currentIndex;
          break;

        case 830: // Reset watched status
          SetMovieWatchStatus(item.Path, item.IsFolder, false);
          int selectedIndex = facadeLayout.SelectedListItemIndex;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          facadeLayout.SelectedListItemIndex = selectedIndex;
          break;

        case 1260: // Set watched status
          SetMovieWatchStatus(item.Path, item.IsFolder, true);
          selectedIndex = facadeLayout.SelectedListItemIndex;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          facadeLayout.SelectedListItemIndex = selectedIndex;
          break;

        case 500: // File menu
          {
            ShowFileMenu(false);
          }
          break;

        case 831:
          string message;

          if (!RemovableDriveHelper.EjectDrive(item.Path, out message))
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(832));
            pDlgOK.SetLine(2, string.Empty);
            pDlgOK.SetLine(3, message);
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          else
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(833));
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          break;

        case 1204: // Play all
          {
            if (!_virtualDirectory.RequestPin(item.Path))
            {
              return;
            }
            OnPlayAll(item.Path);
          }
          break;

        case 1299: // Refresh current directory
          {
            if (facadeLayout.ListLayout.ListItems.Count > 0 && !string.IsNullOrEmpty(_currentFolder))
            {
              facadeLayout.SelectedListItemIndex = 0;
              LoadDirectory(_currentFolder, false);
            }
          }
          break;

        case 868: // Reset V.directory
          {
            ResetShares();

            if (_virtualDirectory.DefaultShare != null && _virtualDirectory.DefaultShare.Path != string.Empty)
            {
              LoadDirectory(_virtualDirectory.DefaultShare.Path, false);
            }
            else
            {
              LoadDirectory(string.Empty, false);
            }
          }
          break;

        case 1262: // Update grabber scripts
          UpdateGrabberScripts(false);
          break;
        case 1307: // Update internal grabber scripts
          UpdateGrabberScripts(true);
          break;
        case 1263: // Set deault grabber script
          SetDefaultGrabber();
          break;
        case 1264: // Get media info (refresh mediainfo and duration)
          if (item != null)
          {
            string file = item.Path;
            SelectDVDHandler sdh = new SelectDVDHandler();
            SelectBDHandler bdh = new SelectBDHandler();

            if (sdh.IsDvdDirectory(item.Path))
            {
              if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
              {
                file = file + @"\VIDEO_TS\VIDEO_TS.IFO";
              }
            }

            if (bdh.IsBDDirectory(item.Path))
            {
              if (File.Exists(item.Path + @"\BDMV\INDEX.BDMV"))
              {
                file = file + @"\BDMV\INDEX.BDMV";
              }
            }

            ArrayList files = new ArrayList();
            files = AddFileToDatabase(file);
            MovieDuration(files, true);
            int movieId = VideoDatabase.GetMovieId(file);
            IMDBMovie mInfo = new IMDBMovie();
            mInfo.SetMediaInfoProperties(file, true);
            mInfo.SetDurationProperty(movieId);
            IMDBMovie.SetMovieData(item);
            SelectCurrentItem();
          }
          break;
      }
    }
Example #9
0
    private void RefreshMediaInfo(GUIListItem item)
    {
      if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.STOPPING)
      {
        return;
      }
      
      if (item != null)
      {
        string file = item.Path;
        SelectDVDHandler sdh = new SelectDVDHandler();
        SelectBDHandler bdh = new SelectBDHandler();

        if (sdh.IsDvdDirectory(item.Path))
        {
          if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
          {
            file = file + @"\VIDEO_TS\VIDEO_TS.IFO";
          }
        }

        if (bdh.IsBDDirectory(item.Path))
        {
          if (File.Exists(item.Path + @"\BDMV\INDEX.BDMV"))
          {
            file = file + @"\BDMV\INDEX.BDMV";
          }
        }

        ArrayList files = new ArrayList();
        files = AddFileToDatabase(file);
        MovieDuration(files, true);
        int movieId = VideoDatabase.GetMovieId(file);
        IMDBMovie mInfo = new IMDBMovie();
        mInfo.SetMediaInfoProperties(file, true);
        mInfo.SetDurationProperty(movieId);
        IMDBMovie.SetMovieData(item);

        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_REFRESH_MEDIAINFO, 0, 0, 0, 0, 0, 0);
        GUIWindowManager.SendMessage(msg);
      }
    }
Example #10
0
    /// <summary>
    /// Get/Set DVDHandler interface from/to registered services.
    /// </summary>
    /// <returns>DVDHandler interface</returns>
    public static ISelectDVDHandler GetSelectDvdHandler()
    {
      ISelectDVDHandler selectDVDHandler;

      if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
      {
        selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
      }
      else
      {
        selectDVDHandler = new SelectDVDHandler();
        GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
      }

      return selectDVDHandler;
    }
 protected void OnPlayDVD(String drive, int parentId)
 {
   ISelectDVDHandler selectDVDHandler;
   if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
   {
     selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
   }
   else
   {
     selectDVDHandler = new SelectDVDHandler();
     GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
   }
   selectDVDHandler.OnPlayDVD(drive, GetID);
 }
    protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
    {
      base.OnClicked(controlId, control, actionType);

      if (control == btnSavedPlaylists)
      {
        OnShowSavedPlaylists(m_strPlayListPath);
      }

      if (control == btnPlayDVD)
      {
        ISelectDVDHandler selectDVDHandler;
        if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
        {
          selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
        }
        else
        {
          selectDVDHandler = new SelectDVDHandler();
          GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
        }
        string dvdToPlay = selectDVDHandler.ShowSelectDVDDialog(GetID);
        if (dvdToPlay != null)
        {
          OnPlayDVD(dvdToPlay, GetID);
        }
        return;
      }
    }
    protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
    {
      base.OnClicked(controlId, control, actionType);

      if (control == btnSavedPlaylists)
      {
        OnShowSavedPlaylists(m_strPlayListPath);
      }

      if (control == btnPlayDVD)
      {
        ISelectDVDHandler selectDVDHandler;
        if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
        {
          selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
        }
        else
        {
          selectDVDHandler = new SelectDVDHandler();
          GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
        }
        string dvdToPlay = selectDVDHandler.ShowSelectDVDDialog(GetID);
        if (dvdToPlay != null)
        {
          OnPlayDVD(dvdToPlay, GetID);
        }
        return;
      }

      if (control == btnScanNew)
      {
        // Check Internet connection
        if (!Win32API.IsConnectedToInternet())
        {
          GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
          dlgOk.SetHeading(257);
          dlgOk.SetLine(1, GUILocalizeStrings.Get(703));
          dlgOk.DoModal(GUIWindowManager.ActiveWindow);
          return;
        }

        OnSearchNew();
      }
    }
    private void LoadDirectory(string newFolderName, bool useCache, HashSet<string> watchedFiles)
    {
      if (newFolderName == null)
      {
        Log.Warn("GUIVideoFiles::LoadDirectory called with invalid argument. newFolderName is null!");
        return;
      }

      if (facadeLayout == null)
      {
        return;
      }

      GUIWaitCursor.Show();
      GUIListItem selectedListItem = null;

      if (facadeLayout != null)
      {
        selectedListItem = facadeLayout.SelectedListItem;
      }
      if (selectedListItem != null)
      {
        if (selectedListItem.IsFolder && selectedListItem.Label != "..")
        {
          _history.Set(selectedListItem.Label, _currentFolder);
        }
      }

      if (newFolderName != _currentFolder && _mapSettings != null)
      {
        SaveFolderSettings(_currentFolder);
      }

      if (newFolderName != _currentFolder || _mapSettings == null)
      {
        LoadFolderSettings(newFolderName);
      }
      // Image file is not listed as a valid movie so we need to handle it 
      // as a folder and enable browsing for it
      if (VirtualDirectory.IsImageFile(Path.GetExtension(newFolderName)))
      {
        if (!MountImageFile(GetID, newFolderName, true))
          return;

        _currentFolder = DaemonTools.GetVirtualDrive();
      }
      else
      {
        _currentFolder = newFolderName;
      }
      string objectCount = string.Empty;

      if (facadeLayout != null)
      {
        GUIControl.ClearControl(GetID, facadeLayout.GetID);
      }


      List<GUIListItem> itemlist = null;

      //Tweak to boost performance when starting/stopping playback
      //For further details see comment in Core\Util\VirtualDirectory.cs
      if (useCache && _cachedDir == _currentFolder)
      {
        itemlist = _cachedItems;
        SelectDVDHandler selectDvdHandler = new SelectDVDHandler();

        foreach (GUIListItem item in itemlist)
        {
          if (watchedFiles != null && watchedFiles.Contains(item.Path))
          {
            item.IsPlayed = true;
          }
          else if (_markWatchedFiles &&
                   (item.IsFolder && selectDvdHandler.IsDvdDirectory(item.Path) || Util.Utils.IsVideo(item.Path)))
          {
            string file = item.Path;
            if (item.IsFolder)
              file = selectDvdHandler.GetFolderVideoFile(item.Path);
            // Check db for watched status for played movie or changed status in movie info window
            item.IsPlayed = VideoDatabase.GetmovieWatchedStatus(VideoDatabase.GetMovieId(file));
          }
          //Do NOT add OnItemSelected event handler here, because its still there...
          facadeLayout.Add(item);
        }
      }
      else
      {
        // here we get ALL files in every subdir, look for folderthumbs, defaultthumbs, etc
        itemlist = _virtualDirectory.GetDirectoryExt(_currentFolder);
        if (_mapSettings.Stack)
        {
          Dictionary<string, List<GUIListItem>> stackings = new Dictionary<string, List<GUIListItem>>(itemlist.Count);

          for (int i = 0; i < itemlist.Count; ++i)
          {
            GUIListItem item1 = itemlist[i];
            string cleanFilename = item1.Label;
            Util.Utils.RemoveStackEndings(ref cleanFilename);
            List<GUIListItem> innerList;
            if (stackings.TryGetValue(cleanFilename, out innerList))
            {
              for (int j = 0; j < innerList.Count; j++)
              {
                GUIListItem item2 = innerList[j];
                if ((!item1.IsFolder || !item2.IsFolder)
                    && (!item1.IsRemote && !item2.IsRemote)
                    && Util.Utils.ShouldStack(item1.Path, item2.Path))
                {
                  if (String.Compare(item1.Path, item2.Path, true) > 0)
                  {
                    item2.FileInfo.Length += item1.FileInfo.Length;
                  }
                  else
                  {
                    // keep item1, it's path is lexicographically before item2 path
                    item1.FileInfo.Length += item2.FileInfo.Length;
                    innerList[j] = item1;
                  }
                  item1 = null;
                  break;
                }
              }
              if (item1 != null) // not stackable
              {
                innerList.Add(item1);
              }
            }
            else
            {
              innerList = new List<GUIListItem> {item1};
              stackings.Add(cleanFilename, innerList);
            }
          }

          List<GUIListItem> itemfiltered = new List<GUIListItem>(itemlist.Count);
          foreach (KeyValuePair<string, List<GUIListItem>> pair in stackings)
          {
            List<GUIListItem> innerList = pair.Value;
            for (int i = 0; i < innerList.Count; i++)
            {
              GUIListItem item = innerList[i];
              if ((VirtualDirectory.IsValidExtension(item.Path, Util.Utils.VideoExtensions, false)))
                item.Label = pair.Key;
              itemfiltered.Add(item);
            }
          }
          itemlist = itemfiltered;
        }

        ISelectDVDHandler selectDVDHandler;
        if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
        {
          selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
        }
        else
        {
          selectDVDHandler = new SelectDVDHandler();
          GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
        }
        // folder.jpg will already be assigned from "itemlist = virtualDirectory.GetDirectory(_currentFolder);" here
        selectDVDHandler.SetIMDBThumbs(itemlist, _markWatchedFiles, _eachFolderIsMovie);

        foreach (GUIListItem item in itemlist)
        {
          item.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected);
          facadeLayout.Add(item);
        }

        _cachedItems = itemlist;
        _cachedDir = _currentFolder;
      }

      OnSort();

      bool itemSelected = false;

      //Sometimes the last selected item wasn't restored correcly after playback stop
      //The !useCache fixes this
      if (selectedListItem != null && !useCache)
      {
        string selectedItemLabel = _history.Get(_currentFolder);
        for (int i = 0; i < facadeLayout.Count; ++i)
        {
          GUIListItem item = facadeLayout[i];
          if (item.Label == selectedItemLabel)
          {
            GUIControl.SelectItemControl(GetID, facadeLayout.GetID, i);
            itemSelected = true;
            break;
          }
        }
      }
      int totalItems = itemlist.Count;
      if (itemlist.Count > 0)
      {
        GUIListItem rootItem = (GUIListItem)itemlist[0];
        if (rootItem.Label == "..")
        {
          totalItems--;
        }
      }

      //set object count label
      GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(totalItems));

      if (!itemSelected)
      {
        UpdateButtonStates();
        SelectCurrentItem();
      }

      GUIWaitCursor.Hide();
    }
    protected override void OnShowContextMenu()
    {
      GUIListItem item = facadeLayout.SelectedListItem;
      int itemNo = facadeLayout.SelectedListItemIndex;
      if (item == null)
      {
        return;
      }
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(498); // menu

      if (!facadeLayout.Focus)
      {
        // Menu button context menuu
        if (!_virtualDirectory.IsRemote(_currentFolder))
        {
          dlg.AddLocalizedString(102); //Scan
          dlg.AddLocalizedString(368); //IMDB
        }
      }
      else
      {
        if ((Path.GetFileName(item.Path) != string.Empty) || Util.Utils.IsDVD(item.Path))
        {
          if (item.IsRemote)
          {
            return;
          }
          if ((item.IsFolder) && (item.Label == ".."))
          {
            return;
          }
          if (Util.Utils.IsDVD(item.Path))
          {
            if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
            {
              dlg.AddLocalizedString(341); //play
            }
            else
            {
              dlg.AddLocalizedString(926); //Queue
              dlg.AddLocalizedString(102); //Scan
            }
            dlg.AddLocalizedString(368); //IMDB
            dlg.AddLocalizedString(654); //Eject
          }
          else if (item.IsFolder)
          {
            if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
            {
              dlg.AddLocalizedString(208); //play             
            }
            dlg.AddLocalizedString(926); //Queue
            if (!VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
            {
              //
              // Play all
              //
              SelectDVDHandler checkIfIsDvd = new SelectDVDHandler();
              if (!checkIfIsDvd.IsDvdDirectory(item.Path))
              {
                dlg.AddLocalizedString(1204); // Play All in selected folder
              }
              else
              {
                if (item.IsPlayed)
                {
                  dlg.AddLocalizedString(830); //Reset watched status for DVD folder
                }
              }
              //
              dlg.AddLocalizedString(102); //Scan            
            }
            dlg.AddLocalizedString(368); //IMDB
            if (Util.Utils.getDriveType(item.Path) == 5)
            {
              dlg.AddLocalizedString(654); //Eject            
            }
            if (!IsFolderPinProtected(item.Path) && _fileMenuEnabled)
            {
              dlg.AddLocalizedString(500); // FileMenu            
            }
          }
          else
          {
            dlg.AddLocalizedString(208); //Play
            dlg.AddLocalizedString(926); //Queue
            dlg.AddLocalizedString(368); //IMDB
            if (item.IsPlayed)
            {
              dlg.AddLocalizedString(830); //Reset watched status
            }

            if (!IsFolderPinProtected(item.Path) && !item.IsRemote && _fileMenuEnabled)
            {
              dlg.AddLocalizedString(500); // FileMenu
            }
          }
        }
        else if (Util.Utils.IsNetwork(item.Path)) // Process network root with drive letter
        {
          dlg.AddLocalizedString(1204); // Play All in selected folder
        }
      }
      if (!_mapSettings.Stack)
      {
        dlg.AddLocalizedString(346); //Stack
      }
      else
      {
        dlg.AddLocalizedString(347); //Unstack
      }
      if (Util.Utils.IsRemovable(item.Path))
      {
        dlg.AddLocalizedString(831);
      }

      dlg.DoModal(GetID);
      if (dlg.SelectedId == -1)
      {
        return;
      }
      switch (dlg.SelectedId)
      {
        case 368: // IMDB
          OnInfo(itemNo);
          break;

        case 208: // play
          OnClick(itemNo);
          break;

        case 926: // add to playlist
          OnQueueItem(itemNo);
          break;

        case 136: // show playlist
          GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_PLAYLIST);
          break;

        case 654: // Eject
          if (Util.Utils.getDriveType(item.Path) != 5)
          {
            Util.Utils.EjectCDROM();
          }
          else
          {
            Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
          }
          LoadDirectory(string.Empty);
          break;

        case 341: //Play dvd
          OnPlayDVD(item.Path, GetID);
          break;

        case 346: //Stack
          _mapSettings.Stack = true;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 347: //Unstack
          _mapSettings.Stack = false;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 102: //Scan
          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }
          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          ArrayList availablePaths = new ArrayList();
          availablePaths.Add(item.Path);
          IMDBFetcher.ScanIMDB(this, availablePaths, _isFuzzyMatching, _scanSkipExisting, _getActors, false);
          LoadDirectory(_currentFolder);
          break;

        case 830: // Reset watched status
          SetMovieUnwatched(item.Path, item.IsFolder);
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 500: // File menu
          {
            ShowFileMenu(false);
          }
          break;

        case 831:
          string message;
          if (!RemovableDriveHelper.EjectDrive(item.Path, out message))
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(832));
            pDlgOK.SetLine(2, string.Empty);
            pDlgOK.SetLine(3, message);
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          else
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(833));
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          break;
          // Play all
        case 1204:
          {
            if (!_virtualDirectory.RequestPin(item.Path))
            {
              return;
            }
            OnPlayAll(item.Path);
          }
          break;
      }
    }
    private void SetMovieUnwatched(string movieFileName, bool isFolder)
    {
      SelectDVDHandler isDvdFolder = new SelectDVDHandler();

      if (isFolder && isDvdFolder.IsDvdDirectory(movieFileName))
        movieFileName = isDvdFolder.GetFolderVideoFile(movieFileName);

      if (VideoDatabase.HasMovieInfo(movieFileName))
      {
        IMDBMovie movieDetails = new IMDBMovie();
        int idMovie = VideoDatabase.GetMovieInfo(movieFileName, ref movieDetails);
        movieDetails.Watched = 0;
        VideoDatabase.SetWatched(movieDetails);
      }
      int idFile = VideoDatabase.GetFileId(movieFileName);
      VideoDatabase.DeleteMovieStopTime(idFile);
      VideoDatabase.SetMovieWatchedStatus(VideoDatabase.GetMovieId(movieFileName), false);
    }
    // CHANGED

    // GUI Item file name handler - share view ->IMDB
    protected override void OnInfo(int iItem)
    {
      _currentSelectedItem = facadeLayout.SelectedListItemIndex;
      GUIListItem pItem = facadeLayout.SelectedListItem;
      if (pItem == null)
      {
        return;
      }
      if (pItem.IsRemote)
      {
        return;
      }
      if (!_virtualDirectory.RequestPin(pItem.Path))
      {
        return;
      }
      string strFile = pItem.Path;
      string strMovie = pItem.Label;
      bool bFoundFile = true;

      if ((pItem.IsFolder) && (!Util.Utils.IsDVD(pItem.Path)))
      {
        if (pItem.Label == "..")
        {
          return;
        }
        ISelectDVDHandler selectDVDHandler;
        if (GlobalServiceProvider.IsRegistered<ISelectDVDHandler>())
        {
          selectDVDHandler = GlobalServiceProvider.Get<ISelectDVDHandler>();
        }
        else
        {
          selectDVDHandler = new SelectDVDHandler();
          GlobalServiceProvider.Add<ISelectDVDHandler>(selectDVDHandler);
        }
        strFile = selectDVDHandler.GetFolderVideoFile(pItem.Path);

        if (strFile == string.Empty)
        {
          bFoundFile = false;
          strFile = pItem.Path;
        }
        else if (strFile.ToUpper().IndexOf(@"\VIDEO_TS\VIDEO_TS.IFO") >= 0)
        {
          //DVD folder
          string dvdFolder = strFile.Substring(0, strFile.ToUpper().IndexOf(@"\VIDEO_TS\VIDEO_TS.IFO"));
          strMovie = Path.GetFileName(dvdFolder);
        }
        else
        {
          //Movie 
          strMovie = Path.GetFileNameWithoutExtension(strFile);
        }
      }
      // Use DVD label as movie name
      if (Util.Utils.IsDVD(pItem.Path) && (pItem.DVDLabel != string.Empty))
      {
        if (File.Exists(pItem.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
        {
          strFile = pItem.Path + @"\VIDEO_TS\VIDEO_TS.IFO";
        }
        strMovie = pItem.DVDLabel;
      }
      IMDBMovie movieDetails = new IMDBMovie();
      if ((VideoDatabase.GetMovieInfo(strFile, ref movieDetails) == -1) ||
          (movieDetails.IsEmpty))
      {
        // Check Internet connection
        if (!Win32API.IsConnectedToInternet())
        {
          GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
          dlgOk.SetHeading(257);
          dlgOk.SetLine(1, GUILocalizeStrings.Get(703));
          dlgOk.DoModal(GUIWindowManager.ActiveWindow);
          return;
        }
        // Movie is not in the database
        if (bFoundFile)
        {
          AddFileToDatabase(strFile);
        }

        // Changed - Movie folder title
        using (MediaPortal.Profile.Settings xmlreader = new MPSettings())
        {
          bool foldercheck = xmlreader.GetValueAsBool("moviedatabase", "usefolderastitle", false);
          if (foldercheck == true)
          {
            movieDetails.SearchString = Path.GetFileName(Path.GetDirectoryName(strMovie));
          }
          else
          {
            movieDetails.SearchString = Path.GetFileNameWithoutExtension(strMovie);
          }
          movieDetails.File = Path.GetFileName(strFile);
        }
        // End change
        if (movieDetails.File == string.Empty)
        {
          movieDetails.Path = strFile;
        }
        else
        {
          movieDetails.Path = strFile.Substring(0, strFile.IndexOf(movieDetails.File) - 1);
        }
        Log.Info("GUIVideoFiles: IMDB search: {0}, file:{1}, path:{2}", movieDetails.SearchString, movieDetails.File,
                 movieDetails.Path);
        if (!IMDBFetcher.GetInfoFromIMDB(this, ref movieDetails, false, _getActors))
        {
          return;
        }
      }
      // Movie is in the database
      GUIVideoInfo videoInfo = (GUIVideoInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_VIDEO_INFO);
      videoInfo.Movie = movieDetails;
      if (pItem.IsFolder)
      {
        videoInfo.FolderForThumbs = pItem.Path;
      }
      else
      {
        videoInfo.FolderForThumbs = string.Empty;
      }
      GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_INFO);

      if (movieDetails != null)
      {
        // Add file name beacuse in the movie.details it's empty -> FanArt on shares helper
        movieDetails.File = Path.GetFileName(strFile);

        // Title suffix for problem with covers and movie with the same name
        //string thumbPath = Util.Utils.GetCoverArt(Thumbs.MovieTitle, movieDetails.Title);
        string titleExt = movieDetails.Title + "{" + movieDetails.ID + "}";
        string thumbPath = Util.Utils.GetCoverArt(Thumbs.MovieTitle, titleExt);

        if (string.IsNullOrEmpty(thumbPath) || !Util.Utils.FileExistsInCache(thumbPath))
        {
          thumbPath = string.Format(@"{0}\{1}", Thumbs.MovieTitle,
                                    Util.Utils.MakeFileName(
                                      Util.Utils.SplitFilename(Path.ChangeExtension(pItem.Path, ".jpg"))));
        }

        if (Util.Utils.FileExistsInCache(thumbPath))
        {
          pItem.RefreshCoverArt();

          pItem.IconImage = thumbPath;
          pItem.IconImageBig = thumbPath;

          string thumbLargePath = Util.Utils.ConvertToLargeCoverArt(thumbPath);
          if (Util.Utils.FileExistsInCache(thumbLargePath))
          {
            pItem.ThumbnailImage = thumbLargePath;
          }
          else
          {
            pItem.ThumbnailImage = thumbPath;
          }
        }
      }
    }
Example #18
0
    private void RefreshMediaInfo(GUIListItem item)
    {
      if (item != null)
      {
        string file = item.Path;
        SelectDVDHandler sdh = new SelectDVDHandler();
        SelectBDHandler bdh = new SelectBDHandler();

        if (sdh.IsDvdDirectory(item.Path))
        {
          if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
          {
            file = file + @"\VIDEO_TS\VIDEO_TS.IFO";
          }
        }

        if (bdh.IsBDDirectory(item.Path))
        {
          if (File.Exists(item.Path + @"\BDMV\INDEX.BDMV"))
          {
            file = file + @"\BDMV\INDEX.BDMV";
          }
        }

        ArrayList files = new ArrayList();
        files = AddFileToDatabase(file);
        MovieDuration(files, true);
        int movieId = VideoDatabase.GetMovieId(file);
        IMDBMovie mInfo = new IMDBMovie();
        mInfo.SetMediaInfoProperties(file, true);
        mInfo.SetDurationProperty(movieId);
        IMDBMovie.SetMovieData(item);
        SelectCurrentItem();
      }
    }