Example #1
0
        public static void SetMusicProperties(string chanName, Guid channelId)
        {
            string logo = string.Empty;

            if (channelId != Guid.Empty && chanName != string.Empty)
            {
                logo = Utility.GetLogoImage(channelId, chanName);
            }
            else
            {
                chanName = string.Empty;
            }

            if (string.IsNullOrEmpty(logo))
            {
                logo = "defaultMyRadioBig.png";
            }

            GUIPropertyManager.RemovePlayerProperties();
            GUIPropertyManager.SetProperty("#Play.Current.Thumb", logo);
            GUIPropertyManager.SetProperty("#Play.Current.ArtistThumb", chanName);
            GUIPropertyManager.SetProperty("#Play.Current.Album", chanName);
            GUIPropertyManager.SetProperty("#Play.Current.Title", chanName);
            GUIPropertyManager.SetProperty("#Play.Current.Artist", chanName);
        }
Example #2
0
        private void LoadAllChannels()
        {
            _allChannelsList.Clear();

            var channels = Proxies.SchedulerService.GetAllChannels(_currentChannelType, false).Result;

            foreach (Channel channel in channels)
            {
                if (!_channelIdsInList.Contains(channel.ChannelId))
                {
                    GUIListItem item = new GUIListItem();
                    item.Label = channel.DisplayName;
                    item.TVTag = channel;

                    string logo = Utility.GetLogoImage(channel);
                    if (!string.IsNullOrEmpty(logo))
                    {
                        item.IconImage = logo;
                    }
                    if (!channel.VisibleInGuide)
                    {
                        item.IsPlayed = true;
                    }
                    _allChannelsList.Add(item);
                }
            }
        }
Example #3
0
    private void SetCurrentChannelLogo()
    {
      string strLogo = string.Empty;
      if (channelId != Guid.Empty && channelName != string.Empty)
      {
          using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
          {
              strLogo = Utility.GetLogoImage(channelId, channelName, tvSchedulerAgent);
          }
      }

      if (string.IsNullOrEmpty(strLogo))                         
      {
        if (imgTvChannelLogo != null)
        {
          imgTvChannelLogo.IsVisible = false;
        }
      }
      else
      {
        if (imgTvChannelLogo != null)
        {
          imgTvChannelLogo.SetFileName(strLogo);
          m_bNeedRefresh = true;
          imgTvChannelLogo.IsVisible = true;
        }        
      }
      ShowPrograms();
    }
Example #4
0
        private void LoadAllChannels()
        {
            _allChannelsList.Clear();

            Channel[] channels = SchedulerAgent.GetAllChannels(_currentChannelType, false);
            if (channels != null && channels.Length > 0)
            {
                foreach (Channel channel in channels)
                {
                    if (!_channelIdsInList.Contains(channel.ChannelId))
                    {
                        GUIListItem item = new GUIListItem();
                        item.Label = channel.DisplayName;
                        item.TVTag = channel;

                        string logo = Utility.GetLogoImage(channel, SchedulerAgent);
                        if (!string.IsNullOrEmpty(logo))
                        {
                            item.IconImage = logo;
                        }
                        if (!channel.VisibleInGuide)
                        {
                            item.IsPlayed = true;
                        }
                        _allChannelsList.Add(item);
                    }
                }
            }
        }
Example #5
0
        private void LoadChannelsForGroup(ChannelGroup group)
        {
            _channelsInGroupList.Clear();
            _channelIdsInList.Clear();

            if (group != null)
            {
                var channels = Proxies.SchedulerService.GetChannelsInGroup(group.ChannelGroupId, false).Result;
                if (channels != null && channels.Count > 0)
                {
                    foreach (Channel channel in channels)
                    {
                        _channelIdsInList.Add(channel.ChannelId);
                        GUIListItem item = new GUIListItem();
                        item.Label = channel.DisplayName;
                        item.TVTag = channel;

                        string logo = Utility.GetLogoImage(channel);
                        if (!string.IsNullOrEmpty(logo))
                        {
                            item.IconImage = logo;
                        }
                        if (!channel.VisibleInGuide)
                        {
                            item.IsPlayed = true;
                        }
                        _channelsInGroupList.Add(item);
                    }
                }
            }
        }
Example #6
0
        private void SetProperties(UpcomingProgram upcoming, ScheduleSummary schedule)
        {
            string guiPropertyPrefix = this._channelType == ChannelType.Television ? "#TV" : "#Radio";

            if (schedule != null)
            {
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", schedule.Name);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", " ");
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", "defaultFolderBig.png");
            }
            else if (upcoming != null)
            {
                GuideProgram guideProgram = upcoming.GuideProgramId.HasValue ?
                                            Proxies.GuideService.GetProgramById(upcoming.GuideProgramId.Value).Result : null;

                string strTime = string.Format("{0} {1} - {2}",
                                               Utility.GetShortDayDateString(upcoming.StartTime),
                                               upcoming.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                               upcoming.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", upcoming.Channel.DisplayName);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", upcoming.Title);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", upcoming.Category);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", strTime);

                string description = String.Empty;
                if (guideProgram != null)
                {
                    description = guideProgram.CreateCombinedDescription(true);
                }
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", description);

                string logo = Utility.GetLogoImage(upcoming.Channel.ChannelId, upcoming.Channel.DisplayName);
                if (!string.IsNullOrEmpty(logo))
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", logo);
                }
                else
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", "defaultVideoBig.png");
                }
            }
            else
            {
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", " ");
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", String.Empty);
            }
        }
Example #7
0
        private void SetProperties(UpcomingProgram program)
        {
            string guiPropertyPrefix = _channelType == ChannelType.Television ? "#TV" : "#Radio";

            if (program == null)
            {
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Channel");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Title");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Genre");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Time");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Description");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.thumb");
            }
            else
            {
                string strTime = string.Format("{0} {1} - {2}",
                                               Utility.GetShortDayDateString(program.StartTime),
                                               program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                               program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Channel", program.Channel.DisplayName);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Title", program.Title);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Genre", program.Category);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Time", strTime);
                string logo = Utility.GetLogoImage(program.Channel.ChannelId, program.Channel.DisplayName, _tvSchedulerAgent);
                if (System.IO.File.Exists(logo))
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.thumb", logo);
                }
                else
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.thumb", "defaultVideoBig.png");
                }

                GuideProgram guideProgram = GuideAgent.GetProgramById(program.GuideProgramId.Value);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Description", guideProgram.CreateCombinedDescription(true));
            }
        }
Example #8
0
        private GUIListItem CreateListItem(UpcomingProgram upcomingProgram, UpcomingRecording recording, ScheduleSummary schedule)
        {
            GUIListItem item = new GUIListItem();

            if (schedule != null)
            {
                //create list with schedules
                item.Label    = schedule.Name;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                item.PinImage = Utility.GetLogoForSchedule(schedule.ScheduleType, schedule.IsOneTime, schedule.IsActive);
                item.TVTag    = schedule;
                item.IsPlayed = !schedule.IsActive;
            }
            else
            {
                //create list with Upcoming Programs
                string title = upcomingProgram.CreateProgramTitle();
                item.Label = title;
                string logoImagePath = Utility.GetLogoImage(upcomingProgram.Channel);
                if (!Utils.FileExistsInCache(logoImagePath))
                {
                    item.Label    = String.Format("[{0}] {1}", upcomingProgram.Channel.DisplayName, title);
                    logoImagePath = "defaultVideoBig.png";
                }
                item.PinImage = Utility.GetIconImageFileName(_currentProgramType, upcomingProgram.IsPartOfSeries,
                                                             upcomingProgram.CancellationReason, recording);
                item.TVTag          = upcomingProgram;
                item.ThumbnailImage = logoImagePath;
                item.IconImageBig   = logoImagePath;
                item.IconImage      = logoImagePath;
                item.Label2         = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(upcomingProgram.StartTime),
                                                    upcomingProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                    upcomingProgram.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
                item.IsPlayed = upcomingProgram.IsCancelled;
            }
            return(item);
        }
Example #9
0
        private void Update(Schedule _schedule)
        {
            _upcomingEpsiodesList.Clear();
            if (_programTimeLabel != null && _programTitleFadeLabel != null)
            {
                if (_upcomingProgram != null)
                {
                    string strTime = String.Format("{0} {1} - {2}",
                                                   Utility.GetShortDayDateString(_upcomingProgram.StartTime),
                                                   _upcomingProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                   _upcomingProgram.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                    _programTimeLabel.Label      = strTime;
                    _programTitleFadeLabel.Label = _upcomingProgram.Title;
                }
                else
                {
                    _programTimeLabel.Label      = string.Empty;
                    _programTitleFadeLabel.Label = string.Empty;
                }
            }

            if (_schedule != null)
            {
                if (_schedule.ScheduleType == ScheduleType.Recording)
                {
                    var recordings = Proxies.ControlService.GetUpcomingRecordings(_schedule.ScheduleId, true).Result;
                    foreach (UpcomingRecording recording in recordings)
                    {
                        GUIListItem item  = new GUIListItem();
                        string      title = recording.Title;
                        item.Label = title;
                        string logoImagePath = Utility.GetLogoImage(recording.Program.Channel);
                        if (logoImagePath == null ||
                            !System.IO.File.Exists(logoImagePath))
                        {
                            item.Label    = String.Format("[{0}] {1}", recording.Program.Channel.DisplayName, title);
                            logoImagePath = "defaultVideoBig.png";
                        }

                        item.PinImage = Utility.GetIconImageFileName(ScheduleType.Recording, recording.Program.IsPartOfSeries,
                                                                     recording.Program.CancellationReason, recording);

                        item.TVTag          = recording;
                        item.ThumbnailImage = logoImagePath;
                        item.IconImageBig   = logoImagePath;
                        item.IconImage      = logoImagePath;
                        item.Label2         = String.Format("{0} {1} - {2}",
                                                            Utility.GetShortDayDateString(recording.StartTime),
                                                            recording.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                            recording.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                        _upcomingEpsiodesList.Add(item);
                    }
                }
                else
                {
                    var _progs = Proxies.SchedulerService.GetUpcomingPrograms(_schedule, true).Result;
                    foreach (UpcomingProgram program in _progs)
                    {
                        GUIListItem item  = new GUIListItem();
                        string      title = program.Title;
                        item.Label = title;
                        //item.OnItemSelected += new global::MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected);
                        string logoImagePath = Utility.GetLogoImage(program.Channel);
                        if (logoImagePath == null ||
                            !System.IO.File.Exists(logoImagePath))
                        {
                            item.Label    = String.Format("[{0}] {1}", program.Channel.DisplayName, title);
                            logoImagePath = "defaultVideoBig.png";
                        }

                        if (_schedule.ScheduleType == ScheduleType.Alert)
                        {
                            item.PinImage = item.PinImage = Utility.GetIconImageFileName(ScheduleType.Alert, program.IsPartOfSeries,
                                                                                         program.CancellationReason, null);
                        }
                        item.TVTag          = program;
                        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));

                        _upcomingEpsiodesList.Add(item);
                    }
                }
            }
            _upcomingEpisodesLabel.IsVisible = (_upcomingEpsiodesList != null && _upcomingEpsiodesList.Count > 0);
        }
Example #10
0
        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;
        }
Example #11
0
        public static void OnGlobalMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            /// <summary>
            /// We need to stop the player if our livestream ends unexpectedly.
            /// If the stream stopped for a recording, we show it in a message.
            /// Without this mediaportal can hang,crash (c++ error in tsreader).
            /// </summary>
            case GUIMessage.MessageType.GUI_MSG_STOP_SERVER_TIMESHIFTING:
            {
                Log.Debug("TvHome: GUI_MSG_STOP_SERVER_TIMESHIFTING, param1 = {0}", message.Param1);
                if (PluginMain.Navigator.IsLiveStreamOn)
                {
                    if (message.Param1 == 4321)        //fired by eventlistener
                    {
                        LiveStream liveStream          = message.Object as LiveStream;
                        LiveStream navigatorLiveStream = PluginMain.Navigator.LiveStream;
                        Channel    channel             = PluginMain.Navigator.CurrentChannel;

                        if (liveStream != null && channel != null &&
                            navigatorLiveStream.TimeshiftFile == liveStream.TimeshiftFile &&
                            liveStream.StreamStartedTime == navigatorLiveStream.StreamStartedTime)
                        {
                            if (g_Player.Playing && (g_Player.IsTV || g_Player.IsRadio))
                            {
                                g_Player.Stop();
                                Log.Info("TvHome: our live stream seems to be aborted, stop the playback now");
                            }

                            string text = GUILocalizeStrings.Get(1516);
                            if (message.Label == LiveStreamAbortReason.RecordingStartedOnCard.ToString())
                            {
                                text = GUILocalizeStrings.Get(1513);
                            }
                            text = text.Replace("\\r", " ");

                            string heading = string.Empty;
                            string tvlogo  = string.Empty;
                            using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                            {
                                if (channel.ChannelType == ChannelType.Television)
                                {
                                    heading = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName;         //my tv
                                }
                                else
                                {
                                    heading = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName;         //my radio
                                }
                                tvlogo = Utility.GetLogoImage(channel, SchedulerAgent);
                            }

                            GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                            if (pDlgNotify != null)
                            {
                                pDlgNotify.Reset();
                                pDlgNotify.ClearAll();
                                pDlgNotify.SetHeading(heading);
                                if (!string.IsNullOrEmpty(text))
                                {
                                    pDlgNotify.SetText(text);
                                }
                                pDlgNotify.SetImage(tvlogo);
                                pDlgNotify.TimeOut = 5;
                                Utils.PlaySound("notify.wav", false, true);
                                pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                            }
                        }
                    }
                    else        //fired by mp player
                    {
                        PluginMain.Navigator.AsyncStopLiveStream();
                    }
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_NOTIFY_REC:
            {
                if (_enableRecNotification)
                {
                    Log.Debug("TvHome: GUI_MSG_NOTIFY_REC");
                    string    head      = string.Empty;
                    string    logo      = string.Empty;
                    Recording recording = message.Object as Recording;

                    if (message.Param1 == 1)
                    {
                        head = GUILocalizeStrings.Get(1446);
                    }
                    else
                    {
                        head = GUILocalizeStrings.Get(1447);
                    }

                    using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                    {
                        Channel chan = SchedulerAgent.GetChannelById(recording.ChannelId);
                        logo = Utility.GetLogoImage(chan, SchedulerAgent);
                    }

                    string _text = String.Format("{0} {1}-{2}",
                                                 recording.Title,
                                                 recording.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                 recording.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                    GUIDialogNotify DlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    if (DlgNotify != null)
                    {
                        DlgNotify.Reset();
                        DlgNotify.ClearAll();
                        DlgNotify.SetHeading(head);
                        if (!string.IsNullOrEmpty(_text))
                        {
                            DlgNotify.SetText(_text);
                        }
                        DlgNotify.SetImage(logo);
                        DlgNotify.TimeOut = 5;
                        if (_playNotifyBeep)
                        {
                            Utils.PlaySound("notify.wav", false, true);
                        }
                        DlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                    }
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_NOTIFY_TV_PROGRAM:
            {
                Log.Debug("TvHome: GUI_MSG_NOTIFY_TV_PROGRAM");
                TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO);
                UpcomingProgram     prog        = message.Object as UpcomingProgram;
                if (tvNotifyDlg == null || prog == null)
                {
                    return;
                }

                tvNotifyDlg.Reset();
                if (prog.StartTime > DateTime.Now)
                {
                    int minUntilStart = (prog.StartTime - DateTime.Now).Minutes;
                    if (minUntilStart > 1)
                    {
                        tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1018), minUntilStart));
                    }
                    else
                    {
                        tvNotifyDlg.SetHeading(1019);         // Program is about to begin
                    }
                }
                else
                {
                    tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1206), (DateTime.Now - prog.StartTime).Minutes.ToString()));
                }

                string description = GUILocalizeStrings.Get(736);
                using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent())
                {
                    try
                    {
                        if (prog.GuideProgramId.HasValue)
                        {
                            GuideProgram Program = tvGuideAgent.GetProgramById(prog.GuideProgramId.Value);
                            description = Program.CreateCombinedDescription(false);
                        }
                    }
                    catch { }
                }

                tvNotifyDlg.SetLine(1, prog.Title);
                tvNotifyDlg.SetLine(2, description);
                tvNotifyDlg.SetLine(4, String.Format(GUILocalizeStrings.Get(1207), prog.Channel.DisplayName));
                string strLogo = string.Empty;
                using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                {
                    strLogo = Utility.GetLogoImage(prog.Channel, SchedulerAgent);
                }

                tvNotifyDlg.SetImage(strLogo);
                tvNotifyDlg.TimeOut = _notifyTVTimeout;
                if (_playNotifyBeep)
                {
                    Utils.PlaySound("notify.wav", false, true);
                }
                tvNotifyDlg.SetDefaultToYes(false);
                tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow);

                if (tvNotifyDlg.IsConfirmed)
                {
                    try
                    {
                        if (prog.Channel.ChannelType == ChannelType.Television)
                        {
                            if (g_Player.Playing && g_Player.IsTV && PluginMain.Navigator.IsLiveStreamOn)
                            {
                                GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TVFULLSCREEN);
                            }
                            else
                            {
                                GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TV);
                            }

                            PluginMain.Navigator.ZapToChannel(prog.Channel, false);
                            if (PluginMain.Navigator.CheckChannelChange())
                            {
                                TvHome.UpdateProgressPercentageBar(true);
                                if (!PluginMain.Navigator.LastChannelChangeFailed)
                                {
                                    g_Player.ShowFullScreenWindow();
                                }
                            }
                        }
                        else
                        {
                            PluginMain.Navigator.ZapToChannel(prog.Channel, false);
                            GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_RADIO);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error("TVHome: TVNotification: Error on starting channel {0} after notification: {1} {2} {3}", prog.Channel.DisplayName, e.Message, e.Source, e.StackTrace);
                    }
                }
            }
            break;

            //this (GUI_MSG_RECORDER_VIEW_CHANNEL) event is used to let other plugins play a recording,
            //lastMediaHandler does this (with param1 = 5577 for indentification).
            case GUIMessage.MessageType.GUI_MSG_RECORDER_VIEW_CHANNEL:
            {
                if (message.Param1 == 5577)
                {
                    try
                    {
                        Recording rec = message.Object as Recording;
                        RecordedBase.PlayRecording(rec, message.Param2);
                    }
                    catch { Log.Error("TVHome: GUI_MSG_RECORDER_VIEW_CHANNEL error"); }
                }
            }
            break;
            }
        }
Example #12
0
        private void ChannelTuneFailedNotifyUser(LiveStreamResult result, Channel channel)
        {
            string TuningResult = string.Empty;

            switch (result)
            {
            case LiveStreamResult.ChannelTuneFailed:
                TuningResult = (Utility.GetLocalizedText(TextId.ChannelTuneFailed));
                break;

            case LiveStreamResult.NoFreeCardFound:
                TuningResult = (Utility.GetLocalizedText(TextId.NoFreeCardFound));
                break;

            case LiveStreamResult.NotSupported:
                TuningResult = (Utility.GetLocalizedText(TextId.NotSupported));
                break;

            case LiveStreamResult.NoRetunePossible:
                TuningResult = (Utility.GetLocalizedText(TextId.NoRetunePossible));
                break;

            case LiveStreamResult.IsScrambled:
                TuningResult = (Utility.GetLocalizedText(TextId.IsScrambled));
                break;

            case LiveStreamResult.UnknownError:
                TuningResult = (Utility.GetLocalizedText(TextId.UnknownError));
                break;
            }

            if (GUIWindowManager.ActiveWindow == (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN)
            {
                // If failed and wasPlaying TV, left screen as it is and show zaposd with error message
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_TV_ERROR_NOTIFY, GUIWindowManager.ActiveWindow, 0,
                                                0, 0, 0,
                                                null);

                msg.SendToTargetWindow = true;
                msg.Object             = TuningResult; // forward error info object
                msg.TargetWindowId     = (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN;
                GUIGraphicsContext.SendMessage(msg);
            }
            else
            {
                // if not fulscreen, show notify dialog with the error message
                string caption = string.Empty;
                string tvlogo  = string.Empty;
                if (channel != null)
                {
                    _navigatorChannels[_currentChannel.ChannelType].PreviousChannel = channel;
                    _currentChannel = null;

                    using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                    {
                        tvlogo = Utility.GetLogoImage(channel, SchedulerAgent);
                    }

                    if (channel.ChannelType == ChannelType.Television)
                    {
                        caption = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName;
                    }
                    else
                    {
                        caption = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName;
                    }
                }

                GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                if (pDlgNotify != null)
                {
                    pDlgNotify.Reset();
                    pDlgNotify.ClearAll();
                    pDlgNotify.SetHeading(caption);
                    if (!string.IsNullOrEmpty(TuningResult))
                    {
                        pDlgNotify.SetText(TuningResult);
                    }
                    pDlgNotify.SetImage(tvlogo);
                    pDlgNotify.TimeOut = 5;
                    pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                }
            }
        }
Example #13
0
        /// <summary>
        /// Fill the list with channels
        /// </summary>
        private void FillChannelList()
        {
            using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
            {
                _channelsListControl.Clear();

                int    i           = 0;
                int    SelectedID  = 0;
                string ChannelLogo = string.Empty;

                if (_currentGroup != null)
                {
                    _currentAndNextPrograms = new List <CurrentAndNextProgram>(
                        tvSchedulerAgent.GetCurrentAndNextForGroup(_currentGroup.ChannelGroupId, true, true, PluginMain.Navigator.LiveStream));
                }
                else
                {
                    _currentAndNextPrograms = new List <CurrentAndNextProgram>();
                }

                Channel currentChannel = PluginMain.Navigator.CurrentChannel;
                Channel prevChannel    = PluginMain.Navigator.GetPreviousChannel(this.ChannelType);

                foreach (CurrentAndNextProgram currentAndNext in _currentAndNextPrograms)
                {
                    i++;
                    sb.Length = 0;
                    GUIListItem item = new GUIListItem("");
                    item.TVTag = currentAndNext.Channel;

                    sb.Append(currentAndNext.Channel.DisplayName);
                    ChannelLogo = Utility.GetLogoImage(currentAndNext.Channel, tvSchedulerAgent);

                    if (!string.IsNullOrEmpty(ChannelLogo))
                    {
                        item.IconImageBig = ChannelLogo;
                        item.IconImage    = ChannelLogo;
                    }
                    else
                    {
                        item.IconImageBig = string.Empty;
                        item.IconImage    = string.Empty;
                    }

                    ActiveRecording activeRecording;
                    if (PluginMain.IsChannelRecording(currentAndNext.Channel.ChannelId, out activeRecording))
                    {
                        if (_showStateIcons)
                        {
                            item.PinImage = RecordingIcon;
                        }
                        else
                        {
                            sb.Append(" ");
                            sb.Append(recordingText);
                        }
                        item.IsPlayed = (currentAndNext.LiveState == ChannelLiveState.NotTunable ||
                                         currentAndNext.LiveState == ChannelLiveState.NoFreeCard);
                    }
                    else
                    {
                        switch (currentAndNext.LiveState)
                        {
                        case ChannelLiveState.NotTunable:
                        case ChannelLiveState.NoFreeCard:
                            item.IsPlayed = true;
                            if (_showStateIcons)
                            {
                                item.PinImage = UnavailableIcon;
                            }
                            else
                            {
                                sb.Append(" ");
                                sb.Append(unavailableText);
                            }
                            break;

                        default:
                            item.IsPlayed = false;
                            if (_showStateIcons)
                            {
                                item.PinImage = AvailableIcon;
                            }
                            break;
                        }
                    }

                    if (currentChannel != null)
                    {
                        if (currentChannel.ChannelId == currentAndNext.Channel.ChannelId)
                        {
                            item.IsRemote = true;
                            SelectedID    = _channelsListControl.Count;

                            if (_showStateIcons && item.PinImage != RecordingIcon &&
                                item.PinImage != UnavailableIcon)
                            {
                                item.PinImage = TimeshiftingIcon;
                            }
                            else if (!_showStateIcons)
                            {
                                sb.Append(" ");
                                sb.Append(timeshiftingText);
                            }
                        }
                    }
                    else if (prevChannel != null &&
                             prevChannel.ChannelId == currentAndNext.Channel.ChannelId)
                    {
                        item.IsRemote = true;
                        SelectedID    = _channelsListControl.Count;
                    }

                    sbTmp.Length = 0;

                    bool hasNow = currentAndNext.Current != null;
                    if (hasNow)
                    {
                        sbTmp.Append(currentAndNext.Current.CreateProgramTitle());
                    }
                    else
                    {
                        sbTmp.Append(noDataAvailableText);
                    }

                    item.Label2 = sbTmp.ToString();
                    sbTmp.Insert(0, nowText);
                    item.Label3 = sbTmp.ToString();

                    sbTmp.Length = 0;

                    if (_showChannelNumber)
                    {
                        sb.Append(" - ");
                        if (!_byIndex)
                        {
                            if (currentAndNext.Channel.LogicalChannelNumber.HasValue)
                            {
                                sb.Append(currentAndNext.Channel.LogicalChannelNumber.Value.ToString());
                            }
                        }
                        else
                        {
                            sb.Append(i);
                        }
                    }

                    if (hasNow)
                    {
                        sb.Append(" - ");
                        sb.Append(currentAndNext.CurrentPercentageComplete);
                        sb.Append("%");
                    }

                    if (currentAndNext.Next != null)
                    {
                        sbTmp.Append(/*currentAndNext.Next.StartTime.ToShortTimeString() + " " + */ currentAndNext.Next.CreateProgramTitle());
                    }
                    else
                    {
                        sbTmp.Append(noDataAvailableText);
                    }

                    item.Label2 = sb.ToString();
                    sbTmp.Insert(0, nextText);
                    item.Label = sbTmp.ToString();

                    _channelsListControl.Add(item);
                }
                _channelsListControl.SelectedListItemIndex = SelectedID;
                Log.Debug("miniguide: state check + filling channel list completed");

                if (_channelsListControl.GetID == 37)
                {
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SETFOCUS, GetID, 0, 37, 0, 0, null);
                    OnMessage(msg);
                }

                sb.Length    = 0;
                sbTmp.Length = 0;
            }
        }