Esempio n. 1
0
        public void SaveImage()
        {
            if (!Recording)
            {
                return;
            }

            if (RecordingsCollection != null && AssociatedObject.IsCapturing)
            {
                RecordingsCollection.Add(AssociatedObject.GetCurrentImage());
            }
            Recording = false;
        }
        internal void UpdateSheduledTVRecordings()
        {
            try
            {
                Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled.count", "0");
                for (int z = 1; z <= Utils.LatestsMaxTVNum; z++)
                {
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".title", string.Empty);
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".startTime", string.Empty);
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".startDate", string.Empty);
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".endTime", string.Empty);
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".endDate", string.Empty);
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".channel", string.Empty);
                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".channelLogo", string.Empty);
                }
                if (Proxies.IsInitialized)
                {
                    List <UpcomingRecording> recordings = null;
                    recordings = Proxies.ControlService.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings | UpcomingRecordingsFilter.CancelledByUser, false).Result;

                    int i = 1;
                    RecordingsCollection latestRecordings = new RecordingsCollection();
                    if (recordings != null)
                    {
                        foreach (UpcomingRecording rec in recordings)
                        {
                            string logoImagePath = GetLogoPath(rec.Program.Channel.ChannelId, rec.Program.Channel.DisplayName, 84, 84);
                            if (string.IsNullOrEmpty(logoImagePath) || !System.IO.File.Exists(logoImagePath))
                            {
                                logoImagePath = "defaultVideoBig.png";
                            }

                            latestRecordings.Add(new LatestRecording(rec.Program.Title, null, rec.Program.ActualStartTime,
                                                                     String.Format("{0:" + Utils.DateFormat + "}", rec.Program.ActualStartTime),
                                                                     rec.Program.ActualStartTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                     String.Format("{0:" + Utils.DateFormat + "}", rec.Program.ActualStopTime),
                                                                     rec.Program.ActualStopTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                     rec.Program.Channel.DisplayName, logoImagePath));
                            Utils.ThreadToSleep();
                        }

                        latestRecordings.Sort(new LatestRecordingsComparer());

                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled.count", latestRecordings.Count.ToString());
                        for (int x0 = 0; x0 < latestRecordings.Count; x0++)
                        {
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".title", latestRecordings[x0].Title);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".startTime", latestRecordings[x0].StartTime);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".startDate", latestRecordings[x0].StartDate);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".endTime", latestRecordings[x0].EndTime);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".endDate", latestRecordings[x0].EndDate);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".channel", latestRecordings[x0].Channel);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".channelLogo", latestRecordings[x0].ChannelLogo);

                            if (i == Utils.LatestsMaxTVNum)
                            {
                                break;
                            }
                            i++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("GetTVRecordings (Scheduled Recordings): " + ex.ToString());
            }
        }
        internal void UpdateSheduledTVRecordings()
        {
            if (TVHome.Connected)
            {
                try
                {
                    IList <TvDatabase.Schedule> schedules = TvDatabase.Schedule.ListAll();

                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled.count", "0");
                    for (int z = 1; z <= Utils.LatestsMaxTVNum; z++)
                    {
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".title", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".startTime", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".startDate", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".endTime", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".endDate", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".channel", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + z + ".channelLogo", string.Empty);
                    }

                    int i = 1;
                    RecordingsCollection latestRecordings = new RecordingsCollection();

                    foreach (TvDatabase.Schedule schedule in schedules)
                    {
                        string logoImagePath = MediaPortal.Util.Utils.GetCoverArt(Thumbs.TVChannel, schedule.ReferencedChannel().DisplayName);
                        if (string.IsNullOrEmpty(logoImagePath))
                        {
                            logoImagePath = "defaultVideoBig.png";
                        }

                        if (schedule.ScheduleType != (int)ScheduleRecordingType.Once)
                        {
                            IList <Schedule> seriesList = TVHome.Util.GetRecordingTimes(schedule);
                            for (int serieNr = 0; serieNr < seriesList.Count; ++serieNr)
                            {
                                Schedule recSeries = seriesList[serieNr];
                                if (DateTime.Now > recSeries.EndTime)
                                {
                                    continue;
                                }
                                if (recSeries.Canceled != Schedule.MinSchedule)
                                {
                                    continue;
                                }

                                //Program program = Program.RetrieveByTitleTimesAndChannel(schedule.ProgramName, schedule.StartTime,schedule.EndTime, schedule.IdChannel);

                                latestRecordings.Add(new LatestRecording(recSeries.ProgramName, null, recSeries.StartTime,
                                                                         String.Format("{0:" + Utils.DateFormat + "}", recSeries.StartTime),
                                                                         recSeries.StartTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                         String.Format("{0:" + Utils.DateFormat + "}", recSeries.EndTime),
                                                                         recSeries.EndTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                         recSeries.ReferencedChannel().DisplayName,
                                                                         logoImagePath));
                                Utils.ThreadToSleep();
                            }
                        }
                        else
                        {
                            if (schedule.IsSerieIsCanceled(schedule.StartTime, schedule.IdChannel))
                            {
                                continue;
                            }
                            //Test if this is an instance of a series recording, if so skip it.
                            if (schedule.ReferencedSchedule() != null)
                            {
                                continue;
                            }

                            latestRecordings.Add(new LatestRecording(schedule.ProgramName, null, schedule.StartTime,
                                                                     String.Format("{0:" + Utils.DateFormat + "}", schedule.StartTime),
                                                                     schedule.StartTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                     String.Format("{0:" + Utils.DateFormat + "}", schedule.EndTime),
                                                                     schedule.EndTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                     schedule.ReferencedChannel().DisplayName,
                                                                     logoImagePath));
                            Utils.ThreadToSleep();
                        }
                    }

                    latestRecordings.Sort(new LatestRecordingsComparer());

                    Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled.count", latestRecordings.Count.ToString());
                    for (int x0 = 0; x0 < latestRecordings.Count; x0++)
                    {
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".title", latestRecordings[x0].Title);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".startTime", latestRecordings[x0].StartTime);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".startDate", latestRecordings[x0].StartDate);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".endTime", latestRecordings[x0].EndTime);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".endDate", latestRecordings[x0].EndDate);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".channel", latestRecordings[x0].Channel);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.scheduled" + i + ".channelLogo", latestRecordings[x0].ChannelLogo);

                        if (i == Utils.LatestsMaxTVNum)
                        {
                            break;
                        }
                        i++;
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("GetTVRecordings (Scheduled Recordings): " + ex.ToString());
                }
            }
        }
        internal void UpdateActiveRecordings()
        {
            try
            {
                if (TVHome.Connected)
                {
                    IList <TvDatabase.Recording> recordings = TvDatabase.Recording.ListAllActive();

                    Utils.SetProperty("#latestMediaHandler.tvrecordings.active.count", "0");
                    for (int z = 1; z <= Utils.LatestsMaxTVNum; z++)
                    {
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".title", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".genre", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".startTime", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".startDate", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".endTime", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".endDate", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".channel", string.Empty);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + z + ".channelLogo", string.Empty);
                    }

                    int i = 1;
                    RecordingsCollection latestRecordings = new RecordingsCollection();
                    foreach (TvDatabase.Recording rec in recordings)
                    {
                        string logoImagePath = MediaPortal.Util.Utils.GetCoverArt(Thumbs.TVChannel, rec.ReferencedChannel().DisplayName);

                        if (string.IsNullOrEmpty(logoImagePath))
                        {
                            logoImagePath = "defaultVideoBig.png";
                        }

                        latestRecordings.Add(new LatestRecording(rec.Title, rec.Genre, rec.StartTime,
                                                                 String.Format("{0:" + Utils.DateFormat + "}", rec.StartTime),
                                                                 rec.StartTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                 String.Format("{0:" + Utils.DateFormat + "}", rec.EndTime),
                                                                 rec.EndTime.ToString("HH:mm", CultureInfo.CurrentCulture),
                                                                 rec.ReferencedChannel().DisplayName,
                                                                 logoImagePath));
                        Utils.ThreadToSleep();
                    }

                    latestRecordings.Sort(new LatestRecordingsComparer());

                    Utils.SetProperty("#latestMediaHandler.tvrecordings.active.count", latestRecordings.Count.ToString());
                    for (int x0 = 0; x0 < latestRecordings.Count; x0++)
                    {
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".title", latestRecordings[x0].Title);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".genre", latestRecordings[x0].Genre);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".startTime", latestRecordings[x0].StartTime);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".startDate", latestRecordings[x0].StartDate);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".endTime", latestRecordings[x0].EndTime);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".endDate", latestRecordings[x0].EndDate);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".channel", latestRecordings[x0].Channel);
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.active" + i + ".channelLogo", latestRecordings[x0].ChannelLogo);
                        if (i == Utils.LatestsMaxTVNum)
                        {
                            break;
                        }
                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("UpdateActiveRecordings: " + ex.ToString());
            }
            UpdateSheduledTVRecordings();
        }