コード例 #1
0
 public string GetRecordingURL(int idRecording)
 {
     if (!ConnectToDatabase())
     {
         return("");
     }
     TvControl.TvServer server = new TvControl.TvServer();
     return(server.GetStreamUrlForFileName(idRecording));
 }
コード例 #2
0
    public new DialogResult ShowDialog(IWin32Window owner)
    {
      Text = "Preview " + _channel.DisplayName;

      TvServer server = new TvServer();
      IUser user = new User("setuptv", false);
      TvResult result = server.StartTimeShifting(ref user, _channel.IdChannel, out _card);
      if (result != TvResult.Succeeded)
      {
        MessageBox.Show("Preview failed:" + result);
        Close();
        return DialogResult.None;
      }

      Log.Info("preview {0} user:{1} {2} {3} {4}", _channel.DisplayName, user.CardId, user.SubChannel, user.Name,
               _card.TimeShiftFileName);
      _player = new Player();
      _player.Play(_card.TimeShiftFileName, this);

      return base.ShowDialog(owner);
    }
コード例 #3
0
    private void OnMoveUp(int item)
    {
      if (item == 0)
      {
        return;
      }
      m_iSelectedItem = item - 1;
      GUIListItem pItem = GetItem(GetSelectedItemNo());
      if (pItem == null)
      {
        return;
      }
      Schedule rec = pItem.TVTag as Schedule;
      if (rec == null)
      {
        return;
      }
      GUIListItem tmpItem;
      Schedule tmprec;

      for (int i = 0; i < item - 1; ++i)
      {
        tmpItem = GetItem(i);
        tmprec = tmpItem.TVTag as Schedule;
        tmprec.Priority = Schedule.HighestPriority - i;
      }
      for (int i = item - 1; i < GetItemCount(); ++i)
      {
        if (item == i)
        {
          continue;
        }
        tmpItem = GetItem(i);
        tmprec = tmpItem.TVTag as Schedule;
        tmprec.Priority = Schedule.HighestPriority - i - 1;
      }

      rec.Priority = Schedule.HighestPriority - item + 1;

      rec.Persist();
      TvServer server = new TvServer();
      server.OnNewSchedule();
      LoadDirectory();
    }
コード例 #4
0
    public override bool OnMessage(GUIMessage message)
    {
      _needToClearScreen = true;

      #region case GUI_MSG_RECORD

      if (message.Message == GUIMessage.MessageType.GUI_MSG_RECORD)
      {
        if (_isDialogVisible)
        {
          return false;
        }

        Channel channel = TVHome.Navigator.Channel;

        if (channel == null)
        {
          return true;
        }

        TvBusinessLayer layer = new TvBusinessLayer();

        Program prog = channel.CurrentProgram;
        VirtualCard card;
        TvServer server = new TvServer();
        if (server.IsRecording(channel.IdChannel, out card))
        {
          _dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
          _dlgYesNo.SetHeading(1449); // stop recording
          _dlgYesNo.SetLine(1, 1450); // are you sure to stop recording?
          if (prog != null)
          {
            _dlgYesNo.SetLine(2, prog.Title);
          }
          _dialogYesNoVisible = true;
          _dlgYesNo.DoModal(GetID);
          _dialogYesNoVisible = false;

          if (!_dlgYesNo.IsConfirmed)
          {
            return true;
          }

          Schedule s = Schedule.Retrieve(card.RecordingScheduleId);
          TVUtil.DeleteRecAndSchedQuietly(s, card.IdChannel);          

          GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_NOTIFY);
          if (dlgNotify == null)
          {
            return true;
          }
          string logo = Utils.GetCoverArt(Thumbs.TVChannel, channel.DisplayName);
          dlgNotify.Reset();
          dlgNotify.ClearAll();
          dlgNotify.SetImage(logo);
          dlgNotify.SetHeading(GUILocalizeStrings.Get(1447)); //recording stopped
          if (prog != null)
          {
            dlgNotify.SetText(String.Format("{0} {1}-{2}",
                                            prog.Title,
                                            prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                            prog.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)));
          }
          else
          {
            dlgNotify.SetText(GUILocalizeStrings.Get(736)); //no tvguide data available
          }
          dlgNotify.TimeOut = 5;

          _notifyDialogVisible = true;
          dlgNotify.DoModal(GUIWindowManager.ActiveWindow);
          TvNotifyManager.ForceUpdate();
          _notifyDialogVisible = false;
          return true;
        }
        else
        {
          if (prog != null)
          {
            _dialogBottomMenu =
              (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT);
            if (_dialogBottomMenu != null)
            {
              _dialogBottomMenu.Reset();
              _dialogBottomMenu.SetHeading(605); //my tv
              //_dialogBottomMenu.SetHeadingRow2(prog.Title);              

              _dialogBottomMenu.AddLocalizedString(875); //current program
              _dialogBottomMenu.AddLocalizedString(876); //till manual stop
              _bottomDialogMenuVisible = true;

              _dialogBottomMenu.DoModal(GetID);

              _bottomDialogMenuVisible = false;
              switch (_dialogBottomMenu.SelectedId)
              {
                case 875:
                  //record current program
                  _isStartingTSForRecording = !g_Player.IsTimeShifting;

                  TVHome.StartRecordingSchedule(channel, false);
                  break;

                case 876:
                  //manual record
                  _isStartingTSForRecording = !g_Player.IsTimeShifting;

                  TVHome.StartRecordingSchedule(channel, true);
                  break;
                default:
                  return true;
              }
            }
          }
          else
          {
            _isStartingTSForRecording = !g_Player.IsTimeShifting;
            TVHome.StartRecordingSchedule(channel, true);
          }

          // check if recorder has to start timeshifting for this recording
          if (_isStartingTSForRecording)
          {
            Channel ch = Channel.Retrieve(TVHome.Card.IdChannel);
            TVHome.ViewChannel(ch);
            _isStartingTSForRecording = false;
          }

          GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_NOTIFY);
          if (dlgNotify == null)
          {
            return true;
          }
          string logo = Utils.GetCoverArt(Thumbs.TVChannel, channel.DisplayName);
          dlgNotify.Reset();
          dlgNotify.ClearAll();
          dlgNotify.SetImage(logo);
          dlgNotify.SetHeading(GUILocalizeStrings.Get(1446)); //recording started
          if (prog != null)
          {
            dlgNotify.SetText(String.Format("{0} {1}-{2}",
                                            prog.Title,
                                            prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                            prog.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)));
          }
          else
          {
            dlgNotify.SetText(GUILocalizeStrings.Get(736)); //no tvguide data available
          }
          dlgNotify.TimeOut = 5;
          _notifyDialogVisible = true;
          dlgNotify.DoModal(GUIWindowManager.ActiveWindow);

          TvNotifyManager.ForceUpdate();


          _notifyDialogVisible = false;
        }
        return true;
      }

      #endregion

      #region case GUI_MSG_RECORDER_ABOUT_TO_START_RECORDING

      if (message.Message == GUIMessage.MessageType.GUI_MSG_RECORDER_ABOUT_TO_START_RECORDING)
      {
        /*
                TVRecording rec = message.Object as TVRecording;
                if (rec == null) return true;
                if (rec.Channel == Recorder.TVChannelName) return true;
                if (!Recorder.NeedChannelSwitchForRecording(rec)) return true;

                _messageBoxVisible = false;
                _msnWindowVisible = false;     // msn related can be removed
                GUIWindowManager.IsOsdVisible = false;
                if (_zapOsdVisible)
                {
                  GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _zapWindow.GetID, 0, 0, GetID, 0, null);
                  _zapWindow.OnMessage(msg);
                  _zapOsdVisible = false;
                  GUIWindowManager.IsOsdVisible = false;
                }
                if (_isOsdVisible)
                {
                  GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _osdWindow.GetID, 0, 0, GetID, 0, null);
                  _osdWindow.OnMessage(msg);
                  _isOsdVisible = false;
                  GUIWindowManager.IsOsdVisible = false;
                }
                if (_msnWindowVisible)     // msn related can be removed
                {
                  GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _msnWindow.GetID, 0, 0, GetID, 0, null);
                  _msnWindow.OnMessage(msg);	// Send a de-init msg to the OSD
                  _msnWindowVisible = false;
                  GUIWindowManager.IsOsdVisible = false;
                }
                if (_isDialogVisible && dlg != null)
                {
                  GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, dlg.GetID, 0, 0, GetID, 0, null);
                  dlg.OnMessage(msg);	// Send a de-init msg to the OSD
                }

                _bottomDialogMenuVisible = true;
                _dialogBottomMenu = (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT);
                _dialogBottomMenu.TimeOut = 10;
                _dialogBottomMenu.SetHeading(1004);//About to start recording
                _dialogBottomMenu.SetHeadingRow2(String.Format("{0} {1}", GUILocalizeStrings.Get(1005), rec.Channel));
                _dialogBottomMenu.SetHeadingRow3(rec.Title);
                _dialogBottomMenu.AddLocalizedString(1006); //Allow recording to begin
                _dialogBottomMenu.AddLocalizedString(1007); //Cancel recording and maintain watching tv
                _dialogBottomMenu.DoModal(GetID);
                if (_dialogBottomMenu.SelectedId == 1007) //cancel recording
                {
                  if (rec.RecType == TVRecording.RecordingType.Once)
                  {
                    rec.Canceled = Utils.datetolong(DateTime.Now);
                  }
                  else
                  {
                    Program prog = message.Object2 as Program;
                    if (prog != null)
                      rec.CanceledSeries.Add(prog.Start);
                    else
                      rec.CanceledSeries.Add(Utils.datetolong(DateTime.Now));
                  }
                  TVDatabase.UpdateRecording(rec, TVDatabase.RecordingChange.Canceled);
                }
         */
        _bottomDialogMenuVisible = false;
      }

      #endregion

      #region case GUI_MSG_NOTIFY

      if (message.Message == GUIMessage.MessageType.GUI_MSG_NOTIFY)
      {
        GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_NOTIFY);
        if (dlgNotify == null)
        {
          return true;
        }
        string channel = GUIPropertyManager.GetProperty("#TV.View.channel");
        string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, channel);
        dlgNotify.Reset();
        dlgNotify.ClearAll();
        dlgNotify.SetImage(strLogo);
        dlgNotify.SetHeading(channel);
        dlgNotify.SetText(message.Label);
        dlgNotify.TimeOut = message.Param1;
        _notifyDialogVisible = true;
        dlgNotify.DoModal(GUIWindowManager.ActiveWindow);
        _notifyDialogVisible = false;
        Log.Debug("Notify Message:" + channel + ", " + message.Label);
        return true;
      }

      #endregion

      #region case GUI_MSG_TV_ERROR_NOTIFY

      // TEST for TV error handling
      if (message.Message == GUIMessage.MessageType.GUI_MSG_TV_ERROR_NOTIFY)
      {
        UpdateOSD((TvPlugin.TVHome.ChannelErrorInfo)message.Object);
        return true;
      }

      #endregion

      #region case GUI_MSG_WINDOW_DEINIT

      if (_isOsdVisible)
      {
        if ((message.Message != GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT))
        {
          _osdTimeoutTimer = DateTime.Now;
          // route messages to OSD window
          if (_osdWindow.OnMessage(message))
          {
            return true;
          }
        }
        else if (message.Param1 == GetID)
        {
          _osdTimeoutTimer = DateTime.Now;
          _osdWindow.OnMessage(message);
        }
      }

      #endregion

      switch (message.Message)
      {
          #region case GUI_MSG_HIDE_MESSAGE

        case GUIMessage.MessageType.GUI_MSG_HIDE_MESSAGE:
          {
            _messageBoxVisible = false;
          }
          break;

          #endregion

          #region case GUI_MSG_SHOW_MESSAGE

        case GUIMessage.MessageType.GUI_MSG_SHOW_MESSAGE:
          {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0,
                                            (int)Control.MSG_BOX_LABEL1, 0, 0, null);
            msg.Label = message.Label;
            OnMessage(msg);

            msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.MSG_BOX_LABEL2, 0, 0,
                                 null);
            msg.Label = message.Label2;
            OnMessage(msg);

            msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.MSG_BOX_LABEL3, 0, 0,
                                 null);
            msg.Label = message.Label3;
            OnMessage(msg);

            msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.MSG_BOX_LABEL4, 0, 0,
                                 null);
            msg.Label = message.Label4;
            OnMessage(msg);

            _messageBoxVisible = true;
            // Set specified timeout
            _msgBoxTimeout = message.Param1;
            _msgTimer = DateTime.Now;
          }
          break;

          #endregion

          // msn related can be removed
          //#region case GUI_MSG_MSN_CLOSECONVERSATION

          //case GUIMessage.MessageType.GUI_MSG_MSN_CLOSECONVERSATION:
          //  if (_msnWindowVisible)
          //  {
          //    ///@
          //    /// GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _msnWindow.GetID, 0, 0, GetID, 0, null);
          //    ///_msnWindow.OnMessage(msg);	// Send a de-init msg to the OSD
          //  }
          //  _msnWindowVisible = false;
          //  GUIWindowManager.IsOsdVisible = false;
          //  break;

          //#endregion

          // msn related can be removed
          //#region case GUI_MSG_MSN_STATUS_MESSAGE

          //case GUIMessage.MessageType.GUI_MSG_MSN_STATUS_MESSAGE:

          //#endregion

          // msn related can be removed
          //#region case GUI_MSG_MSN_MESSAGE
          //case GUIMessage.MessageType.GUI_MSG_MSN_MESSAGE:
          //  if (_isOsdVisible && _isMsnChatPopup)
          //  {
          //    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _osdWindow.GetID, 0, 0, GetID, 0, null);
          //    _osdWindow.OnMessage(msg);	// Send a de-init msg to the OSD
          //    _isOsdVisible = false;
          //    GUIWindowManager.IsOsdVisible = false;

          //  }

          //  if (!_msnWindowVisible && _isMsnChatPopup)
          //  {
          //    Log.Debug("MSN CHAT:ON");
          //    _msnWindowVisible = true;
          //    GUIWindowManager.VisibleOsd = GUIWindow.Window.WINDOW_TVMSNOSD;
          //    ///@
          //    ///_msnWindow.DoModal(GetID, message);
          //    _msnWindowVisible = false;
          //    GUIWindowManager.IsOsdVisible = false;

          //  }
          //  break;
          //#endregion

          #region case GUI_MSG_WINDOW_DEINIT

        case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
          {
            lock (this) {
              Log.Debug("TvFullScreen:deinit->OSD:Off");
              HideMainOSD();

              _isOsdVisible = false;
              _isPauseOsdVisible = false;
              GUIWindowManager.IsOsdVisible = false;
              GUIWindowManager.IsPauseOsdVisible = false;
              _channelInputVisible = false;
              _keyPressedTimer = DateTime.Now;
              _channelName = "";

              _stepSeekVisible = false;
              _statusVisible = false;
              _groupVisible = false;
              _notifyDialogVisible = false;
              _dialogYesNoVisible = false;
              _bottomDialogMenuVisible = false;
              _statusTimeOutTimer = DateTime.Now;

              _screenState.ContextMenuVisible = false;
              _screenState.MsgBoxVisible = false;
              //_screenState.MsnVisible = false;      // msn related can be removed
              _screenState.OsdVisible = false;
              _screenState.Paused = false;
              _screenState.ShowGroup = false;
              _screenState.ShowInput = false;
              _screenState.ShowStatusLine = false;
              _screenState.ShowTime = false;
              _screenState.ZapOsdVisible = false;
              _needToClearScreen = false;

              GUIGraphicsContext.IsFullScreenVideo = false;
              GUILayerManager.UnRegisterLayer(this);

              base.OnMessage(message);
            }
            return true;
          }

          #endregion

          #region case GUI_MSG_WINDOW_INIT

        case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
          {
            base.OnMessage(message);

            if (!SettingsLoaded)
              LoadSettings();
            GUIGraphicsContext.IsFullScreenVideo = true;

            _osdWindow = (TvOsd)GUIWindowManager.GetWindow((int)Window.WINDOW_TVOSD);
            _zapWindow = (TvZapOsd)GUIWindowManager.GetWindow((int)Window.WINDOW_TVZAPOSD);
            //_msnWindow = (GUITVMSNOSD)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_TVMSNOSD);     // msn related can be removed

            _lastPause = g_Player.Paused;
            _lastSpeed = g_Player.Speed;

            Log.Debug("TvFullScreen:init->OSD:Off");
            Log.Debug("TvFullScreen: init, playing {0}, player.CurrentFile {1}, TVHome.Card.TimeShiftFileName {2}",
                      g_Player.Playing, g_Player.CurrentFile, TVHome.Card.TimeShiftFileName);

            _isOsdVisible = false;
            GUIWindowManager.IsOsdVisible = false;
            _channelInputVisible = false;
            _keyPressedTimer = DateTime.Now;
            _channelName = "";

            _isPauseOsdVisible = _lastPause;
            GUIWindowManager.IsPauseOsdVisible = _lastPause;
            //_zapTimeOutTimer=DateTime.Now;
            _osdTimeoutTimer = DateTime.Now;

            _stepSeekVisible = false;
            _statusVisible = false;
            _groupVisible = false;
            _notifyDialogVisible = false;
            _dialogYesNoVisible = false;
            _bottomDialogMenuVisible = false;
            _statusTimeOutTimer = DateTime.Now;
            //imgVolumeBar.Current = VolumeHandler.Instance.Step;
            //imgVolumeBar.Maximum = VolumeHandler.Instance.StepMax;

            ResetAllControls(); // make sure the controls are positioned relevant to the OSD Y offset
            ScreenStateChanged();
            UpdateGUI();

            GUIGraphicsContext.IsFullScreenVideo = true;
            GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Osd);

            RenderVolume(false);

            //return base.OnMessage(message);
            return true;
          }

          #endregion

          #region case GUI_MSG_SETFOCUS

        case GUIMessage.MessageType.GUI_MSG_SETFOCUS:
          goto case GUIMessage.MessageType.GUI_MSG_LOSTFOCUS;

          #endregion

          #region case GUI_MSG_LOSTFOCUS

        case GUIMessage.MessageType.GUI_MSG_LOSTFOCUS:
          if (_isOsdVisible)
          {
            return true;
          }
          //if (_msnWindowVisible) return true;     // msn related can be removed
          if (message.SenderControlId != (int)Window.WINDOW_TVFULLSCREEN)
          {
            return true;
          }
          break;

          #endregion
      }

      // msn related can be removed
      //if (_msnWindowVisible)
      //{
      //  ///@
      //  ///_msnWindow.OnMessage(message);	// route messages to MSNChat window
      //}
      return base.OnMessage(message);
    }
コード例 #5
0
 private void OnRecordProgram(Program program)
 {
   if (program == null)
   {
     return;
   }
   Log.Debug("TVProgammInfo.OnRecordProgram - programm = {0}", program.ToString());
   Schedule recordingSchedule;
   if (!anyUpcomingEpisodesRecording && currentSchedule != null)
   {
     CancelProgram(program, currentSchedule, GetID);
   }
   else if (IsRecordingProgram(program, out recordingSchedule, true)) // check if schedule is already existing
   {
     CancelProgram(program, recordingSchedule, GetID);
   }
   else
   {
     TvServer server = new TvServer();
     VirtualCard card;
     if (TVHome.Navigator.Channel.IdChannel == program.IdChannel &&
         server.IsRecording(TVHome.Navigator.Channel.IdChannel, out card))
     {
       Schedule schedFromDB = Schedule.Retrieve(card.RecordingScheduleId);
       if (schedFromDB.IsManual)
       {
         Schedule sched = Schedule.Retrieve(card.RecordingScheduleId);
         TVUtil.DeleteRecAndSchedWithPrompt(sched, program.IdChannel);
       }
       else
       {
         CreateProgram(program, (int)ScheduleRecordingType.Once, GetID);
       }
     }
     else
     {
       CreateProgram(program, (int)ScheduleRecordingType.Once, GetID);
     }
   }
   Update();
 }
コード例 #6
0
    private void OnKeep()
    {
      Schedule rec = currentSchedule;
      if (currentSchedule == null && !IsRecordingProgram(CurrentProgram, out rec, false))
      {
        return;
      }

      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(1042);
      dlg.AddLocalizedString(1043); //Until watched
      dlg.AddLocalizedString(1044); //Until space needed
      dlg.AddLocalizedString(1045); //Until date
      dlg.AddLocalizedString(1046); //Always
      switch (rec.KeepMethod)
      {
        case (int)KeepMethodType.UntilWatched:
          dlg.SelectedLabel = 0;
          break;
        case (int)KeepMethodType.UntilSpaceNeeded:
          dlg.SelectedLabel = 1;
          break;
        case (int)KeepMethodType.TillDate:
          dlg.SelectedLabel = 2;
          break;
        case (int)KeepMethodType.Always:
          dlg.SelectedLabel = 3;
          break;
      }
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel == -1)
      {
        return;
      }
      switch (dlg.SelectedId)
      {
        case 1043:
          rec.KeepMethod = (int)KeepMethodType.UntilWatched;
          break;
        case 1044:
          rec.KeepMethod = (int)KeepMethodType.UntilSpaceNeeded;

          break;
        case 1045:
          rec.KeepMethod = (int)KeepMethodType.TillDate;
          dlg.Reset();
          dlg.ShowQuickNumbers = false;
          dlg.SetHeading(1045);
          for (int iDay = 1; iDay <= 100; iDay++)
          {
            DateTime dt = CurrentProgram.StartTime.AddDays(iDay);
            dlg.Add(dt.ToLongDateString());
          }
          TimeSpan ts = (rec.KeepDate - CurrentProgram.StartTime);
          int days = (int)ts.TotalDays;
          if (days >= 100)
          {
            days = 30;
          }
          dlg.SelectedLabel = days - 1;
          dlg.DoModal(GetID);
          if (dlg.SelectedLabel < 0)
          {
            return;
          }
          rec.KeepDate = CurrentProgram.StartTime.AddDays(dlg.SelectedLabel + 1);
          break;
        case 1046:
          rec.KeepMethod = (int)KeepMethodType.Always;
          break;
      }
      rec.Persist();
      currentSchedule = rec;
      TvServer server = new TvServer();
      server.OnNewSchedule();
    }
コード例 #7
0
    public static void OnSetQuality(Schedule rec)
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg != null)
      {
        dlg.Reset();
        dlg.SetHeading(882);

        dlg.ShowQuickNumbers = true;
        dlg.AddLocalizedString(968);
        dlg.AddLocalizedString(965);
        dlg.AddLocalizedString(966);
        dlg.AddLocalizedString(967);
        VIDEOENCODER_BITRATE_MODE _newBitRate = rec.BitRateMode;
        switch (_newBitRate)
        {
          case VIDEOENCODER_BITRATE_MODE.NotSet:
            dlg.SelectedLabel = 0;
            break;
          case VIDEOENCODER_BITRATE_MODE.ConstantBitRate:
            dlg.SelectedLabel = 1;
            break;
          case VIDEOENCODER_BITRATE_MODE.VariableBitRateAverage:
            dlg.SelectedLabel = 2;
            break;
          case VIDEOENCODER_BITRATE_MODE.VariableBitRatePeak:
            dlg.SelectedLabel = 3;
            break;
        }

        dlg.DoModal(GUIWindowManager.ActiveWindow);

        if (dlg.SelectedLabel == -1)
        {
          return;
        }
        switch (dlg.SelectedLabel)
        {
          case 0: // Not Set
            _newBitRate = VIDEOENCODER_BITRATE_MODE.NotSet;
            break;

          case 1: // CBR
            _newBitRate = VIDEOENCODER_BITRATE_MODE.ConstantBitRate;
            break;

          case 2: // VBR
            _newBitRate = VIDEOENCODER_BITRATE_MODE.VariableBitRateAverage;
            break;

          case 3: // VBR Peak
            _newBitRate = VIDEOENCODER_BITRATE_MODE.VariableBitRatePeak;
            break;
        }

        rec.BitRateMode = _newBitRate;
        rec.Persist();

        dlg.Reset();
        dlg.SetHeading(882);

        dlg.ShowQuickNumbers = true;
        dlg.AddLocalizedString(968);
        dlg.AddLocalizedString(886); //Default
        dlg.AddLocalizedString(993); // Custom
        dlg.AddLocalizedString(893); //Portable
        dlg.AddLocalizedString(883); //Low
        dlg.AddLocalizedString(884); //Medium
        dlg.AddLocalizedString(885); //High
        QualityType _newQuality = rec.QualityType;
        switch (_newQuality)
        {
          case QualityType.NotSet:
            dlg.SelectedLabel = 0;
            break;
          case QualityType.Default:
            dlg.SelectedLabel = 1;
            break;
          case QualityType.Custom:
            dlg.SelectedLabel = 2;
            break;
          case QualityType.Portable:
            dlg.SelectedLabel = 3;
            break;
          case QualityType.Low:
            dlg.SelectedLabel = 4;
            break;
          case QualityType.Medium:
            dlg.SelectedLabel = 5;
            break;
          case QualityType.High:
            dlg.SelectedLabel = 6;
            break;
        }

        dlg.DoModal(GUIWindowManager.ActiveWindow);

        if (dlg.SelectedLabel == -1)
        {
          return;
        }
        switch (dlg.SelectedLabel)
        {
          case 0: // Not Set
            _newQuality = QualityType.NotSet;
            break;

          case 1: // Default
            _newQuality = QualityType.Default;
            break;

          case 2: // Custom
            _newQuality = QualityType.Custom;
            break;

          case 3: // Protable
            _newQuality = QualityType.Portable;
            break;

          case 4: // Low
            _newQuality = QualityType.Low;
            break;

          case 5: // Medium
            _newQuality = QualityType.Medium;
            break;

          case 6: // High
            _newQuality = QualityType.High;
            break;
        }

        rec.QualityType = _newQuality;
        rec.Persist();
      }
      TvServer server = new TvServer();
      server.OnNewSchedule();
    }
コード例 #8
0
ファイル: TVHome.cs プロジェクト: splatterpop/MediaPortal-1
    /// <summary>
    /// Tunes to a new channel
    /// </summary>
    /// <param name="channel"></param>
    /// <returns></returns>
    public static bool ViewChannelAndCheck(Channel channel)
    {
      bool checkResult;
      bool doContinue;

      if (!Connected)
      {
        return false;
      }

      _status.Clear();

      _doingChannelChange = false;

      try
      {
        checkResult = PreTuneChecks(channel, out doContinue);
        if (doContinue == false)
          return checkResult;

        _doingChannelChange = true;
        TvResult succeeded;


        IUser user = new User();
        if (Card != null)
        {
          user.CardId = Card.Id;
        }

        if ((g_Player.Playing && g_Player.IsTimeShifting && !g_Player.Stopped) && (g_Player.IsTV || g_Player.IsRadio))
        {
          _status.Set(LiveTvStatus.WasPlaying);
        }

        //Start timeshifting the new tv channel
        TvServer server = new TvServer();
        VirtualCard card;
        int newCardId = -1;

        // check which card will be used
        newCardId = server.TimeShiftingWouldUseCard(ref user, channel.IdChannel);

        //Added by joboehl - If any major related to the timeshifting changed during the start, restart the player.           
        if (newCardId != -1 && Card.Id != newCardId)
        {
          _status.Set(LiveTvStatus.CardChange);
          RegisterCiMenu(newCardId);
        }

        // we need to stop player HERE if card has changed.        
        if (_status.AllSet(LiveTvStatus.WasPlaying | LiveTvStatus.CardChange))
        {
          Log.Debug("TVHome.ViewChannelAndCheck(): Stopping player. CardId:{0}/{1}, RTSP:{2}", Card.Id, newCardId,
                    Card.RTSPUrl);
          Log.Debug("TVHome.ViewChannelAndCheck(): Stopping player. Timeshifting:{0}", Card.TimeShiftFileName);
          Log.Debug("TVHome.ViewChannelAndCheck(): rebuilding graph (card changed) - timeshifting continueing.");
        }
        if (_status.IsSet(LiveTvStatus.WasPlaying))
        {
          RenderBlackImage();
          g_Player.PauseGraph();
        }
        else
        {
          // if CI menu is not attached due to card change, do it if graph was not playing 
          // (some handlers use polling threads that get stopped on graph stop)
          if (_status.IsNotSet(LiveTvStatus.CardChange))
            RegisterCiMenu(newCardId);
        }

        // if card was not changed
        if (_status.IsNotSet(LiveTvStatus.CardChange))
        {
          g_Player.OnZapping(0x80); // Setup Zapping for TsReader, requesting new PAT from stream
        }
        bool cardChanged = false;
        succeeded = server.StartTimeShifting(ref user, channel.IdChannel, out card, out cardChanged);

        if (_status.IsSet(LiveTvStatus.WasPlaying))
        {
          if (card != null)
            g_Player.OnZapping((int)card.Type);
          else
            g_Player.OnZapping(-1);
        }


        if (succeeded != TvResult.Succeeded)
        {
          //timeshifting new channel failed. 
          g_Player.Stop();

          // ensure right channel name, even if not watchable:Navigator.Channel = channel; 
          ChannelTuneFailedNotifyUser(succeeded, _status.IsSet(LiveTvStatus.WasPlaying), channel);

          _doingChannelChange = true; // keep fullscreen false;
          return true; // "success"
        }

        if (card != null && card.NrOfOtherUsersTimeshiftingOnCard > 0)
        {
          _status.Set(LiveTvStatus.SeekToEndAfterPlayback);
        }

        if (cardChanged)
        {
          _status.Set(LiveTvStatus.CardChange);
          if (card != null)
          {
            RegisterCiMenu(card.Id);
          }
          _status.Reset(LiveTvStatus.WasPlaying);
        }
        else
        {
          _status.Reset(LiveTvStatus.CardChange);
          _status.Set(LiveTvStatus.SeekToEnd);
        }

        // Update channel navigator
        if (Navigator.Channel != null &&
            (channel.IdChannel != Navigator.Channel.IdChannel || (Navigator.LastViewedChannel == null)))
        {
          Navigator.LastViewedChannel = Navigator.Channel;
        }
        Log.Info("succeeded:{0} {1}", succeeded, card);
        Card = card; //Moved by joboehl - Only touch the card if starttimeshifting succeeded. 

        // if needed seek to end
        if (_status.IsSet(LiveTvStatus.SeekToEnd))
        {
          SeekToEnd(true);
        }

        // continue graph
        g_Player.ContinueGraph();
        if (!g_Player.Playing || _status.IsSet(LiveTvStatus.CardChange) || (g_Player.Playing && !(g_Player.IsTV || g_Player.IsRadio)))
        {
          StartPlay();

          // if needed seek to end
          if (_status.IsSet(LiveTvStatus.SeekToEndAfterPlayback))
          {
            double dTime = g_Player.Duration - 5;
            g_Player.SeekAbsolute(dTime);
          }
        }

        _playbackStopped = false;
        _doingChannelChange = false;
        _ServerNotConnectedHandled = false;
        return true;
      }
      catch (Exception ex)
      {
        Log.Debug("TvPlugin:ViewChannelandCheckV2 Exception {0}", ex.ToString());
        _doingChannelChange = false;
        Card.User.Name = new User().Name;
        g_Player.Stop();
        Card.StopTimeShifting();
        return false;
      }
      finally
      {
        StopRenderBlackImage();        
        _userChannelChanged = false;
        FireOnChannelChangedEvent();
        Navigator.UpdateCurrentChannel();
      }
    }
コード例 #9
0
 public string GetRecordingURL(int idRecording)
 {
     if (!ConnectToDatabase())
     return "";
       TvControl.TvServer server = new TvControl.TvServer();
       return server.GetStreamUrlForFileName(idRecording);
 }
コード例 #10
0
    /// <summary>
    /// Ensures that the navigator has the correct current channel (retrieved from the Recorder).
    /// </summary>
    public void UpdateCurrentChannel()
    {
      Channel newChannel = null;
      //if current card is watching tv then use that channel
      int id;
      if (TVHome.Connected)
      {
        if (TVHome.Card.IsTimeShifting || TVHome.Card.IsRecording)
        {
          id = TVHome.Card.IdChannel;
          if (id >= 0)
          {
            newChannel = Channel.Retrieve(id);
          }
        }
        else
        {
          // else if any card is recording
          // then get & use that channel
          if (TVHome.IsAnyCardRecording)
          {
            TvServer server = new TvServer();          
            for (int i = 0; i < server.Count; ++i)
            {
              User user = new User();
              VirtualCard card = server.CardByIndex(user, i);
              if (card.IsRecording)
              {
                id = card.IdChannel;
                if (id >= 0)
                {
                  newChannel = Channel.Retrieve(id);
                  break;
                }
              }
            }
          }
        }
        if (newChannel == null)
        {
          newChannel = m_currentChannel;
        }

        int currentChannelId = 0;
        int newChannelId = 0;

        if (m_currentChannel != null)
        {
          currentChannelId = m_currentChannel.IdChannel;
        }

        if (newChannel != null)
        {
          newChannelId = newChannel.IdChannel;
        }

        if (currentChannelId != newChannelId)
        {
          m_currentChannel = newChannel;
          m_currentChannel.CurrentGroup = CurrentGroup;
        }
      }
    }
コード例 #11
0
ファイル: TVZapOSD.cs プロジェクト: arangas/MediaPortal-1
    private void ShowPrograms()
    {
      if (lblOnTvNow != null)
      {
        lblOnTvNow.EnableUpDown = false;
        lblOnTvNow.Clear();
      }
      if (lblOnTvNext != null)
      {
        lblOnTvNext.EnableUpDown = false;
        lblOnTvNext.Clear();
      }

      // Set recorder status
      if (imgRecIcon != null)
      {
        VirtualCard card;
        TvServer server = new TvServer();
        imgRecIcon.IsVisible = server.IsRecording(idChannel, out card);
      }
      
      if (lblZapToCannelNo != null)
      {
        lblZapToCannelNo.Label = channelNr;
        lblZapToCannelNo.Visible = !string.IsNullOrEmpty(channelNr);
      }
      if (LastError != null)
      {        
        lblStartTime.Label = "";
        lblEndTime.Label = "";
        if (LastError.FailingChannel != null)
        {
          lblCurrentChannel.Label = LastError.FailingChannel.DisplayName;
        }
        if (LastError.Messages.Count > 0)
        {
          lblOnTvNow.Label = LastError.Messages[0]; // first line in "NOW"
          if (LastError.Messages.Count > 1)
          {
            lblOnTvNext.Label = String.Join(", ", LastError.Messages.ToArray(), 1, LastError.Messages.Count - 1);
            // 2nd and later in "NEXT"
          }
        }
        m_lastError = null; // reset member only, not the failing channel info in Navigator
      }
      else
      {
        if (lblCurrentChannel != null)
        {
          lblCurrentChannel.Label = channelName;
        }
        Channel chan = TVHome.Navigator.GetChannel(idChannel, true);
        Program prog = chan.GetProgramAt(m_dateTime);
        if (prog != null)
        {
          string strTime = String.Format("{0}-{1}",
                                         prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                         prog.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

          if (lblCurrentTime != null)
          {
            lblCurrentTime.Label = strTime;
          }

          if (lblOnTvNow != null)
          {
            lblOnTvNow.Label = prog.Title;
          }
          if (lblStartTime != null)
          {
            strTime = String.Format("{0}", prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
            lblStartTime.Label = strTime;
          }
          if (lblEndTime != null)
          {
            strTime = String.Format("{0} ", prog.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
            lblEndTime.Label = strTime;
          }

          // next program
          prog = chan.GetProgramAt(prog.EndTime.AddMinutes(1));
          //prog = TVHome.Navigator.GetChannel(channelName).GetProgramAt(prog.EndTime.AddMinutes(1));
          if (prog != null)
          {
            if (lblOnTvNext != null)
            {
              lblOnTvNext.Label = prog.Title;
            }
          }
        }
        else
        {
          lblOnTvNow.Label = GUILocalizeStrings.Get(736); // no epg for this channel

          if (lblStartTime != null)
          {
            lblStartTime.Label = String.Empty;
          }
          if (lblEndTime != null)
          {
            lblEndTime.Label = String.Empty;
          }
          if (lblCurrentTime != null)
          {
            lblCurrentTime.Label = String.Empty;
          }
        }
      }
      UpdateProgressBar();
    }
コード例 #12
0
        public List<WebActiveStream> GetActiveStreams()
        {
            IList<Card> cards = Card.ListAll();
              List<Channel> channels = new List<Channel>();
              TvControl.TvServer server = new TvControl.TvServer();
              List<User> _users = new List<User>();
              List<WebActiveStream> activestream = new List<WebActiveStream>();
              if(!ConnectToDatabase())
            return activestream;

              foreach (Card card in cards)
              {
            if (card.Enabled == false)
              continue;
            if (!RemoteControl.Instance.CardPresent(card.IdCard))
              continue;
            User[] users = RemoteControl.Instance.GetUsersForCard(card.IdCard);
            if (users == null)
              return activestream;

            for (int i = 0; i < users.Length; ++i)
            {
              User user = users[i];
              if (card.IdCard != user.CardId)
            continue;

              bool isRecording;
              bool isTimeShifting;

              VirtualCard tvcard = new VirtualCard(user, RemoteControl.HostName);
              isRecording = tvcard.IsRecording;
              isTimeShifting = tvcard.IsTimeShifting;
              if (isTimeShifting || (isRecording && !isTimeShifting))
              {
            int idChannel = tvcard.IdChannel;
            try
            {
              WebChannel channel = new WebChannel(Channel.Retrieve(idChannel));
              WebTvServerUser tvServerUser = new WebTvServerUser(tvcard.User);
              WebActiveStream stream = new WebActiveStream(tvServerUser, channel);
              activestream.Add(stream);
            }
            catch (Exception ex)
            {
              // FIXME: handle it
            }
              }
            }
              }
              return activestream;
        }
コード例 #13
0
    private void OnQuickRecord()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(GUILocalizeStrings.Get(891)); //Select TV Channel
      IList<GroupMap> channels = TVHome.Navigator.CurrentGroup.ReferringGroupMap();
      foreach (GroupMap chan in channels)
      {
        GUIListItem item = new GUIListItem(chan.ReferencedChannel().DisplayName);
        string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, chan.ReferencedChannel().DisplayName);
        if (string.IsNullOrEmpty(strLogo))                      
        {
          strLogo = "defaultVideoBig.png";
        }
        item.ThumbnailImage = strLogo;
        item.IconImageBig = strLogo;
        item.IconImage = strLogo;
        dlg.Add(item);
      }
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel < 0)
      {
        return;
      }

      Channel selectedChannel = (channels[dlg.SelectedLabel]).ReferencedChannel();
      dlg.Reset();
      dlg.SetHeading(616); //select recording type
      for (int i = 611; i <= 615; ++i)
      {
        dlg.Add(GUILocalizeStrings.Get(i));
      }
      dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WorkingDays)));
      dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WeekendDays)));

      Schedule rec = new Schedule(selectedChannel.IdChannel, "", Schedule.MinSchedule, Schedule.MinSchedule);

      TvBusinessLayer layer = new TvBusinessLayer();
      rec.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
      rec.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);
      rec.ScheduleType = (int)ScheduleRecordingType.Once;

      DateTime dtNow = DateTime.Now;
      int day;
      day = 0;

      dlg.Reset();
      dlg.SetHeading(142); //select time
      dlg.ShowQuickNumbers = false;
      //time
      //int no = 0;
      int hour, minute, steps;
      steps = 15;
      dlg.Add("00:00");
      for (hour = 0; hour <= 23; hour++)
      {
        for (minute = 0; minute < 60; minute += steps)
        {
          if (hour == 0 && minute == 0)
          {
            continue;
          }
          string time;
          if (hour < 10)
          {
            time = "0" + hour;
          }
          else
          {
            time = hour.ToString();
          }
          time += ":";
          if (minute < 10)
          {
            time = time + "0" + minute;
          }
          else
          {
            time += minute.ToString();
          }

          //if (hour < 1) time = String.Format("{0} {1}", minute, GUILocalizeStrings.Get(3004));
          dlg.Add(time);
        }
      }
      // pre-select the current time
      dlg.SelectedLabel = (DateTime.Now.Hour * (60 / steps)) + (Convert.ToInt16(DateTime.Now.Minute / steps));
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel == -1)
      {
        return;
      }

      int mins = (dlg.SelectedLabel) * steps;
      hour = (mins) / 60;
      minute = ((mins) % 60);


      dlg.Reset();
      dlg.SetHeading(180); //select time
      dlg.ShowQuickNumbers = false;
      //duration
      for (float hours = 0.5f; hours <= 24f; hours += 0.5f)
      {
        dlg.Add(String.Format("{0} {1}", hours.ToString("f2"), GUILocalizeStrings.Get(3002)));
      }
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel == -1)
      {
        return;
      }
      int duration = (dlg.SelectedLabel + 1) * 30;


      dtNow = DateTime.Now.AddDays(day);
      rec.StartTime = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, hour, minute, 0, 0);
      rec.EndTime = rec.StartTime.AddMinutes(duration);
      rec.ProgramName = GUILocalizeStrings.Get(413) + " (" + rec.ReferencedChannel().DisplayName + ")";

      rec.Persist();
      TvServer server = new TvServer();
      server.OnNewSchedule();
      GUIWindowManager.ShowPreviousWindow();
    }
コード例 #14
0
ファイル: TVHome.cs プロジェクト: Eddie-Jee/MediaPortal-1
    private void OnActiveStreams()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(692); // Active Tv Streams
      int selected = 0;
      string remoteHostName = string.Empty;
      IList<Card> cards = TvDatabase.Card.ListAll();
      List<Channel> channels = new List<Channel>();
      int count = 0;
      TvServer server = new TvServer();
      List<IUser> _users = new List<IUser>();
      foreach (Card card in cards)
      {
        if (card.Enabled == false)
        {
          continue;
        }
        if (!RemoteControl.Instance.CardPresent(card.IdCard))
        {
          continue;
        }
        IUser[] users = RemoteControl.Instance.GetUsersForCard(card.IdCard);

        if (users == null)
        {
          return;
        }
        for (int i = 0; i < users.Length; ++i)
        {
          IUser user = users[i];
          Log.Debug("rtsp url: {0}, {1}", user, RemoteControl.Instance.GetStreamingUrl(user));
          
          if (card.IdCard != user.CardId)
          {
            continue;
          }
          bool isRecording;
          bool isTimeShifting;
          VirtualCard tvcard = new VirtualCard(user, RemoteControl.HostName);
          isRecording = tvcard.IsRecording;
          isTimeShifting = tvcard.IsTimeShifting;
          if (isTimeShifting || (isRecording && !isTimeShifting))
          {
            int idChannel = tvcard.IdChannel;
            user = tvcard.User;
            Channel ch = Channel.Retrieve(idChannel);
            channels.Add(ch);
            GUIListItem item = new GUIListItem();
            item.Label = ch.DisplayName;
            item.Label2 = user.Name;
            string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, ch.DisplayName);
            if (string.IsNullOrEmpty(strLogo))
            {
              strLogo = "defaultVideoBig.png";
            }
            item.IconImage = strLogo;
            if (isRecording)
            {
              item.PinImage = Thumbs.TvRecordingIcon;
            }
            else
            {
              item.PinImage = "";
            }
            dlg.Add(item);
            _users.Add(user);
            if (Card != null && Card.IdChannel == idChannel)
            {
              selected = count;
            }
            count++;
          }
        }
      }
      if (channels.Count == 0)
      {
        GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
        if (pDlgOK != null)
        {
          pDlgOK.SetHeading(692); //my tv
          pDlgOK.SetLine(1, GUILocalizeStrings.Get(1511)); // No Active streams
          pDlgOK.SetLine(2, "");
          pDlgOK.DoModal(this.GetID);
        }
        return;
      }
      dlg.SelectedLabel = selected;
      dlg.DoModal(this.GetID);
      if (dlg.SelectedLabel < 0)
      {
 
        return;
      }

      string selectedUrl = RemoteControl.Instance.GetStreamingUrl(_users[dlg.SelectedLabel]);
      VirtualCard vCard = new VirtualCard(_users[dlg.SelectedLabel], RemoteControl.HostName);
      Channel channel = Navigator.GetChannel(vCard.IdChannel);
      User myUser = new User();

      /// Connect to the virtual user and play
      if (_users[dlg.SelectedLabel].Name.Contains("Placeshift Virtual User"))
      {
        if (inPlaceShift)
        {
          vPlaceshiftCard.StopTimeShifting();
        }
        else if (Card.IsTimeShifting)
        {
          Card.StopTimeShifting();
        }

        myUser.CardId = vCard.Id;

        // Replace the virtual user to local user
        RemoteControl.Instance.ReplaceTimeshiftUser(vCard.Id, myUser, _users[dlg.SelectedLabel].Name);

        // Send heartbeat ASAP
        RemoteControl.Instance.HeartBeat(myUser);

        if (!g_Player.Play(selectedUrl, g_Player.MediaType.TV, null, false))
        {
          StopPlayback();
        }

        // Seek to same position as the TV was stopped on another client.
        double TimeshiftPosition = RemoteControl.Instance.GetTimeshiftPosition(vCard.Id, myUser);
        g_Player.SeekAbsolute(TimeshiftPosition);

        Navigator.setChannel(channel);
        UpdateCurrentChannel();

        Log.Debug("placeshift selected active rtspUrl: {0} for channel: {1}, user: {2}, vCard.Id: {3}, TimeshiftPosition: {4}", 
          selectedUrl, channel.DisplayName, _users[dlg.SelectedLabel].Name, vCard.Id, TimeshiftPosition);

        // Setup vPlaceshiftCard for stoptimeshift
        vPlaceshiftCard = vCard;
        vPlaceshiftCard.User.Name = myUser.Name;
        inPlaceShift = true;
      }
      else
      {
        if (myUser.Name != _users[dlg.SelectedLabel].Name && OnShareTsBuffer())
        {
          if (inPlaceShift)
          {
            vPlaceshiftCard.StopTimeShifting();
          }
          else if (Card.IsTimeShifting)
          {
            Card.StopTimeShifting();
          }

          if (!g_Player.Play(selectedUrl, g_Player.MediaType.TV, null, false))
          {
            StopPlayback();
          }

          Navigator.setChannel(channel);
          UpdateCurrentChannel();

        }
        else
        {
         ViewChannel(channel);
        }
      }
    }
コード例 #15
0
ファイル: TVConflicts.cs プロジェクト: arangas/MediaPortal-1
    private void OnClick(int iItem)
    {
      m_iSelectedItem = GetSelectedItemNo();
      GUIListItem item = GetItem(iItem);
      if (item == null)
      {
        return;
      }
      if (item.IsFolder)
      {
        if (item.Label == "..")
        {
          if (selectedItem != null)
          {
            selectedItem = null;
          }
          LoadDirectory();
          return;
        }
        if (selectedItem == null)
        {
          selectedItem = item;
        }
        LoadDirectory();
        return;
      }

      Schedule schedule = item.TVTag as Schedule;
      if (schedule == null)
      {
        return;
      }

      if (schedule.ScheduleType == (int)ScheduleRecordingType.Once)
      {
        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
        if (null != dlgYesNo)
        {
          dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording?
          dlgYesNo.SetLine(1, schedule.ReferencedChannel().DisplayName);
          dlgYesNo.SetLine(2, schedule.ProgramName);
          dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure
          dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);

          if (dlgYesNo.IsConfirmed)
          {
            if (schedule.ScheduleType == (int)ScheduleRecordingType.Once)
            {
              schedule.Delete();
              selectedItem = null;
            }
          }
        }
      }
      else // advanced recording
      {
        GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
        if (dlg != null)
        {
          dlg.Reset();
          dlg.SetHeading(schedule.ProgramName);
          dlg.AddLocalizedString(981); //Delete this recording
          dlg.AddLocalizedString(982); //Delete series recording
          dlg.DoModal(GetID);
          if (dlg.SelectedLabel == -1)
          {
            return;
          }
          switch (dlg.SelectedId)
          {
            case 981: //delete specific series
              CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, schedule.IdChannel, schedule.StartTime);
              canceledSchedule.Persist();
              selectedItem = null;
              TvServer server = new TvServer();
              server.OnNewSchedule();
              break;
            case 982: //Delete entire recording
              schedule.Delete();
              selectedItem = null;
              break;
          }
        }
      }
      LoadDirectory();
    }
コード例 #16
0
 protected void Initialize()
 {
   _server = new TvServer();
 }
コード例 #17
0
    private void mpButtonTimeShift_Click(object sender, EventArgs e)
    {
      if (ServiceHelper.IsStopped) return;
      if (mpComboBoxChannels.SelectedItem == null) return;
      int id = ((ComboBoxExItem)mpComboBoxChannels.SelectedItem).Id;

      TvServer server = new TvServer();
      VirtualCard card = GetCardTimeShiftingChannel(id);
      if (card != null)
      {
        card.StopTimeShifting();
        mpButtonRec.Enabled = false;
      }
      else
      {
        string timeShiftingFilename = string.Empty;
        int cardId = -1;
        foreach (ListViewItem listViewItem in mpListView1.SelectedItems)
        {
          if (listViewItem.SubItems[2].Text != "disabled")
          {
            cardId = Convert.ToInt32(listViewItem.SubItems[0].Tag);
            break; // Keep the first card enabled selected only
          }
        }
        IUser user = new User();
        user.Name = "setuptv-" + id + "-" + cardId;
        user.IsAdmin = true;
        user.CardId = cardId;

        TvResult result = server.StartTimeShifting(ref user, id, out card, cardId != -1);
        if (result != TvResult.Succeeded)
        {
          switch (result)
          {
            case TvResult.NoPmtFound:
              MessageBox.Show(this, "No PMT found");
              break;
            case TvResult.NoSignalDetected:
              MessageBox.Show(this, "No signal");
              break;
            case TvResult.CardIsDisabled:
              MessageBox.Show(this, "Card is not enabled");
              break;
            case TvResult.AllCardsBusy:
              MessageBox.Show(this, "All cards are busy");
              break;
            case TvResult.ChannelIsScrambled:
              MessageBox.Show(this, "Channel is scrambled");
              break;
            case TvResult.NoVideoAudioDetected:
              MessageBox.Show(this, "No Video/Audio detected");
              break;
            case TvResult.UnableToStartGraph:
              MessageBox.Show(this, "Unable to create/start graph");
              break;
            case TvResult.ChannelNotMappedToAnyCard:
              MessageBox.Show(this, "Channel is not mapped to any card");
              break;
            case TvResult.NoTuningDetails:
              MessageBox.Show(this, "No tuning information available for this channel");
              break;
            case TvResult.UnknownChannel:
              MessageBox.Show(this, "Unknown channel");
              break;
            case TvResult.UnknownError:
              MessageBox.Show(this, "Unknown error occured");
              break;
            case TvResult.ConnectionToSlaveFailed:
              MessageBox.Show(this, "Cannot connect to slave server");
              break;
            case TvResult.NotTheOwner:
              MessageBox.Show(this, "Failed since card is in use and we are not the owner");
              break;
            case TvResult.GraphBuildingFailed:
              MessageBox.Show(this, "Unable to create graph");
              break;
            case TvResult.SWEncoderMissing:
              MessageBox.Show(this, "No suppported software encoder installed");
              break;
            case TvResult.NoFreeDiskSpace:
              MessageBox.Show(this, "No free disk space");
              break;
          }
        }
        else
        {
          mpButtonRec.Enabled = true;
        }
      }
    }
コード例 #18
0
ファイル: TvOSD.cs プロジェクト: cmendozac/MediaPortal-1
    private void SetRecorderStatus(bool forced)
    {
      if (imgRecIcon != null)
      {
        TimeSpan ts = DateTime.Now - _RecIconLastCheck;
        if (ts.TotalSeconds > 15 || forced)
        {
          bool isRecording = false;
          VirtualCard card;
          TvServer server = new TvServer();

          if (GetChannel() != null)
          {
            if (server.IsRecording(GetChannel().IdChannel, out card))
            {
              if (g_Player.IsTVRecording)
              {
                Recording rec = TvRecorded.ActiveRecording();
                if (rec != null)
                {
                  isRecording = TvRecorded.IsLiveRecording();
                }
              }
              else
              {
                isRecording = true;
              }
            }
          }

          imgRecIcon.Visible = isRecording;
          _RecIconLastCheck = DateTime.Now;
          Log.Info("OSD.SetRecorderStatus = {0}", imgRecIcon.Visible);
        }
      }
    }
コード例 #19
0
ファイル: TVHome.cs プロジェクト: splatterpop/MediaPortal-1
    private void OnActiveStreams()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(692); // Active Tv Streams
      int selected = 0;

      IList<Card> cards = TvDatabase.Card.ListAll();
      List<Channel> channels = new List<Channel>();
      int count = 0;
      TvServer server = new TvServer();
      List<IUser> _users = new List<IUser>();
      foreach (Card card in cards)
      {
        if (card.Enabled == false)
        {
          continue;
        }
        if (!RemoteControl.Instance.CardPresent(card.IdCard))
        {
          continue;
        }
        IUser[] users = RemoteControl.Instance.GetUsersForCard(card.IdCard);
        if (users == null)
        {
          return;
        }
        for (int i = 0; i < users.Length; ++i)
        {
          IUser user = users[i];
          if (card.IdCard != user.CardId)
          {
            continue;
          }
          bool isRecording;
          bool isTimeShifting;
          VirtualCard tvcard = new VirtualCard(user, RemoteControl.HostName);
          isRecording = tvcard.IsRecording;
          isTimeShifting = tvcard.IsTimeShifting;
          if (isTimeShifting || (isRecording && !isTimeShifting))
          {
            int idChannel = tvcard.IdChannel;
            user = tvcard.User;
            Channel ch = Channel.Retrieve(idChannel);
            channels.Add(ch);
            GUIListItem item = new GUIListItem();
            item.Label = ch.DisplayName;
            item.Label2 = user.Name;
            string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, ch.DisplayName);
            if (string.IsNullOrEmpty(strLogo))
            {
              strLogo = "defaultVideoBig.png";
            }
            item.IconImage = strLogo;
            if (isRecording)
            {
              item.PinImage = Thumbs.TvRecordingIcon;
            }
            else
            {
              item.PinImage = "";
            }
            dlg.Add(item);
            _users.Add(user);
            if (Card != null && Card.IdChannel == idChannel)
            {
              selected = count;
            }
            count++;
          }
        }
      }
      if (channels.Count == 0)
      {
        GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
        if (pDlgOK != null)
        {
          pDlgOK.SetHeading(692); //my tv
          pDlgOK.SetLine(1, GUILocalizeStrings.Get(1511)); // No Active streams
          pDlgOK.SetLine(2, "");
          pDlgOK.DoModal(this.GetID);
        }
        return;
      }
      dlg.SelectedLabel = selected;
      dlg.DoModal(this.GetID);
      if (dlg.SelectedLabel < 0)
      {
        return;
      }

      VirtualCard vCard = new VirtualCard(_users[dlg.SelectedLabel], RemoteControl.HostName);
      Channel channel = Navigator.GetChannel(vCard.IdChannel);
      ViewChannel(channel);
    }
コード例 #20
0
ファイル: TVUtil.cs プロジェクト: doskabouter/MediaPortal-1
    private static bool StopRecAndDeleteSchedule(Schedule schedule, Schedule parentSchedule, int idChannel, DateTime canceledStartTime)
    {
      bool wasCanceled = CancelEpisode(canceledStartTime, parentSchedule, idChannel);
      bool wasDeleted = false;
      if (canceledStartTime == schedule.StartTime)
      {
        bool isScheduleTypeOnce = IsScheduleTypeOnce(schedule.IdSchedule);

        wasDeleted = StopRecording(schedule);
        if (isScheduleTypeOnce && !wasDeleted)
        {
          wasDeleted = DeleteSchedule(schedule.IdSchedule);
        }        
      }
            
      TvServer server = new TvServer();
      server.OnNewSchedule();
      return wasDeleted || wasCanceled;
    }
コード例 #21
0
    public static void OnSetEpisodesToKeep(Schedule rec)
    {
      Schedule schedule = Schedule.Retrieve(rec.IdSchedule);
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(887); //quality settings
      dlg.ShowQuickNumbers = false;
      dlg.AddLocalizedString(889); //All episodes
      for (int i = 1; i < 40; ++i)
      {
        dlg.Add(i.ToString() + " " + GUILocalizeStrings.Get(874));
      }
      if (schedule.MaxAirings == Int32.MaxValue)
      {
        dlg.SelectedLabel = 0;
      }
      else
      {
        dlg.SelectedLabel = schedule.MaxAirings;
      }

      dlg.DoModal(GUIWindowManager.ActiveWindow);
      if (dlg.SelectedLabel == -1)
      {
        return;
      }

      if (dlg.SelectedLabel == 0)
      {
        schedule.MaxAirings = Int32.MaxValue;
      }
      else
      {
        schedule.MaxAirings = dlg.SelectedLabel;
      }
      schedule.Persist();
      TvServer server = new TvServer();
      server.OnNewSchedule();
    }
コード例 #22
0
ファイル: TVHome.cs プロジェクト: splatterpop/MediaPortal-1
    public static bool ManualRecord(Channel channel, int dialogId)
    {
      if (GUIWindowManager.ActiveWindowEx == (int)(int)Window.WINDOW_TVFULLSCREEN)
      {
        Log.Info("send message to fullscreen tv");
        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_RECORD, GUIWindowManager.ActiveWindow, 0, 0, 0, 0,
                                        null);
        msg.SendToTargetWindow = true;
        msg.TargetWindowId = (int)(int)Window.WINDOW_TVFULLSCREEN;
        GUIGraphicsContext.SendMessage(msg);
        return false;
      }

      Log.Info("TVHome:Record action");
      var server = new TvServer();

      VirtualCard card = null;
      Program prog = channel.CurrentProgram;
      bool isRecording;
      bool hasProgram = (prog != null);
      if (hasProgram)
      {
        prog.Refresh();//refresh the states from db
        isRecording = (prog.IsRecording || prog.IsRecordingOncePending);
      }
      else
      {
        isRecording = server.IsRecording(channel.IdChannel, out card);
      }

      if (!isRecording)
      {
        if (hasProgram)
        {
          GUIDialogMenuBottomRight pDlgOK =
            (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT);
          if (pDlgOK != null)
          {
            pDlgOK.Reset();
            pDlgOK.SetHeading(605); //my tv
            pDlgOK.AddLocalizedString(875); //current program

            bool doesManuelScheduleAlreadyExist = DoesManualScheduleAlreadyExist(channel);
            if (!doesManuelScheduleAlreadyExist)
            {
              pDlgOK.AddLocalizedString(876); //till manual stop
            }
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
            switch (pDlgOK.SelectedId)
            {
              case 875:
                //record current program                  
                TVProgramInfo.CreateProgram(prog, (int)ScheduleRecordingType.Once, dialogId);
                GUIMessage msgManualRecord = new GUIMessage(GUIMessage.MessageType.GUI_MSG_MANUAL_RECORDING_STARTED, 0, 0, 0, 0, 0, null);
                GUIWindowManager.SendMessage(msgManualRecord);
                return true;

              case 876:
                //manual
                StartRecordingSchedule(channel, true);
                return true;
             }
          }
        }
        else
        {
          //manual record
          StartRecordingSchedule(channel, true);
          return true;
        }
      }
      else
      {
        Schedule s = null;
        int idChannel = 0;
        if (hasProgram)
        {
          TVProgramInfo.IsRecordingProgram(prog, out s, false);
          if (s != null)
          {
            idChannel = s.ReferencedChannel().IdChannel;
          }
        }
        else
        {
          s = Schedule.Retrieve(card.RecordingScheduleId);
          idChannel = card.IdChannel;
        }

        if (s != null && idChannel > 0)
        {
          TVUtil.StopRecAndSchedWithPrompt(s, idChannel);
        }
      }
      return false;
    }
コード例 #23
0
ファイル: TVUtil.cs プロジェクト: doskabouter/MediaPortal-1
 private static bool StopRecAndDeleteEntireSchedule(Schedule schedule, Schedule parentSchedule, DateTime canceledStartTime)
 {
   int idChannel = schedule.IdChannel;      
   CancelEpisode(canceledStartTime, parentSchedule, idChannel);
   TvServer server = new TvServer();
   bool wasRecStopped = StopRecording(schedule);            
   bool wasDeleted = DeleteEntireOrOnceSchedule(schedule, parentSchedule);              
                     
   server.OnNewSchedule();
   return wasRecStopped || wasDeleted;
 }
コード例 #24
0
ファイル: TVHome.cs プロジェクト: splatterpop/MediaPortal-1
    /// <summary>
    /// Update the state of the following buttons    
    /// - record now
    /// </summary>
    private void UpdateStateOfRecButton()
    {
      if (!Connected)
      {
        btnTvOnOff.Selected = false;
        return;
      }
      bool isTimeShifting = Card.IsTimeShifting;

      //are we recording a tv program?      
      if (Navigator.Channel != null && Card != null)
      {
        string label;
        TvServer server = new TvServer();
        VirtualCard vc;
        if (server.IsRecording(Navigator.Channel.IdChannel, out vc))
        {
          if (!isTimeShifting)
          {
            Card = vc;
          }
          //yes then disable the timeshifting on/off buttons
          //and change the Record Now button into Stop Record
          label = GUILocalizeStrings.Get(629); //stop record
        }
        else
        {
          //nop. then change the Record Now button
          //to Record Now
          label = GUILocalizeStrings.Get(601); // record
        }
        if (label != btnRecord.Label)
        {
          btnRecord.Label = label;
        }
      }
    }
コード例 #25
0
ファイル: TVUtil.cs プロジェクト: doskabouter/MediaPortal-1
    private static bool PromptDeleteRecording(int idSchedule, Program prg)
    {
      bool confirmed = false;
      bool isRec = false;
      if (prg != null)
      {
        isRec = TvDatabase.Schedule.IsScheduleRecording(idSchedule, prg);  
      }
      else
      {
        var tvServer = new TvServer();
        VirtualCard vCard;
        isRec = tvServer.IsRecordingSchedule(idSchedule, out vCard);
      }      

      if (isRec)
      {
        confirmed = SetupConfirmDelRecDialogue();        
      }
      else
      {
        confirmed = true;
      }
      return confirmed;
    }
コード例 #26
0
ファイル: TVHome.cs プロジェクト: splatterpop/MediaPortal-1
    public static void StartRecordingSchedule(Channel channel, bool manual)
    {
      TvBusinessLayer layer = new TvBusinessLayer();
      TvServer server = new TvServer();
      if (manual) // until manual stop
      {
        Schedule newSchedule = new Schedule(channel.IdChannel,
                                            GUILocalizeStrings.Get(413) + " (" + channel.DisplayName + ")",
                                            DateTime.Now, DateTime.Now.AddDays(1));
        newSchedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
        newSchedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);
        newSchedule.Persist();
        server.OnNewSchedule();
      }
      else // current program
      {
        // lets find any canceled episodes that match this one we want to create, if found uncancel it.
        Schedule existingParentSchedule = Schedule.RetrieveSeries(channel.IdChannel, channel.CurrentProgram.Title,
                                                                  channel.CurrentProgram.StartTime,
                                                                  channel.CurrentProgram.EndTime);
        if (existingParentSchedule != null)
        {
          foreach (CanceledSchedule cancelSched in existingParentSchedule.ReferringCanceledSchedule())
          {
            if (cancelSched.CancelDateTime == channel.CurrentProgram.StartTime)
            {
              existingParentSchedule.UnCancelSerie(channel.CurrentProgram.StartTime, channel.CurrentProgram.IdChannel);
              server.OnNewSchedule();
              return;
            }
          }
        }

        // ok, no existing schedule found with matching canceled schedules found. proceeding to add the schedule normally
        Schedule newSchedule = new Schedule(channel.IdChannel, channel.CurrentProgram.Title,
                                            channel.CurrentProgram.StartTime, channel.CurrentProgram.EndTime);
        newSchedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
        newSchedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);        
        newSchedule.Persist();
        server.OnNewSchedule();
      }
      GUIMessage msgManualRecord = new GUIMessage(GUIMessage.MessageType.GUI_MSG_MANUAL_RECORDING_STARTED, 0, 0, 0, 0, 0, null);
      GUIWindowManager.SendMessage(msgManualRecord);
    }
コード例 #27
0
ファイル: TVUtil.cs プロジェクト: doskabouter/MediaPortal-1
 private static bool StopRecording(Schedule schedule)
 {
   bool stoppedRec = false;
   bool isRec = TvDatabase.Schedule.IsScheduleRecording(schedule.IdSchedule);
   if (isRec)
   {
     TvServer server = new TvServer();
     server.StopRecordingSchedule(schedule.IdSchedule);
     stoppedRec = true;
   }
   return stoppedRec;
 }
コード例 #28
0
    public static void CreateProgram(Program program, int scheduleType, int dialogId)
    {
      Log.Debug("TVProgramInfo.CreateProgram: program = {0}", program.ToString());
      Schedule schedule;
      Schedule saveSchedule = null;
      TvBusinessLayer layer = new TvBusinessLayer();
      if (IsRecordingProgram(program, out schedule, false)) // check if schedule is already existing
      {
        Log.Debug("TVProgramInfo.CreateProgram - series schedule found ID={0}, Type={1}", schedule.IdSchedule,
                  schedule.ScheduleType);
        Log.Debug("                            - schedule= {0}", schedule.ToString());
        //schedule = Schedule.Retrieve(schedule.IdSchedule); // get the correct informations
        if (schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel))
        {
          //lets delete the cancelled schedule.

          saveSchedule = schedule;
          schedule = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime);

          schedule.PreRecordInterval = saveSchedule.PreRecordInterval;
          schedule.PostRecordInterval = saveSchedule.PostRecordInterval;
          schedule.ScheduleType = (int)ScheduleRecordingType.Once; // needed for layer.GetConflictingSchedules(...)
        }
      }
      else
      {
        Log.Debug("TVProgramInfo.CreateProgram - no series schedule");
        // no series schedule => create it
        schedule = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime);
        schedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
        schedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);
        schedule.ScheduleType = scheduleType;
      }

      // check if this program is conflicting with any other already scheduled recording
      IList conflicts = layer.GetConflictingSchedules(schedule);
      Log.Debug("TVProgramInfo.CreateProgram - conflicts.Count = {0}", conflicts.Count);
      TvServer server = new TvServer();
      bool skipConflictingEpisodes = false;
      if (conflicts.Count > 0)
      {
        TVConflictDialog dlg =
          (TVConflictDialog)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_TVCONFLICT);
        if (dlg != null)
        {
          dlg.Reset();
          dlg.SetHeading(GUILocalizeStrings.Get(879)); // "recording conflict"
          foreach (Schedule conflict in conflicts)
          {
            Log.Debug("TVProgramInfo.CreateProgram: Conflicts = " + conflict);

            GUIListItem item = new GUIListItem(conflict.ProgramName);
            item.Label2 = GetRecordingDateTime(conflict);
            Channel channel = Channel.Retrieve(conflict.IdChannel);
            if (channel != null && !string.IsNullOrEmpty(channel.DisplayName))
            {
              item.Label3 = channel.DisplayName;
            }
            else
            {
              item.Label3 = conflict.IdChannel.ToString();
            }
            item.TVTag = conflict;
            dlg.AddConflictRecording(item);
          }
          dlg.ConflictingEpisodes = (scheduleType != (int)ScheduleRecordingType.Once);
          dlg.DoModal(dialogId);
          switch (dlg.SelectedLabel)
          {
            case 0: // Skip new Recording
              {
                Log.Debug("TVProgramInfo.CreateProgram: Skip new recording");
                return;
              }
            case 1: // Don't record the already scheduled one(s)
              {
                Log.Debug("TVProgramInfo.CreateProgram: Skip old recording(s)");
                foreach (Schedule conflict in conflicts)
                {
                  Program prog =
                    new Program(conflict.IdChannel, conflict.StartTime, conflict.EndTime, conflict.ProgramName, "-", "-",
                                Program.ProgramState.None,
                                DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                string.Empty, -1);
                  CancelProgram(prog, Schedule.Retrieve(conflict.IdSchedule), dialogId);
                }
                break;
              }
            case 2: // keep conflict
              {
                Log.Debug("TVProgramInfo.CreateProgram: Keep Conflict");
                break;
              }
            case 3: // Skip for conflicting episodes
              {
                Log.Debug("TVProgramInfo.CreateProgram: Skip conflicting episode(s)");
                skipConflictingEpisodes = true;
                break;
              }
            default: // Skipping new Recording
              {
                Log.Debug("TVProgramInfo.CreateProgram: Default => Skip new recording");
                return;
              }
          }
        }
      }

      if (saveSchedule != null)
      {
        Log.Debug("TVProgramInfo.CreateProgram - UnCancleSerie at {0}", program.StartTime);
        saveSchedule.UnCancelSerie(program.StartTime, program.IdChannel);
        //saveSchedule.UnCancelSerie();
        saveSchedule.Persist();
        currentSchedule = saveSchedule;
      }
      else
      {
        Log.Debug("TVProgramInfo.CreateProgram - create schedule = {0}", schedule.ToString());
        schedule.Persist();

        if (currentSchedule == null || (currentSchedule.ScheduleType > 0 && schedule.ScheduleType != (int)ScheduleRecordingType.Once))
        {
          currentSchedule = schedule;
        }
      }
      if (skipConflictingEpisodes)
      {
        List<Schedule> episodes = layer.GetRecordingTimes(schedule);
        foreach (Schedule episode in episodes)
        {
          if (DateTime.Now > episode.EndTime)
          {
            continue;
          }
          if (episode.IsSerieIsCanceled(episode.StartTime, program.IdChannel))
          {
            continue;
          }
          foreach (Schedule conflict in conflicts)
          {
            if (episode.IsOverlapping(conflict))
            {
              Log.Debug("TVProgramInfo.CreateProgram - skip episode = {0}", episode.ToString());
              CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, program.IdChannel, episode.StartTime);
              canceledSchedule.Persist();
            }
          }
        }
      }
      server.OnNewSchedule();
    }
コード例 #29
0
    private void ShowContextMenu()
    {
      if (dlg == null)
      {
        dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      }
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(924); // menu

      if (!g_Player.IsTVRecording && GUIGraphicsContext.DBLClickAsRightClick)
      {
        dlg.AddLocalizedString(10104); // TV MiniEPG
      }

      //dlg.AddLocalizedString(915); // TV Channels
      if (!g_Player.IsTVRecording)
      {
        dlg.AddLocalizedString(4); // TV Guide}
      }

      TvBusinessLayer layer = new TvBusinessLayer();
      IList<ChannelLinkageMap> linkages = null;
      if (!g_Player.IsTVRecording)
      {
        linkages = layer.GetLinkagesForChannel(TVHome.Navigator.Channel);
        if (linkages != null)
        {
          if (linkages.Count > 0)
          {
            dlg.AddLocalizedString(200042); // Linked Channels
          }
        }
      }

    /*if (TVHome.Navigator.Groups.Count > 1)
        dlg.AddLocalizedString(971); // Group*/
      if (!g_Player.IsTVRecording && TVHome.Card.HasTeletext)
      {
        dlg.AddLocalizedString(1441); // Fullscreen teletext
      }
      dlg.AddLocalizedString(941); // Change aspect ratio

      // msn related can be removed
      //if (PluginManager.IsPluginNameEnabled("MSN Messenger"))
      //{
      //  dlg.AddLocalizedString(12902); // MSN Messenger
      //  dlg.AddLocalizedString(902); // MSN Online contacts
      //}

      //IAudioStream[] streams = TVHome.Card.AvailableAudioStreams;
      //if (streams != null && streams.Length > 0)
      if (g_Player.AudioStreams > 0)
      {
        dlg.AddLocalizedString(492); // Audio language menu
      }

      eAudioDualMonoMode dualMonoMode = g_Player.GetAudioDualMonoMode();
      if (dualMonoMode != eAudioDualMonoMode.UNSUPPORTED)
      {
        dlg.AddLocalizedString(200059); // Audio dual mono mode menu
      }

      // SubTitle stream, show only when there exists any streams,
      //    dialog shows then the streams and an item to disable them
      if (g_Player.SubtitleStreams > 0 || g_Player.SupportsCC)
      {
        dlg.AddLocalizedString(462);
      }

      // If the decoder supports postprocessing features (FFDShow)
      if (g_Player.HasPostprocessing)
      {
        dlg.AddLocalizedString(200073);
      }

      dlg.AddLocalizedString(11000); // Crop settings

      if (!g_Player.IsTVRecording)
      {
        dlg.AddLocalizedString(100748); // Program Information
      }

      if (!g_Player.IsTVRecording && Utils.FileExistsInCache(GUIGraphicsContext.Skin + @"\mytvtuningdetails.xml"))
      {
        dlg.AddLocalizedString(200041); // tuning details
      }

      TvServer server = new TvServer();
      if (!g_Player.IsTVRecording)
      {
        VirtualCard vc;
        if (server.IsRecording(TVHome.Navigator.Channel.IdChannel, out vc))
        {
          dlg.AddLocalizedString(265); //stop rec.
        }
        else
        {
          dlg.AddLocalizedString(601); //Record Now        
        }
      }

      if (TVHome.Card.CiMenuSupported() && !g_Player.IsTVRecording)
        dlg.AddLocalizedString(2700); // CI Menu supported

      //dlg.AddLocalizedString(6008); // Sort TvChannel

      if (!g_Player.IsTVRecording && TVHome.Card.IsOwner() && !TVHome.Card.IsRecording &&
          TVHome.Card.SupportsQualityControl())
      {
        dlg.AddLocalizedString(882);
      }

      if (g_Player.HasChapters) // For recordings with chapters
      {
        dlg.AddLocalizedString(200091);
      }
      dlg.AddLocalizedString(368); // IMDB
      dlg.AddLocalizedString(970); // Previous window

      _isDialogVisible = true;

      dlg.DoModal(GetID);
      _isDialogVisible = false;

      Log.Debug("selected id:{0}", dlg.SelectedId);
      if (dlg.SelectedId == -1)
      {
        return;
      }
      switch (dlg.SelectedId)
      {
        case 4: // TVGuide
          {
            TvNewScheduleSearch.SearchFor = TvNewScheduleSearch.SearchType.KeyWord;
            GUIWindowManager.ActivateWindow((int)Window.WINDOW_TVGUIDE);
            break;
          }

        case 10104: // MiniEPG
          {
            ShowMiniEpg();
            break;
          }

        case 941: // Change aspect ratio
          ShowAspectRatioMenu();
          break;

        case 2700: // Open CI Menu
          PrepareCiMenu();
          break;

        //case 6008: // TvChannel sort
        //  SortChannels();
        //  break;

        case 492: // Show audio language menu
          ShowAudioLanguageMenu();
          break;

        case 200059:
          ShowAudioDualMonoModeMenu(dualMonoMode);
          break;

        case 1441: // Fullscreen teletext
          GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_TELETEXT);
          break;

        case 970:
          // switch back to previous window
          _isOsdVisible = false;
          GUIWindowManager.IsOsdVisible = false;
          GUIGraphicsContext.IsFullScreenVideo = false;
          GUIWindowManager.ShowPreviousWindow();
          break;

        case 11000:
          TvCropSettings cropSettings =
            (TvCropSettings)GUIWindowManager.GetWindow((int)Window.WINDOW_TV_CROP_SETTINGS);
          _isDialogVisible = true;
          cropSettings.DoModal(GetID);
          _isDialogVisible = false;
          break;

        case 100748: // Show Program Info
          ShowProgramInfo();
          break;

        case 601: // RecordNow          
        case 265: // StopRec.          
          TVHome.ManualRecord(TVHome.Navigator.Channel, GetID);
          break;

        case 200042: // Linked channels
          CacheManager.Clear();
          linkages = layer.GetLinkagesForChannel(TVHome.Navigator.Channel);
          ShowLinkedChannelsMenu(linkages);
          break;

        case 200041: // Tuning details
          GUIWindowManager.ActivateWindow((int)Window.WINDOW_TV_TUNING_DETAILS);
          break;

        case 882: // Quality settings
          ShowQualitySettingsMenu();
          break;

        case 368: // IMDB
          OnGetIMDBInfo();
          break;

        case 200091:
          ShowChapterStreamsMenu();
          break;

        case 462:
          ShowSubtitleStreamsMenu();
          break;

        case 200073:
          ShowPostProcessingMenu();
          break;
      }
    }
コード例 #30
0
    private void OnPreRecordInterval()
    {
      Schedule rec = currentSchedule;
      if (currentSchedule == null && !IsRecordingProgram(CurrentProgram, out rec, false))
      {
        return;
      }
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg != null)
      {
        dlg.Reset();
        dlg.ShowQuickNumbers = false;
        dlg.SetHeading(GUILocalizeStrings.Get(1444)); //pre-record

        foreach (int interval in RecordingIntervalValues)
        {
          if (interval == 1)
          {
            if (interval == _preRec)
            {
              dlg.Add(String.Format("{0} {1}", interval,
                                    GUILocalizeStrings.Get(3003) + " (" + GUILocalizeStrings.Get(886) + ")"));
              // minute (default)
            }
            else
            {
              dlg.Add(String.Format("{0} {1}", interval, GUILocalizeStrings.Get(3003))); // minute
            }
          }
          else
          {
            if (interval == _preRec)
            {
              dlg.Add(String.Format("{0} {1}", interval,
                                    GUILocalizeStrings.Get(3004) + " (" + GUILocalizeStrings.Get(886) + ")"));
              // minutes (default)
            }
            else
            {
              dlg.Add(String.Format("{0} {1}", interval, GUILocalizeStrings.Get(3004))); // minutes
            }
          }
        }

        if (rec.PreRecordInterval < 0)
        {
          dlg.SelectedLabel = 0;
        }
        else if (RecordingIntervalValues.IndexOf(rec.PreRecordInterval) == -1)
        {
          RecordingIntervalValues.IndexOf(_preRec); // select default if the value is not part of the list
        }
        else
        {
          dlg.SelectedLabel = RecordingIntervalValues.IndexOf(rec.PreRecordInterval);
        }

        dlg.DoModal(GetID);

        if (dlg.SelectedLabel < 0)
        {
          return;
        }

        rec.PreRecordInterval = RecordingIntervalValues[dlg.SelectedLabel];
        rec.Persist();
        currentSchedule = rec;
        
        Schedule assocSchedule = Schedule.RetrieveSpawnedSchedule(rec.IdSchedule, rec.StartTime);

        if (assocSchedule != null)
        {
          assocSchedule.PreRecordInterval = rec.PreRecordInterval;
          assocSchedule.Persist();
        }

        TvServer server = new TvServer();
        server.OnNewSchedule();
      }
      Update();
    }
コード例 #31
0
    private void UpdateGUI()
    {
      // Set recorder status
      VirtualCard card;
      var server = new TvServer();
      if (server.IsRecording(TVHome.Navigator.Channel.IdChannel, out card))
      {
        ShowControl(GetID, (int)Control.REC_LOGO);
      }
      else
      {
        HideControl(GetID, (int)Control.REC_LOGO);
      }

      int speed = g_Player.Speed;
      HideControl(GetID, (int)Control.IMG_2X);
      HideControl(GetID, (int)Control.IMG_4X);
      HideControl(GetID, (int)Control.IMG_8X);
      HideControl(GetID, (int)Control.IMG_16X);
      HideControl(GetID, (int)Control.IMG_32X);
      HideControl(GetID, (int)Control.IMG_MIN2X);
      HideControl(GetID, (int)Control.IMG_MIN4X);
      HideControl(GetID, (int)Control.IMG_MIN8X);
      HideControl(GetID, (int)Control.IMG_MIN16X);
      HideControl(GetID, (int)Control.IMG_MIN32X);

      switch (speed)
      {
        case 2:
          ShowControl(GetID, (int)Control.IMG_2X);
          break;
        case 4:
          ShowControl(GetID, (int)Control.IMG_4X);
          break;
        case 8:
          ShowControl(GetID, (int)Control.IMG_8X);
          break;
        case 16:
          ShowControl(GetID, (int)Control.IMG_16X);
          break;
        case 32:
          ShowControl(GetID, (int)Control.IMG_32X);
          break;
        case -2:
          ShowControl(GetID, (int)Control.IMG_MIN2X);
          break;
        case -4:
          ShowControl(GetID, (int)Control.IMG_MIN4X);
          break;
        case -8:
          ShowControl(GetID, (int)Control.IMG_MIN8X);
          break;
        case -16:
          ShowControl(GetID, (int)Control.IMG_MIN16X);
          break;
        case -32:
          ShowControl(GetID, (int)Control.IMG_MIN32X);
          break;
      }

      HideControl(GetID, (int)Control.LABEL_ROW1);
      HideControl(GetID, (int)Control.LABEL_ROW2);
      HideControl(GetID, (int)Control.LABEL_ROW3);
      HideControl(GetID, (int)Control.BLUE_BAR);
      if (_screenState.SeekStep != 0)
      {
        ShowControl(GetID, (int)Control.BLUE_BAR);
        ShowControl(GetID, (int)Control.LABEL_ROW1);
      }
      if (_statusVisible)
      {
        ShowControl(GetID, (int)Control.BLUE_BAR);
        ShowControl(GetID, (int)Control.LABEL_ROW1);
      }
      if (_groupVisible)
      {
        ShowControl(GetID, (int)Control.BLUE_BAR);
        ShowControl(GetID, (int)Control.LABEL_ROW1);
      }
      //if (_channelInputVisible)
      //{
      //  ShowControl(GetID, (int)Control.LABEL_ROW1);
      //}
      HideControl(GetID, (int)Control.MSG_BOX);
      HideControl(GetID, (int)Control.MSG_BOX_LABEL1);
      HideControl(GetID, (int)Control.MSG_BOX_LABEL2);
      HideControl(GetID, (int)Control.MSG_BOX_LABEL3);
      HideControl(GetID, (int)Control.MSG_BOX_LABEL4);

      if (_messageBoxVisible)
      {
        ShowControl(GetID, (int)Control.MSG_BOX);
        ShowControl(GetID, (int)Control.MSG_BOX_LABEL1);
        ShowControl(GetID, (int)Control.MSG_BOX_LABEL2);
        ShowControl(GetID, (int)Control.MSG_BOX_LABEL3);
        ShowControl(GetID, (int)Control.MSG_BOX_LABEL4);
      }

      RenderVolume(_isVolumeVisible);
    }