MediaPortal.Video.Database.IMDBMovie.SetDurationProperty C# (CSharp) Method

SetDurationProperty() public method

public SetDurationProperty ( int movieId ) : void
movieId int
return void
    public void SetDurationProperty(int movieId) 
    {
      if (RunTime <= 0)
      {
        IMDBMovie movie = new IMDBMovie();
        VideoDatabase.GetMovieInfoById(movieId, ref movie);
        RunTime = movie.RunTime;
      }

      if (RunTime <=0)
      {
        GUIPropertyManager.SetProperty("#runtime", string.Empty);
      }
      else
      {
        GUIPropertyManager.SetProperty("#runtime", RunTime + 
                                " " +
                                GUILocalizeStrings.Get(2998) +
                                " (" + 
                                Util.Utils.SecondsToHMString(RunTime * 60) + 
                                ")");
      }

      if (RunTime <= 0)
      {
        GUIPropertyManager.SetProperty("#runtimeMins", string.Empty);
      }
      else
      {
        int runtimeMins = RunTime * 60;
        GUIPropertyManager.SetProperty("#runtimeMins", runtimeMins.ToString());
      }

      if (Duration <= 0)
      {
        GUIPropertyManager.SetProperty("#videoruntime", string.Empty);
      }
      else
      {
        GUIPropertyManager.SetProperty("#videoruntime", Util.Utils.SecondsToHMSString(Duration));
      }
    }

Usage Example

Example #1
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;
      }
    }
All Usage Examples Of MediaPortal.Video.Database.IMDBMovie::SetDurationProperty