From: <do...@us...> - 2009-02-07 15:41:33
|
Revision: 2613 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2613&view=rev Author: dot-i Date: 2009-02-07 15:41:24 +0000 (Sat, 07 Feb 2009) Log Message: ----------- Updated to source code for version 1.3.3.0. Modified Paths: -------------- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/LinkedMediaPortalChannel.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Properties/AssemblyInfo.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SettingName.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SyncEpgThread.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/TvServerPlugin.cs trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Utility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ActiveRecordings.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordHome.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/PostBuild.cmd trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Properties/AssemblyInfo.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/SetupForm.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TVZapOSD.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TextId.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Translator.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvFullScreen.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideBase.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideSearch.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvMiniGuide.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvOSD.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvProgramInfo.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvRecorded.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/UpcomingPrograms.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Utility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/WindowId.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/CurrentAndNextProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/CurrentAndNextProgramsList.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/EditScheduleController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/EditScheduleModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/EditSchedule/TitleRuleTypeIndex.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/KeepUntilControlUtility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ProcessUtility.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Properties/AssemblyInfo.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/RecorderTunersCache.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Recordings/RecordingsController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/Recordings/RecordingsModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/ScheduleNamesCache.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/SearchGuide/SearchGuideController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/SearchGuide/SearchGuideModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/SerializableDictionary.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/SortableBindingList.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvChannelProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvChannelProgramsList.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvGuide/ChannelPrograms.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvGuide/TvGuideController.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvGuide/TvGuideModel.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/TvGuide/TvGuideUpcomingProgram.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/UpcomingOrActiveProgramView.cs trunk/plugins/ForTheRecord/ForTheRecord.UI.Process/UpcomingOrActiveProgramsList.cs trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.Entities.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.RecorderTuners.Common.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.ServiceAgents.dll trunk/plugins/ForTheRecord/ReferencedAssemblies/ForTheRecord.ServiceContracts.dll Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLink.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/ChannelLinks.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/LinkedMediaPortalChannel.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/LinkedMediaPortalChannel.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Channels/LinkedMediaPortalChannel.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/MediaPortalRecorderTunerService.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify @@ -228,6 +228,8 @@ } } } + + return LiveTvResult.NoRetunePossible; } else { @@ -254,14 +256,15 @@ } } } + + return LiveTvResult.NoFreeCardFound; } } catch (Exception ex) { Log(TraceEventType.Error, ex.Message); + return LiveTvResult.UnknownError; } - - return LiveTvResult.NoFreeCardFound; } private bool CardFreeOrUsingSameTransponder(int cardId, Channel channel, User userToIgnore) Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Properties/AssemblyInfo.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Properties/AssemblyInfo.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -11,7 +11,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ForTheRecord.RecorderTuners.MediaPortalTvServer")] -[assembly: AssemblyCopyright("Copyright © ForTheRecord 2007-2008")] +[assembly: AssemblyCopyright("Copyright © ForTheRecord 2007-2009")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/RecordingThread.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SettingName.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SettingName.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SettingName.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SetupForm.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SyncEpgThread.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SyncEpgThread.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/SyncEpgThread.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify @@ -55,210 +55,177 @@ set { _plugin = value; } } - private TvSchedulerServiceAgent _tvSchedulerAgent; - private TvGuideServiceAgent _tvGuideAgent; - protected override void Run() { - Thread.Sleep(5 * 60 * 1000); + Thread.Sleep(3 * 60 * 1000); - try + bool aborted = false; + DateTime lastSyncTime = DateTime.MinValue; + DateTime lastAllSyncTime = DateTime.MinValue; + DateTime latestProgramTime = DateTime.Today; + while (!aborted) { - bool aborted = false; - DateTime lastSyncTime = DateTime.MinValue; - DateTime lastAllSyncTime = DateTime.MinValue; - DateTime latestProgramTime = DateTime.Today; - while (!aborted) + try { - try - { - TvBusinessLayer layer = new TvBusinessLayer(); - bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value); - int epgSyncAllHours = Convert.ToInt32(layer.GetSetting(SettingName.EpgSyncAllHours, TvServerPlugin.DefaultSyncAllHours.ToString()).Value); + TvBusinessLayer layer = new TvBusinessLayer(); + bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value); + int epgSyncAllHours = Convert.ToInt32(layer.GetSetting(SettingName.EpgSyncAllHours, TvServerPlugin.DefaultSyncAllHours.ToString()).Value); - if (epgSyncOn) + if (epgSyncOn) + { + if (EnsureConnection()) { - if (EnsureAgents()) + if (DateTime.Now - lastSyncTime >= new TimeSpan(1, 0, 0)) { - if (DateTime.Now - lastSyncTime >= new TimeSpan(1, 0, 0)) + lastSyncTime = DateTime.Now; + bool syncAll = (lastSyncTime - lastAllSyncTime >= new TimeSpan(epgSyncAllHours, 0, 0)); + latestProgramTime = SynchronizeEpg(latestProgramTime, syncAll); + if (syncAll) { - lastSyncTime = DateTime.Now; - bool syncAll = (lastSyncTime - lastAllSyncTime >= new TimeSpan(epgSyncAllHours, 0, 0)); - latestProgramTime = SynchronizeEpg(latestProgramTime, syncAll); - if (syncAll) - { - lastAllSyncTime = lastSyncTime; - } + lastAllSyncTime = lastSyncTime; } } } + } #if DEBUG - aborted = this.StopThreadEvent.WaitOne(5000, false); + aborted = this.StopThreadEvent.WaitOne(5000, false); #else - aborted = this.StopThreadEvent.WaitOne(5 * 60 * 1000, false); + aborted = this.StopThreadEvent.WaitOne(5 * 60 * 1000, false); #endif - } - catch (Exception ex) - { - Log.Error("Run(): {0}", ex.Message); - DisposeAgents(); - // Delay for a short while and then restart. - aborted = this.StopThreadEvent.WaitOne(30 * 1000, false); - } } + catch (Exception ex) + { + Log.Error("ForTheRecordSyncEpg error: {0}", ex.Message); + // Delay for a short while and then restart. + aborted = this.StopThreadEvent.WaitOne(30 * 1000, false); + } } - finally - { - DisposeAgents(); - } } - private bool EnsureAgents() + private bool EnsureConnection() { if (!_plugin.IsTvSchedulerConnectionInitialized) { _plugin.InitializeTvSchedulerConnection(null); } - if (_plugin.IsTvSchedulerConnectionInitialized) - { - if (_tvSchedulerAgent == null) - { - _tvSchedulerAgent = new TvSchedulerServiceAgent(); - } - if (_tvGuideAgent == null) - { - _tvGuideAgent = new TvGuideServiceAgent(); - } - return true; - } - return false; + return _plugin.IsTvSchedulerConnectionInitialized; } - private void DisposeAgents() - { - if (_tvSchedulerAgent != null) - { - _tvSchedulerAgent.Dispose(); - _tvSchedulerAgent = null; - } - if (_tvGuideAgent != null) - { - _tvGuideAgent.Dispose(); - _tvGuideAgent = null; - } - } - private DateTime SynchronizeEpg(DateTime latestProgramTime, bool synchronizeAll) { - TvBusinessLayer layer = new TvBusinessLayer(); - bool epgSyncAutoCreateChannels = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value); - - ChannelLinks channelLinks = ChannelLinks.LoadChannelLinks(); - - _tvGuideAgent.StartGuideImport(); - try + using (TvSchedulerServiceAgent tvSchedulerAgent = new TvSchedulerServiceAgent()) + using (TvGuideServiceAgent tvGuideAgent = new TvGuideServiceAgent()) { - bool aborted = false; + TvBusinessLayer layer = new TvBusinessLayer(); + bool epgSyncAutoCreateChannels = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value); - IList mpChannels = Channel.ListAll(); - foreach (Channel channel in mpChannels) + ChannelLinks channelLinks = ChannelLinks.LoadChannelLinks(); + + tvGuideAgent.StartGuideImport(); + try { - // only execute for tv channels - if (channel.IsTv) + bool aborted = false; + + IList mpChannels = Channel.ListAll(); + foreach (Channel channel in mpChannels) { - ChannelLink channelLink = channelLinks.GetChannelLinkForMediaPortalChannel(channel); - TvChannel tvChannel = null; - if (channelLink != null) + // only execute for tv channels + if (channel.IsTv) { - tvChannel = _tvSchedulerAgent.GetChannelById(channelLink.TvChannelId); - if (tvChannel == null) + ChannelLink channelLink = channelLinks.GetChannelLinkForMediaPortalChannel(channel); + TvChannel tvChannel = null; + if (channelLink != null) { - tvChannel = _tvSchedulerAgent.GetChannelByDisplayName(channelLink.TvChannelName); - } - } - if (tvChannel == null) - { - tvChannel = _tvSchedulerAgent.GetChannelByDisplayName(channel.DisplayName); - } - if (tvChannel == null - && epgSyncAutoCreateChannels) - { - Guid tvChannelId = _tvSchedulerAgent.EnsureChannel(channel.DisplayName, "DVB-EPG"); - tvChannel = _tvSchedulerAgent.GetChannelById(tvChannelId); - } - if (tvChannel != null) - { - Guid guideChannelId; - if (!tvChannel.GuideChannelId.HasValue) - { - string externalId = channel.ExternalId; - if (String.IsNullOrEmpty(externalId)) + tvChannel = tvSchedulerAgent.GetChannelById(channelLink.TvChannelId); + if (tvChannel == null) { - externalId = tvChannel.TvChannelId.ToString("N", CultureInfo.InvariantCulture); + tvChannel = tvSchedulerAgent.GetChannelByDisplayName(channelLink.TvChannelName); } - guideChannelId = _tvGuideAgent.EnsureChannel(externalId, channel.DisplayName); - _tvSchedulerAgent.AttachChannelToGuide(tvChannel.TvChannelId, guideChannelId); } - else + if (tvChannel == null) { - guideChannelId = tvChannel.GuideChannelId.Value; + tvChannel = tvSchedulerAgent.GetChannelByDisplayName(channel.DisplayName); } - - IList mpPrograms = layer.GetPrograms(channel, synchronizeAll ? DateTime.Today : latestProgramTime, DateTime.Today.AddDays(14)); - List<GuideProgram> guidePrograms = new List<GuideProgram>(); - foreach (Program program in mpPrograms) + if (tvChannel == null + && epgSyncAutoCreateChannels) { - if (program.StartTime < program.EndTime) + Guid tvChannelId = tvSchedulerAgent.EnsureChannel(channel.DisplayName, "DVB-EPG"); + tvChannel = tvSchedulerAgent.GetChannelById(tvChannelId); + } + if (tvChannel != null) + { + Guid guideChannelId; + if (!tvChannel.GuideChannelId.HasValue) { - GuideProgram guideProgram = new GuideProgram(); - guideProgram.GuideChannelId = guideChannelId; - guideProgram.Category = program.Genre; - guideProgram.Description = program.Description; - guideProgram.EpisodeNumberDisplay = program.EpisodeNum; - guideProgram.Rating = program.Classification; - guideProgram.StartTime = program.StartTime; - guideProgram.StopTime = program.EndTime; - guideProgram.Title = program.Title; - guidePrograms.Add(guideProgram); + string externalId = channel.ExternalId; + if (String.IsNullOrEmpty(externalId)) + { + externalId = tvChannel.TvChannelId.ToString("N", CultureInfo.InvariantCulture); + } + guideChannelId = tvGuideAgent.EnsureChannel(externalId, channel.DisplayName); + tvSchedulerAgent.AttachChannelToGuide(tvChannel.TvChannelId, guideChannelId); + } + else + { + guideChannelId = tvChannel.GuideChannelId.Value; + } - if (guideProgram.StartTime > latestProgramTime) + IList mpPrograms = layer.GetPrograms(channel, synchronizeAll ? DateTime.Today : latestProgramTime, DateTime.Today.AddDays(14)); + List<GuideProgram> guidePrograms = new List<GuideProgram>(); + foreach (Program program in mpPrograms) + { + if (program.StartTime < program.EndTime) { - latestProgramTime = guideProgram.StartTime; + GuideProgram guideProgram = new GuideProgram(); + guideProgram.GuideChannelId = guideChannelId; + guideProgram.Category = program.Genre; + guideProgram.Description = program.Description; + guideProgram.EpisodeNumberDisplay = program.EpisodeNum; + guideProgram.Rating = program.Classification; + guideProgram.StartTime = program.StartTime; + guideProgram.StopTime = program.EndTime; + guideProgram.Title = program.Title; + guidePrograms.Add(guideProgram); + + if (guideProgram.StartTime > latestProgramTime) + { + latestProgramTime = guideProgram.StartTime; + } + + if (guidePrograms.Count >= _syncBatchSize) + { + tvGuideAgent.ImportPrograms(guidePrograms.ToArray(), GuideSource.DvbEpg); + guidePrograms.Clear(); + } } - if (guidePrograms.Count >= _syncBatchSize) + aborted = this.StopThreadEvent.WaitOne(0, false); + if (aborted) { - _tvGuideAgent.ImportPrograms(guidePrograms.ToArray(), GuideSource.DvbEpg); - guidePrograms.Clear(); + break; } } - - aborted = this.StopThreadEvent.WaitOne(0, false); - if (aborted) + if (!aborted + && guidePrograms.Count > 0) { - break; + tvGuideAgent.ImportPrograms(guidePrograms.ToArray(), GuideSource.DvbEpg); } } - if (!aborted - && guidePrograms.Count > 0) - { - _tvGuideAgent.ImportPrograms(guidePrograms.ToArray(), GuideSource.DvbEpg); - } } - } - if (aborted) - { - break; + if (aborted) + { + break; + } } } - } - finally - { - _tvGuideAgent.EndGuideImport(); - } + finally + { + tvGuideAgent.EndGuideImport(); + } - return latestProgramTime; + return latestProgramTime; + } } } } Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/TvServerPlugin.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/TvServerPlugin.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/TvServerPlugin.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Utility.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Utility.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.RecorderTuners.MediaPortalTvServer/Utility.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ActiveRecordings.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ActiveRecordings.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ActiveRecordings.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -394,7 +394,8 @@ item.Label = title; //item.OnItemSelected += new global::MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected); string logoImagePath = Utility.GetLogoImage(activeRecording.Program.TvChannel, TvSchedulerAgent); - if (!System.IO.File.Exists(logoImagePath)) + if (logoImagePath == null + || !System.IO.File.Exists(logoImagePath)) { item.Label = String.Format("[{0}] {1}", activeRecording.Program.TvChannel.DisplayName, title); logoImagePath = "defaultVideoBig.png"; @@ -453,11 +454,11 @@ string description; if (guideProgram == null) { - description = Utility.GetComposedDescription(recording.Program.CreateEpisodeTitle(), null, null, null); + description = String.Empty; } else { - description = Utility.GetComposedDescription(guideProgram); + description = guideProgram.CreateCombinedDescription(true); } GUIPropertyManager.SetProperty("#TV.Active.Description", description); Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ChannelNavigator.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -43,6 +43,8 @@ private List<TvChannelGroup> _groups = new List<TvChannelGroup>(); private TvChannelGroup _currentChannelGroup; private List<TvChannel> _channels = new List<TvChannel>(); + private Dictionary<int, TvChannel> _channelsByNumber = new Dictionary<int, TvChannel>(); + private Dictionary<int, TvChannelGroup> _groupsByChannelNumber = new Dictionary<int, TvChannelGroup>(); private CurrentAndNextProgram _currentNextProgram; private GuideProgram _currentProgram; private GuideProgram _nextProgram; @@ -52,7 +54,7 @@ private TvChannelGroup _zapGroup; private TvChannel _zapChannel; private DateTime _zapTime; - private GuideProgram _zapProgram; + private GuideProgramSummary _zapProgram; private long _zapDelayMs; private bool _autoFullScreen; @@ -148,7 +150,7 @@ get { return _nextProgram; } } - public GuideProgram ZapProgram + public GuideProgramSummary ZapProgram { get { return _zapProgram; } } @@ -213,17 +215,84 @@ } } - public TvChannel GetChannelByNumber(int channelNr) + public TvChannel GetChannelByIndex(int channelIndex) { if (_channels != null - && channelNr >= 1 - && channelNr <= _channels.Count) + && channelIndex >= 1 + && channelIndex <= _channels.Count) { - return _channels[channelNr - 1]; + return _channels[channelIndex - 1]; } return null; } + public TvChannel GetChannelByNumber(int channelNr) + { + TvChannelGroup tvChannelGroup; + return GetChannelByNumber(channelNr, out tvChannelGroup); + } + + public TvChannel GetChannelByNumber(int channelNr, out TvChannelGroup tvChannelGroup) + { + tvChannelGroup = _currentChannelGroup; + if (_channelsByNumber.ContainsKey(channelNr)) + { + tvChannelGroup = _groupsByChannelNumber[channelNr]; + return _channelsByNumber[channelNr]; + } + TvChannel channel = null; + if (_channels != null) + { + channel = FindChannelByNumber(_channels, channelNr); + if (channel == null) + { + try + { + using (TvSchedulerServiceAgent tvSchedulerAgent = new TvSchedulerServiceAgent()) + { + foreach (TvChannelGroup group in _groups) + { + if (group != _currentChannelGroup) + { + channel = FindChannelInGroupByNumber(tvSchedulerAgent, group.TvChannelGroupId, channelNr); + if (channel != null) + { + tvChannelGroup = group; + break; + } + } + } + } + } + catch (Exception ex) + { + Log.Error("ChannelNavigator: Error in GetChannelByNumber - {0}", ex.Message); + } + } + } + _channelsByNumber[channelNr] = channel; + _groupsByChannelNumber[channelNr] = tvChannelGroup; + return channel; + } + + private TvChannel FindChannelByNumber(List<TvChannel> channels, int channelNr) + { + foreach (TvChannel channel in channels) + { + if (channel.LogicalChannelNumber.HasValue + && channel.LogicalChannelNumber.Value == channelNr) + { + return channel; + } + } + return null; + } + + private TvChannel FindChannelInGroupByNumber(TvSchedulerServiceAgent tvSchedulerAgent, Guid tvChannelGroupId, int channelNr) + { + return FindChannelByNumber(new List<TvChannel>(tvSchedulerAgent.GetChannelsInGroup(tvChannelGroupId, true)), channelNr); + } + public void ZapNow() { _zapTime = DateTime.Now.AddSeconds(-1); @@ -249,10 +318,8 @@ // Make sure current and next is up to date. if (_currentNextProgram != null) { - if ((_currentNextProgram.Current != null - && _currentNextProgram.Current.StopTime < DateTime.Now) - || (_currentNextProgram.Next != null - && _currentNextProgram.Next.StartTime < DateTime.Now)) + if ((_currentNextProgram.Current != null && _currentNextProgram.Current.StopTime < DateTime.Now) + || (_currentNextProgram.Next != null && _currentNextProgram.Next.StartTime < DateTime.Now)) { RefreshCurrentAndNext(); } @@ -267,7 +334,7 @@ // Zapping to another group? if (_zapGroup != null && _zapGroup != _currentChannelGroup) { - // Change current group and zap to the first channel of the group + // Change current group (and possibly zap to the first channel of the group) _previousChannelGroup = _currentChannelGroup; _currentChannelGroup = _zapGroup; RefreshChannelsInGroup(); @@ -300,58 +367,18 @@ return false; } - ///// <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; + public bool ZapToChannelNumber(int channelNr, bool useZapDelay) + { + TvChannelGroup tvChannelGroup; + TvChannel channel = GetChannelByNumber(channelNr, out tvChannelGroup); + if (channel != null) + { + ZapToChannel(tvChannelGroup, channel, useZapDelay); + return true; + } + return false; + } - - // if (!TVHome.HandleServerNotConnected()) - // { - - // 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 - // TvServer server = new TvServer(); - // if (server.IsAnyCardRecording()) - // { - // 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; - // if (m_currentChannel != newChannel && newChannel != null) - // { - // m_currentChannel = newChannel; - // m_currentChannel.CurrentGroup = CurrentGroup; - // } - // } - //} - /// <summary> /// Changes the current channel after a specified delay. /// </summary> @@ -384,7 +411,7 @@ { using (TvGuideServiceAgent tvGuideAgent = new TvGuideServiceAgent()) { - GuideProgram[] programs = tvGuideAgent.GetChannelProgramsBetween(_zapChannel.GuideChannelId.Value, _zapTime, _zapTime); + GuideProgramSummary[] programs = tvGuideAgent.GetChannelProgramsBetween(_zapChannel.GuideChannelId.Value, _zapTime, _zapTime); if (programs.Length > 0) { _zapProgram = programs[0]; @@ -576,41 +603,51 @@ LiveTvResult result = LiveTvResult.UnknownError; try { - string lastRtspUrl = liveTvStream.RtspUrl; + // + // First try to re-tune the existing TV stream (staying on the same card). + // result = this.TvControlAgent.TuneLiveTvStream(currentAndNext.TvChannel, ref liveTvStream); if (result == LiveTvResult.Succeeded) { SetCurrentAndNext(currentAndNext); _currentChannel = tvChannel; - if (liveTvStream.RtspUrl != lastRtspUrl) - { - result = PlayLiveTv(liveTvStream); - } - else - { - string fileName; - int seekOffset; - GetPlayerFileNameAndOffset(liveTvStream, out fileName, out seekOffset); - g_Player.SeekAbsolute(g_Player.Duration + seekOffset); - } + string fileName; + int seekOffset; + GetPlayerFileNameAndOffset(liveTvStream, out fileName, out seekOffset); + g_Player.SeekAbsolute(g_Player.Duration + seekOffset); } else { - firstResult = result; - tvChannel = _currentChannel; - + // Seems a re-tune has failed, so keep track of the channel that + // was already being streamed and stop the current stream. + TvChannel resumeChannel = _currentChannel; g_Player.ContinueGraph(); resumeGraph = false; SilentlyStopLiveTv(liveTvStream); + // Now re-try the new channel with a new stream. liveTvStream = null; result = this.TvControlAgent.TuneLiveTvStream(tvChannel, ref liveTvStream); if (result == LiveTvResult.Succeeded) { + // Success! Let's show the new stream. result = PlayLiveTv(liveTvStream); _currentChannel = tvChannel; } + else + { + // Still nothing :-( So keep track of the error-code and let's + // try to re-tune to the original channel. + firstResult = result; + liveTvStream = null; + result = this.TvControlAgent.TuneLiveTvStream(resumeChannel, ref liveTvStream); + if (result == LiveTvResult.Succeeded) + { + result = PlayLiveTv(liveTvStream); + _currentChannel = resumeChannel; + } + } } } catch @@ -672,6 +709,7 @@ int seekOffset; GetPlayerFileNameAndOffset(liveTvStream, out fileName, out seekOffset); + TvRecorded.RememberActiveRecordingPosition(); if (g_Player.Play(fileName, g_Player.MediaType.TV)) { _liveTvStream = liveTvStream; @@ -730,7 +768,7 @@ if (_currentProgram != null) { g_Player.currentTitle = _currentProgram.CreateProgramTitle(); - g_Player.currentDescription = Utility.GetComposedDescription(_currentProgram); + g_Player.currentDescription = _currentProgram.CreateCombinedDescription(true); } else { @@ -744,11 +782,7 @@ { using (TvSchedulerServiceAgent tvSchedulerAgent = new TvSchedulerServiceAgent()) { - CurrentAndNextProgram currentAndNext = tvSchedulerAgent.GetCurrentAndNextForChannel(_currentChannel.TvChannelId); - if (currentAndNext != null) - { - _currentNextProgram = currentAndNext; - } + SetCurrentAndNext(tvSchedulerAgent.GetCurrentAndNextForChannel(_currentChannel.TvChannelId)); } } @@ -768,8 +802,8 @@ _asyncStopLiveTvThread.Start(); } } + SetCurrentAndNext(null); _currentChannel = null; - _currentNextProgram = null; } public void StopLiveTv() @@ -781,8 +815,8 @@ _liveTvStream = null; _previousChannel = _currentChannel; } + SetCurrentAndNext(null); _currentChannel = null; - _currentNextProgram = null; } public void SendLiveTvKeepAlive() @@ -811,6 +845,10 @@ dlg.SetLine(1, "Not supported on your recorder/tuner(s)"); break; + case LiveTvResult.NoRetunePossible: + dlg.SetLine(1, "It was not possible to re-tune live TV"); + break; + case LiveTvResult.UnknownError: dlg.SetLine(1, "Unknown error"); break; @@ -868,6 +906,8 @@ { _channels = new List<TvChannel>(); } + _channelsByNumber.Clear(); + _groupsByChannelNumber.Clear(); } catch (Exception ex) { Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordHome.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordHome.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/ForTheRecordHome.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -705,7 +705,7 @@ internal static bool AvoidRtspForLiveTv { - get { return GetCachedBooleanSetting(SettingName.AvoidRtspForLiveTv, true); } + get { return GetCachedBooleanSetting(SettingName.AvoidRtspForLiveTv, false); } } private static Dictionary<string, bool> _booleanSettings = new Dictionary<string, bool>(); @@ -830,7 +830,7 @@ GUIPropertyManager.SetProperty("#TV.View.remaining", global::MediaPortal.Util.Utils.SecondsToHMSString(current.StopTime - current.StartTime)); GUIPropertyManager.SetProperty("#TV.View.genre", current.Category); GUIPropertyManager.SetProperty("#TV.View.title", current.Title); - GUIPropertyManager.SetProperty("#TV.View.description", Utility.GetComposedDescription(current)); + GUIPropertyManager.SetProperty("#TV.View.description", current.CreateCombinedDescription(true)); } if (next == null) @@ -848,7 +848,7 @@ GUIPropertyManager.SetProperty("#TV.Next.remaining", global::MediaPortal.Util.Utils.SecondsToHMSString(next.StopTime - next.StartTime)); GUIPropertyManager.SetProperty("#TV.Next.genre", next.Category); GUIPropertyManager.SetProperty("#TV.Next.title", next.Title); - GUIPropertyManager.SetProperty("#TV.Next.description", Utility.GetComposedDescription(next)); + GUIPropertyManager.SetProperty("#TV.Next.description", next.CreateCombinedDescription(true)); } string logo = Utility.GetLogoImage(ForTheRecordHome.Navigator.CurrentChannel, tvSchedulerAgent); @@ -1189,11 +1189,11 @@ { using (TvGuideServiceAgent tvGuideAgent = new TvGuideServiceAgent()) { - GuideProgram[] programs = + GuideProgramSummary[] programs = tvGuideAgent.GetChannelProgramsBetween(channel.GuideChannelId.Value, time, time); if (programs.Length > 0) { - return programs[0]; + return tvGuideAgent.GetProgramById(programs[0].GuideProgramId); } } } Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/PostBuild.cmd =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/PostBuild.cmd 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/PostBuild.cmd 2009-02-07 15:41:24 UTC (rev 2613) @@ -19,6 +19,6 @@ xcopy /S /Y /I %1..\..\skin %mpDir%\skin xcopy /S /Y /I %1..\..\language %mpDir%\language :reallyEnd - IF EXIST "C:\ProgramData\Team MediaPortal\MediaPortal\Cache" DEL /S /Q "C:\ProgramData\Team MediaPortal\MediaPortal\Cache" - IF EXIST "C:\Documents And Settings\All Users\Application Data\Team Mediaportal\Mediaportal\Cache" DEL /S /Q "C:\Documents And Settings\All Users\Application Data\Team Mediaportal\Mediaportal\Cache" + REM IF EXIST "C:\ProgramData\Team MediaPortal\MediaPortal\Cache" DEL /S /Q "C:\ProgramData\Team MediaPortal\MediaPortal\Cache" + REM IF EXIST "C:\Documents And Settings\All Users\Application Data\Team Mediaportal\Mediaportal\Cache" DEL /S /Q "C:\Documents And Settings\All Users\Application Data\Team Mediaportal\Mediaportal\Cache" exit 0 Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Properties/AssemblyInfo.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Properties/AssemblyInfo.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ForTheRecord.UI.MediaPortal")] -[assembly: AssemblyCopyright("Copyright © ForTheRecord 2007-2008")] +[assembly: AssemblyCopyright("Copyright © ForTheRecord 2007-2009")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/SetupForm.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/SetupForm.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/SetupForm.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TVZapOSD.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TVZapOSD.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TVZapOSD.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -180,7 +180,7 @@ void Get_TimeInfo() { string strTime = channelName; - GuideProgram prog = ForTheRecordHome.Navigator.ZapProgram; + GuideProgramSummary prog = ForTheRecordHome.Navigator.ZapProgram; if (prog != null) { strTime = String.Format("{0}-{1}", prog.StartTime.ToShortTimeString(), prog.StopTime.ToShortTimeString()); @@ -388,7 +388,7 @@ void UpdateProgressBar() { double fPercent = 0.0; - GuideProgram prog = ForTheRecordHome.Navigator.ZapProgram; + GuideProgramSummary prog = ForTheRecordHome.Navigator.ZapProgram; if (prog != null) { string strTime = String.Format("{0}-{1}", prog.StartTime.ToShortTimeString(), prog.StopTime.ToShortTimeString()); Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TextId.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TextId.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TextId.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Translator.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Translator.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/Translator.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 ForTheRecord + * Copyright (C) 2007-2009 ForTheRecord * http://www.4therecord.eu * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvFullScreen.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvFullScreen.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvFullScreen.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -1408,11 +1408,14 @@ { case 4: //TVGuide { +#if false TvGuideDialog dlgTvGuide = (TvGuideDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVGUIDE); - _isDialogVisible = true; dlgTvGuide.DoModal(GetID); _isDialogVisible = false; +#else + GUIWindowManager.ActivateWindow(WindowId.TvGuide); +#endif break; } @@ -2215,22 +2218,24 @@ _channelName += chKey; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.LABEL_ROW1, 0, 0, null); - string displayedChannelName = string.Empty; + string displayedChannelName = String.Empty; - if (_byIndex) + int channelNr; + if (!Int32.TryParse(_channelName, out channelNr)) + return; + TvChannel tvChannel = _byIndex ? + ForTheRecordHome.Navigator.GetChannelByIndex(channelNr) : ForTheRecordHome.Navigator.GetChannelByNumber(channelNr); + if (tvChannel != null) { - int channelNr; - if (!Int32.TryParse(_channelName, out channelNr)) - return; - if (channelNr > ForTheRecordHome.Navigator.ChannelCount) - return; - TvChannel tvChannel = ForTheRecordHome.Navigator.GetChannelByNumber(channelNr); - displayedChannelName = tvChannel == null ? String.Empty : tvChannel.DisplayName; + displayedChannelName = tvChannel.DisplayName; } - if (displayedChannelName != string.Empty) - msg.Label = String.Format("{0} ({1})", _channelName, displayedChannelName); // Channel + + string channelText; + if (displayedChannelName != String.Empty) + channelText = String.Format("{0} ({1})", _channelName, displayedChannelName); else - msg.Label = String.Format("{0}", _channelName); // Channel + channelText = String.Format("{0}", _channelName); + msg.Label = channelText.Substring(0, Math.Min(12, channelText.Length)); GUIControl cntTarget = base.GetControl((int)Control.LABEL_ROW1); if (cntTarget != null) @@ -2280,13 +2285,24 @@ { Log.Debug("ChangeChannelNr()"); - TvChannel tvChannel = ForTheRecordHome.Navigator.GetChannelByNumber(channelNr); - if (tvChannel != null) + if (_byIndex) { - ForTheRecordHome.Navigator.ZapToChannel(tvChannel, false); - UpdateOSD(); - _zapTimeOutTimer = DateTime.Now; + TvChannel tvChannel = ForTheRecordHome.Navigator.GetChannelByIndex(channelNr); + if (tvChannel != null) + { + ForTheRecordHome.Navigator.ZapToChannel(tvChannel, false); + UpdateOSD(); + _zapTimeOutTimer = DateTime.Now; + } } + else + { + if (ForTheRecordHome.Navigator.ZapToChannelNumber(channelNr, false)) + { + UpdateOSD(); + _zapTimeOutTimer = DateTime.Now; + } + } } public void ZapPreviousChannel() Modified: trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideBase.cs =================================================================== --- trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideBase.cs 2009-02-07 15:15:14 UTC (rev 2612) +++ trunk/plugins/ForTheRecord/ForTheRecord.UI.MediaPortal/TvGuideBase.cs 2009-02-07 15:41:24 UTC (rev 2613) @@ -128,6 +128,8 @@ int _backupChannelOffset = 0; DateTime _updateTimer = DateTime.Now; + bool _showChannelNumber = false; + #endregion #region ctor @@ -176,6 +178,7 @@ _currentChannelName = xmlreader.GetValueAsString("tvguide", "channel", String.Empty); _cursorX = xmlreader.GetValueAsInt("tvguide", "ypos", 0); _channelOffset = xmlreader.GetValueAsInt("tvguide", "yoffset", 0); + _showChannelNumber = xmlreader.GetValueAsBool("mytv", "showchannelnumber", false); } } @@ -1177,7 +1180,7 @@ GUIPropertyManager.SetProperty("#TV.Guide.Title", _currentProgram.Title); GUIPropertyManager.SetProperty("#TV.Guide.Time", strTime); - GUIPropertyManager.SetProperty("#TV.Guide.Description", Utility.GetComposedDescrip... [truncated message content] |