Exemple #1
0
        private LiveStreamResult PlayLiveStream(LiveStream liveStream)
        {
            Log.Debug("ChannelNavigator: PlayLiveStream()");
            LiveStreamResult result = LiveStreamResult.Succeeded;
            string           fileName;
            bool             isRTSP;

            GetPlayerFileNameAndOffset(liveStream, out fileName, out isRTSP);

            if (liveStream != null)
            {
                _isAnalog = (ControlAgent.GetLiveStreamTuningDetails(liveStream).CardType == CardType.Analog);
            }

            if (!isRTSP)
            {
                for (int i = 0; i < 10; i++)
                {
                    if (System.IO.File.Exists(fileName))
                    {
                        break;
                    }

                    Thread.Sleep(100);
                    Log.Info("Channelnavigator: startplay: waiting for TS file {0}", fileName);
                }
                if (!System.IO.File.Exists(fileName))
                {
                    result = LiveStreamResult.UnknownError;
                    g_Player.Stop();
                }
            }

            if (result == LiveStreamResult.Succeeded)
            {
                for (int i = 0; i < 50; i++)
                {
                    if (g_Player.Play(fileName, liveStream.Channel.ChannelType == ChannelType.Television ? g_Player.MediaType.TV : g_Player.MediaType.Radio))
                    {
                        double duration = g_Player.Duration;
                        if (duration > 0.0)
                        {
                            result = LiveStreamResult.Succeeded;
                            g_Player.SeekAbsolute(duration);
                            _liveStream = liveStream;
                            break;
                        }
                        else
                        {
                            result = LiveStreamResult.UnknownError;
                            g_Player.Stop();
                            Thread.Sleep(50);
                            Log.Debug("ChannelNavigator: PlayLiveStream_timeout = {0}", i);
                        }
                    }
                    else
                    {
                        result = LiveStreamResult.UnknownError;
                        break;
                    }
                }
            }
            Log.Debug("ChannelNavigator: PlayLiveStream_Result = {0}", result);
            return(result);
        }
        private void SetLabels()
        {
            UpcomingRecording[]             upcomingRecordings       = ControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.All, true);
            UpcomingGuideProgram[]          upcomingAlerts           = SchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Alert, true);
            UpcomingGuideProgram[]          upcomingSuggestions      = SchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Suggestion, true);
            UpcomingGuideProgramsDictionary AllUpcomingGuidePrograms = new UpcomingGuideProgramsDictionary(upcomingRecordings, upcomingAlerts, upcomingSuggestions);

            foreach (GUIListItem item in _viewsList.ListItems)
            {
                if (item.Label != _parentDirectoryLabel)
                {
                    UpcomingProgram program = item.TVTag as UpcomingProgram;
                    if (program != null)
                    {
                        if (!item.IsFolder)
                        {
                            item.PinImage = null;
                            Guid upcomingProgramId = program.UpcomingProgramId;
                            if (AllUpcomingGuidePrograms.ContainsKey(upcomingProgramId))
                            {
                                GuideUpcomingProgram programInfo = AllUpcomingGuidePrograms[upcomingProgramId];
                                item.PinImage = Utility.GetIconImageFileName(programInfo.Type, programInfo.IsPartOfSeries,
                                                                             programInfo.CancellationReason, programInfo.UpcomingRecording);
                            }

                            string title = GuideProgram.CreateProgramTitle(program.Title, program.SubTitle, program.EpisodeNumberDisplay);
                            item.Label = title;
                            string logoImagePath = Utility.GetLogoImage(program.Channel, _tvSchedulerAgent);
                            if (logoImagePath == null ||
                                !System.IO.File.Exists(logoImagePath))
                            {
                                item.Label    = String.Format("[{0}] {1}", program.Channel.DisplayName, title);
                                logoImagePath = "defaultVideoBig.png";
                            }

                            item.ThumbnailImage = logoImagePath;
                            item.IconImageBig   = logoImagePath;
                            item.IconImage      = logoImagePath;

                            item.Label2 = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(program.StartTime),
                                                        program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                        program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                            if (_currentSortMethod == SortMethod.Channel)
                            {
                                item.Label3 = program.Channel.DisplayName;
                            }
                            else
                            {
                                item.Label3 = program.Category;
                            }
                        }
                        else
                        {
                            Utils.SetDefaultIcons(item);
                            item.Label = program.Title;
                        }
                    }
                }
            }
            AllUpcomingGuidePrograms.Clear();
            AllUpcomingGuidePrograms = null;
        }
Exemple #3
0
        private void LoadUpcomingPrograms(ScheduleSummary schedule)
        {
            GUIControl.ClearControl(GetID, _viewsList.GetID);

            if (schedule == null)
            {
                _isInSubDirectory = false;
                bool group = false;
                if (_groupBySchedButton != null)
                {
                    group = _groupBySchedButton.Selected;
                }

                if (group)
                {
                    ScheduleSummary[] schedules = SchedulerAgent.GetAllSchedules(this._channelType, _currentProgramType, true);
                    foreach (ScheduleSummary sched in schedules)
                    {
                        GUIListItem item = CreateListItem(null, null, sched);
                        _viewsList.Add(item);
                    }
                }
                else
                {
                    if (_currentProgramType == ScheduleType.Recording)
                    {
                        List <UpcomingRecording> upcomingRecordings = new List <UpcomingRecording>(
                            this.ControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings | UpcomingRecordingsFilter.CancelledByUser, false));
                        foreach (UpcomingRecording recording in upcomingRecordings)
                        {
                            if (recording.Program.Channel.ChannelType == this._channelType)
                            {
                                GUIListItem item = CreateListItem(recording.Program, recording, null);
                                _viewsList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        List <UpcomingProgram> upcomingPrograms = new List <UpcomingProgram>(
                            this.SchedulerAgent.GetAllUpcomingPrograms(_currentProgramType, true));
                        foreach (UpcomingProgram program in upcomingPrograms)
                        {
                            if (program.Channel.ChannelType == this._channelType)
                            {
                                GUIListItem item = CreateListItem(program, null, null);
                                _viewsList.Add(item);
                            }
                        }
                    }
                }
            }
            else if (schedule != null)
            {
                //add prev directory folder
                GUIListItem item = new GUIListItem();
                item.Label    = _parentDirectoryLabel;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                _viewsList.Add(item);

                _selectedSchedule = schedule;
                if (_currentProgramType == ScheduleType.Recording)
                {
                    UpcomingRecording[] upcomingRecordings = ControlAgent.GetUpcomingRecordings(schedule.ScheduleId, true);
                    foreach (UpcomingRecording recording in upcomingRecordings)
                    {
                        item = CreateListItem(recording.Program, recording, null);
                        _viewsList.Add(item);
                    }
                }
                else
                {
                    Schedule          sched            = SchedulerAgent.GetScheduleById(schedule.ScheduleId);
                    UpcomingProgram[] upcomingPrograms = SchedulerAgent.GetUpcomingPrograms(sched, true);
                    foreach (UpcomingProgram upcomingProgram in upcomingPrograms)
                    {
                        item = CreateListItem(upcomingProgram, null, null);
                        _viewsList.Add(item);
                    }
                }

                _isInSubDirectory = true;
            }

            string strObjects = string.Format("{0}", _viewsList.Count - (_viewsList.Count > 0 && _viewsList[0].Label == _parentDirectoryLabel ? 1 : 0));

            GUIPropertyManager.SetProperty("#itemcount", strObjects);

            OnSort();
            UpdateButtonStates();
            UpdateProperties();

            if (GetItemCount() > 0)
            {
                if (_isInSubDirectory)
                {
                    while (m_iSelectedItemInFolder >= GetItemCount() && m_iSelectedItemInFolder > 0)
                    {
                        m_iSelectedItemInFolder--;
                    }
                    GUIControl.SelectItemControl(GetID, _viewsList.GetID, m_iSelectedItemInFolder);
                }
                else
                {
                    while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0)
                    {
                        m_iSelectedItem--;
                    }
                    GUIControl.SelectItemControl(GetID, _viewsList.GetID, m_iSelectedItem);
                }
            }
        }