protected override bool UpdateRecordingStatus(IProgram program) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus == null) { return(false); } ChannelProgramListItem programChannel = _channelList.OfType <ChannelProgramListItem>().FirstOrDefault(c => c.Channel.ChannelId == program.ChannelId); if (programChannel == null) { return(false); } ProgramListItem listProgram; lock (programChannel.Programs.SyncRoot) { listProgram = programChannel.Programs.OfType <ProgramListItem>().FirstOrDefault(p => p.Program.ProgramId == program.ProgramId); if (listProgram == null) { return(false); } } listProgram.Program.UpdateState(recordingStatus.RecordingStatus); return(true); }
public override Task <AsyncResult <RecordingStatus> > GetRecordingStatusAsync(IProgram program) { IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); IProgramRecordingStatus recProgram = (IProgramRecordingStatus)GetProgram(programService.GetProgram(program.ProgramId), true); return(Task.FromResult(new AsyncResult <RecordingStatus>(true, recProgram.RecordingStatus))); }
/// <summary> /// Tries to update a program item, i.e. if recording status was changed. /// </summary> /// <param name="program">Program</param> private void UpdateProgramStatus(IProgram program) { if (program == null) { return; } FrameworkElement control = GetProgramItems().FirstOrDefault(el => { ProgramListItem programListItem = (ProgramListItem)el.Context; if (programListItem == null) { return(false); } ProgramProperties programProperties = programListItem.Program; return(programProperties != null && programProperties.ProgramId == program.ProgramId); }); if (control == null) { return; } // Update properties IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus != null) { ((ProgramListItem)control.Context).Program.UpdateState(recordingStatus.RecordingStatus); } }
public bool GetRecordingStatus(IProgram program, out RecordingStatus recordingStatus) { IProgramService programService = GlobalServiceProvider.Get <IProgramService>(); IProgramRecordingStatus recProgram = (IProgramRecordingStatus)programService.GetProgram(program.ProgramId).ToProgram(true); recordingStatus = recProgram.RecordingStatus; return(true); }
public override async Task <AsyncResult <ContentDirectoryMessaging.MediaItemChangeType> > ProcessAsync(MediaItem mediaItem) { var falseResult = new AsyncResult <ContentDirectoryMessaging.MediaItemChangeType>(false, ContentDirectoryMessaging.MediaItemChangeType.None); if (_schedule != null) { var tvHandler = ServiceRegistration.Get <ITvHandler>(false); if (tvHandler != null && tvHandler.ScheduleControl != null) { bool deleteWholeSchedule = true; if (_schedule.IsSeries) { // Schedule is a series - we only want to stop the recording of the current program var programs = await tvHandler.ScheduleControl.GetProgramsForScheduleAsync(_schedule); if (programs.Success) { deleteWholeSchedule = false; foreach (IProgram program in programs.Result) { IProgramRecordingStatus s = program as IProgramRecordingStatus; // If this program is recording, just cancel this recording, not the whole schedule. if (s != null && s.RecordingStatus.HasFlag(RecordingStatus.Recording)) { await tvHandler.ScheduleControl.RemoveScheduleForProgramAsync(program, ScheduleRecordingType.Once); } } } } if (deleteWholeSchedule) { var result = tvHandler.ScheduleControl.RemoveScheduleAsync(_schedule).Result; if (!result) { ServiceRegistration.Get <ILogger>().Warn("DeleteRecordingFromStorage: Failed to remove current schedule."); return(falseResult); } } } } // When the recording is stopped, it will be imported into library. This can lead to locked files by MetaDataExtractors. // So we allow some retries after a small delay here. for (int i = 1; i <= 3; i++) { var res = await base.ProcessAsync(mediaItem); if (res.Success) { return(res); } ServiceRegistration.Get <ILogger>().Info("DeleteRecordingFromStorage: Failed to delete recording (try {0})", i); await Task.Delay(i * 1000); } ServiceRegistration.Get <ILogger>().Warn("DeleteRecordingFromStorage: Failed to delete recording."); return(falseResult); }
public void SetProgram(IProgram program) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus != null) { UpdateState(recordingStatus.RecordingStatus); } try { IChannel channel; IChannelAndGroupInfo channelAndGroupInfo = ServiceRegistration.Get <ITvHandler>().ChannelAndGroupInfo; if (program != null && channelAndGroupInfo != null && channelAndGroupInfo.GetChannel(program.ChannelId, out channel)) { ChannelName = channel.Name; } _settingProgram = true; IProgramSeries series = program as IProgramSeries; if (series != null) { SeasonNumber = series.SeasonNumber; EpisodeNumber = series.EpisodeNumber; EpisodeTitle = series.EpisodeTitle; Series = BuildSeriesText(this); } else { SeasonNumber = string.Empty; EpisodeNumber = string.Empty; EpisodeTitle = string.Empty; Series = string.Empty; } if (program != null) { ProgramId = program.ProgramId; Title = program.Title; Description = program.Description; StartTime = program.StartTime; EndTime = program.EndTime; Genre = program.Genre; } else { ProgramId = 0; Title = string.Empty; Description = string.Empty; StartTime = DateTime.Now.GetDay(); EndTime = StartTime.AddDays(1); Genre = string.Empty; } UpdateDuration(); } finally { _settingProgram = false; } }
public bool GetRecordingStatus(IProgram program, out RecordingStatus recordingStatus) { #if TVE3 var tvProgram = (IProgramRecordingStatus)TvDatabase.Program.Retrieve(program.ProgramId).ToProgram(true); recordingStatus = tvProgram.RecordingStatus; #else IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); IProgramRecordingStatus recProgram = (IProgramRecordingStatus)programService.GetProgram(program.ProgramId).ToProgram(true); recordingStatus = recProgram.RecordingStatus; #endif return(true); }
protected virtual bool UpdateRecordingStatus(IProgram program, RecordingStatus newStatus) { IProgramRecordingStatus status = program as IProgramRecordingStatus; if (status == null) { return(false); } status.RecordingStatus = newStatus; return(true); }
protected virtual bool UpdateRecordingStatus(IProgram program, RecordingStatus newStatus) { IProgramRecordingStatus status = program as IProgramRecordingStatus; if (status == null) { return(false); } status.RecordingStatus = newStatus; SlimTvClientMessaging.SendSlimTvProgramChangedMessage(program); return(true); }
public void SetProgram(IProgram program) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus != null) { UpdateState(recordingStatus.RecordingStatus); } try { _settingProgram = true; IProgramSeries series = program as IProgramSeries; if (series != null) { SeasonNumber = series.SeasonNumber; EpisodeNumber = series.EpisodeNumber; EpisodeTitle = series.EpisodeTitle; Series = BuildSeriesText(this); } else { SeasonNumber = string.Empty; EpisodeNumber = string.Empty; EpisodeTitle = string.Empty; Series = string.Empty; } if (program != null) { ProgramId = program.ProgramId; Title = program.Title; Description = program.Description; StartTime = program.StartTime; EndTime = program.EndTime; Genre = program.Genre; } else { ProgramId = 0; Title = string.Empty; Description = string.Empty; StartTime = DateTime.Now.GetDay(); EndTime = StartTime.AddDays(1); Genre = string.Empty; } UpdateDuration(); } finally { _settingProgram = false; } }
protected virtual bool UpdateRecordingStatus(IProgram program, RecordingStatus status, ScheduleRecordingType type) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus == null || recordingStatus.RecordingStatus == status) { return(false); } RecordingStatus oldStatus = recordingStatus.RecordingStatus; recordingStatus.RecordingStatus = (RecordingStatus)status; OnRecordingStatusChanged(program, oldStatus, status, type); return(true); }
protected override bool UpdateRecordingStatus(IProgram program) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus == null) { return(false); } foreach (var programItem in _programsList.OfType <ProgramListItem>().Where(programItem => programItem.Program.ProgramId == program.ProgramId)) { programItem.Program.UpdateState(recordingStatus.RecordingStatus); } return(true); }
internal static WebProgramDetailed ProgramDetailed(IProgram program) { if (program == null) { return(new WebProgramDetailed()); } IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; IProgramSeries programSeries = program as IProgramSeries; WebProgramBasic webProgramBasic = BaseProgramBasic.ProgramBasic(program); WebProgramDetailed webProgramDetailed = new WebProgramDetailed { // From Basic Description = webProgramBasic.Description, ChannelId = webProgramBasic.ChannelId, StartTime = webProgramBasic.StartTime, EndTime = webProgramBasic.EndTime, Title = webProgramBasic.Title, Id = webProgramBasic.Id, DurationInMinutes = webProgramBasic.DurationInMinutes, Classification = program.Classification, OriginalAirDate = program.OriginalAirDate ?? DateTime.Now, ParentalRating = program.ParentalRating, StarRating = program.StarRating, IsScheduled = webProgramBasic.IsScheduled, Genre = program.Genre, IsRecording = recordingStatus != null && recordingStatus.RecordingStatus != RecordingStatus.None, IsRecordingSeriesPending = recordingStatus != null && recordingStatus.RecordingStatus == RecordingStatus.SeriesScheduled, IsRecordingOncePending = recordingStatus != null && recordingStatus.RecordingStatus == RecordingStatus.Scheduled, IsRecordingSeries = recordingStatus != null && recordingStatus.RecordingStatus == RecordingStatus.RecordingSeries, IsRecordingManual = recordingStatus != null && recordingStatus.RecordingStatus == RecordingStatus.RecordingManual, IsRecordingOnce = recordingStatus != null && recordingStatus.RecordingStatus == RecordingStatus.RecordingOnce, HasConflict = recordingStatus != null && recordingStatus.HasConflict, SeriesNum = programSeries.SeasonNumber, EpisodeNum = programSeries.EpisodeNumber, EpisodeName = programSeries.EpisodeTitle, EpisodeNumber = programSeries.EpisodeNumberDetailed, EpisodePart = programSeries.EpisodePart, }; //webProgramDetailed.IsPartialRecordingSeriesPending; return(webProgramDetailed); }
public void SetProgram(IProgram program) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus != null) { IsScheduled = recordingStatus.RecordingStatus != RecordingStatus.None; } if (program != null) { ProgramId = program.ProgramId; Title = program.Title; Description = program.Description; StartTime = program.StartTime; EndTime = program.EndTime; Genre = program.Genre; UpdateDuration(); } }
internal static WebProgramBasic ProgramBasic(IProgram program) { if (program == null) { return(new WebProgramBasic()); } IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; WebProgramBasic webProgramBasic = new WebProgramBasic { Description = program.Description, ChannelId = program.ChannelId, StartTime = program.StartTime, EndTime = program.EndTime, Title = program.Title, Id = program.ProgramId, DurationInMinutes = Convert.ToInt32(program.EndTime.Subtract(program.StartTime).TotalMinutes), IsScheduled = recordingStatus?.RecordingStatus != RecordingStatus.None }; return(webProgramBasic); }
public void SetProgram(IProgram program) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus != null) { IsScheduled = recordingStatus.RecordingStatus != RecordingStatus.None; } try { _settingProgram = true; if (program != null) { ProgramId = program.ProgramId; Title = program.Title; Description = program.Description; StartTime = program.StartTime; EndTime = program.EndTime; Genre = program.Genre; } else { ProgramId = 0; Title = string.Empty; Description = string.Empty; StartTime = FormatHelper.GetDay(DateTime.Now); EndTime = StartTime.AddDays(1); Genre = string.Empty; } UpdateDuration(); } finally { _settingProgram = false; } }
public void SetProgram(IProgram program, IChannel channel = null) { IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus; if (recordingStatus != null) { UpdateState(recordingStatus.RecordingStatus); } try { if (channel == null && program != null) { IChannelAndGroupInfoAsync channelAndGroupInfo = ServiceRegistration.Get <ITvHandler>().ChannelAndGroupInfo; if (channelAndGroupInfo != null) { var result = channelAndGroupInfo.GetChannelAsync(program.ChannelId).Result; if (result.Success) { channel = result.Result; } } } ChannelName = channel?.Name ?? ""; ChannelNumber = channel?.ChannelNumber ?? 0; ChannelLogoType = channel.GetFanArtMediaType(); _settingProgram = true; IProgramSeries series = program as IProgramSeries; if (series != null) { SeasonNumber = series.SeasonNumber; EpisodeNumber = series.EpisodeNumber; EpisodeTitle = series.EpisodeTitle; Series = BuildSeriesText(this); } else { SeasonNumber = string.Empty; EpisodeNumber = string.Empty; EpisodeTitle = string.Empty; Series = string.Empty; } if (program != null) { ProgramId = program.ProgramId; Title = program.Title; Description = program.Description; StartTime = program.StartTime; EndTime = program.EndTime; Genre = program.Genre; EpgGenreId = program.EpgGenreId; EpgGenreColor = program.EpgGenreColor; } else { ProgramId = -1; Title = string.Empty; Description = string.Empty; StartTime = DateTime.Now.GetDay(); EndTime = StartTime.AddDays(1); Genre = string.Empty; EpgGenreId = 0; EpgGenreColor = string.Empty; } NoProgramData = ProgramId == -1; UpdateDuration(); } finally { _settingProgram = false; } }
public bool IsAvailable(IProgram program ) { IProgramRecordingStatus s = program as IProgramRecordingStatus; return s == null || s.RecordingStatus != RecordingStatus.Recording; }