NextPVR Forums

Full Version: how are you getting data for recording items?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working on my Tuner Status plugin, and know if a tuner is recording and the show name that is being recorded. I also want to get the channel # so I can display the channel icon and show description.

IList mRecordingScheduleList = null;
DateTime mRecordingScheduleListLoadedTS = DateTime.Now;
Programme mProgramme = null;
Channel mChannel = null;
mRecordingScheduleList = GBPVR.Backend.Common.ScheduleHelper.getInstance().LoadRecordingSchedule();

This gives me an array of scheduled recordings, and I can search for a matching name and try to guess the date and time it started vs DateTime.Now. There has to be an easier way to know that if something is recording, for it to return specific info on what is being recorded: channel #, show name, show description.

What's your secret to display the data in the tooltip?
Code:
[FONT=Courier New][COLOR=#0000ff]public [/COLOR][COLOR=#0000ff]bool[/COLOR] getScheduledRecordingInProgress()[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New][COLOR=#0000ff] bool[/COLOR] inProgress = [COLOR=#0000ff]false[/COLOR];[/FONT]
[FONT=Courier New] ScheduledRecording sr = getScheduledRecordingObject(mProgramme.getOID());[/FONT]
[FONT=Courier New][COLOR=#0000ff] if[/COLOR] (sr != [COLOR=#0000ff]null[/COLOR])[/FONT]
[FONT=Courier New] {[/FONT]
[FONT=Courier New][COLOR=#0000ff]   int[/COLOR] status = (sr == [COLOR=#0000ff]null[/COLOR] ? -1 : sr.getRecordingStatus());[/FONT]
[FONT=Courier New][COLOR=#0000ff]   if[/COLOR] (status == ScheduledRecording.STATUS_IN_PROGRESS)[/FONT]
[FONT=Courier New]     inProgress = [COLOR=#0000ff]true[/COLOR];[/FONT]
[FONT=Courier New] }[/FONT]
[FONT=Courier New][COLOR=#0000ff] return[/COLOR] inProgress;[/FONT]
[FONT=Courier New]}[/FONT]
Continually loading the recording schedule places a large load on the processor so I only ever reload it when absolutely necessary.

I monitor the tuner status using the code I gave you before and extract the number of recordings ongoing at any one time. If the number of active recordings changes then I reload the recording schedule and pull out the recordings whose .getRecordingStatus() == ScheduledRecording.STATUS_IN_PROGRESS.

I think these are the two bits that should point you in the right direction.

Code:
#region RecordingStatus
    /// <summary>
    /// Enumeration of possible recording status values for a <see cref="ScheduledRecording"/>.
    /// </summary>
    public enum RecordingStatus
    {
      /// <summary>Indicates a <see cref="ScheduledRecording"/> completed successfully.</summary>
      Completed = ScheduledRecording.STATUS_COMPLETED,
      /// <summary>Indicates a <see cref="ScheduledRecording"/> did not complete successfully.</summary>
      CompletedWithError = ScheduledRecording.STATUS_COMPLETED_WITH_ERROR,
      Conflict = ScheduledRecording.STATUS_CONFLICT,
      Deleted = ScheduledRecording.STATUS_DELETED,
      /// <summary>Indicates a <see cref="ScheduledRecording"/> is currently being recorded.</summary>
      InProgress = ScheduledRecording.STATUS_IN_PROGRESS,
      /// <summary>Indicates a <see cref="ScheduledRecording"/> is scheduled to be recorded in the future.</summary>
      Pending = ScheduledRecording.STATUS_PENDING,
      Placeholder = ScheduledRecording.STATUS_PLACE_HOLDER,
      /// <summary>Used to tell <see cref="Schedule(RecordingStatus)"/> to return all recordings regardless of RecordingStatus.</summary>
      Any = int.MaxValue
    }
    #endregion

    public static System.Collections.ArrayList Schedule(
                               RecordingStatus Status,
                                           int NumberOfRecordings)
    {
      ArrayList RecordingList = new ArrayList();
      // Make sure a schedule is loaded
      if (NeedToRefreshSchedule) { RefreshSchedule(); }
      // Now run through schedule and return information required
      try
      {
        for (int RecordingCount = 0;
             _ScheduleListGeneric != null && RecordingCount < _ScheduleListGeneric.Count;
             RecordingCount++)
        {
          try
          {
            //ScheduledRecording Recording = (ScheduledRecording)_ScheduleList[RecordingCount];
            if ((RecordingList.Count < NumberOfRecordings)
            && ((_ScheduleListGeneric[RecordingCount].getRecordingStatus() == (int)Status) || (Status == RecordingStatus.Any)))
            {
              // Add this recording to the recording list
              RecordingList.Add(_ScheduleListGeneric[RecordingCount]);
            }
          }
          catch (Exception ex)
          {
            Trace.TraceError("ERROR: Failed to analyze RecordingScheduleList for status=" + Status.ToString()
                        + "\nLOCAL: RecordingCount=" + RecordingCount.ToString()
                        + "\nLOCAL: RecordingList.Count=" + _ScheduleListGeneric.Count.ToString()
                        + "\nLOCAL: Recording=" + _ScheduleListGeneric[RecordingCount].ToString()
                        + "\n" + ex.ToString());
          }
        }
      }
      catch (Exception ex)
      {
        Trace.TraceError("ERROR: Failed to analyze RecordingScheduleList."
                     + "\nLOCAL: RecordingList.Count=" + _ScheduleListGeneric.Count.ToString()
                     + "\n" + ex.ToString());
      }
      return RecordingList;
    }

I've also PM'd you the source code for Slimm GBPVR. Note that the source code for Slimm.GBPVR.dll (which is where the above functions are) are in a folder called SlimmGBPVRHelper. Also, note that there are sections of code which belong to other people who will need to be credited somewhere on your project if you use them. The code is reasonably well commented and there is the technical documentation called SlimmGBPVRDoc.chm in the SlimmGBPVR/Documentation folder.