/// <summary> /// Create Timeshifting filename based on RTSP url, UNC or real path. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static string GetFileNameForTimeshifting() { bool useRTSP = TVHome.UseRTSP(); string fileName = ""; if (!useRTSP) //SMB mode { bool fileExists = File.Exists(TVHome.Card.TimeShiftFileName); if (!fileExists) // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.TimeshiftingPath().Length > 0) { //use user defined timeshifting folder as either UNC or network drive fileName = Path.GetFileName(TVHome.Card.TimeShiftFileName); fileName = TVHome.TimeshiftingPath() + "\\" + fileName; } else // use automatic UNC path { fileName = TVHome.Card.TimeShiftFileName.Replace(":", ""); fileName = "\\\\" + RemoteControl.HostName + "\\" + fileName; } } else { fileName = TVHome.Card.TimeShiftFileName; } } else //RTSP mode, get RTSP url { fileName = TVHome.Card.RTSPUrl; } return(fileName); }
/* * /// <summary> * /// On close * /// </summary> * private void Close() * { * GUIWindowManager.IsSwitchingToNewWindow = true; * lock (this) * { * GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, 0, 0, null); * OnMessage(msg); * * GUIWindowManager.UnRoute(); * _running = false; * _parentWindow = null; * } * GUIWindowManager.IsSwitchingToNewWindow = false; * GUILayerManager.UnRegisterLayer(this); * } */ /// <summary> /// On Message /// </summary> /// <param name="message"></param> /// <returns></returns> public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_CLICKED: { if (message.SenderControlId == 35 || message.SenderControlId == 37) // listbox { if ((int)Action.ActionType.ACTION_SELECT_ITEM == message.Param1) { // switching logic SelectedChannel = (Channel)lstChannels.SelectedListItem.TVTag; Channel changeChannel = null; if (AutoZap) { if (TVHome.Navigator.Channel.IdChannel != SelectedChannel.IdChannel || !g_Player.IsTimeShifting || g_Player.IsTVRecording) { List <Channel> tvChannelList = GetChannelListByGroup(); if (tvChannelList != null) { changeChannel = (Channel)tvChannelList[lstChannels.SelectedListItemIndex]; } } } _canceled = false; PageDestroy(); //This one shows the zapOSD when changing channel from mini GUIDE, this is currently unwanted. /* * TvFullScreen TVWindow = (TvFullScreen)GUIWindowManager.GetWindow((int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN); * if (TVWindow != null) TVWindow.UpdateOSD(changeChannel.Name); */ TVHome.UserChannelChanged = true; if (changeChannel != null) { TVHome.ViewChannel(changeChannel); } } } else if (message.SenderControlId == 36) // spincontrol { // switch group OnGroupChanged(); } else if (message.SenderControlId == 34) // exit button { // exit _canceled = true; PageDestroy(); } break; } } return(base.OnMessage(message)); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnTvGroup) { TVHome.OnSelectGroup(); UpdateList(); } base.OnClicked(controlId, control, actionType); }
public override void Process() { if (needUpdate) { needUpdate = false; LoadDirectory(); } TVHome.UpdateProgressPercentageBar(); }
public override void Process() { base.Process(); if (_refreshList) { Search(); _refreshList = false; } TVHome.UpdateProgressPercentageBar(); }
public static void Play() { // We have the Station Name in there to retrieve the correct Coverart for the station in the Vis Window GUIPropertyManager.RemovePlayerProperties(); GUIPropertyManager.SetProperty("#Play.Current.ArtistThumb", _currentChannel.DisplayName); GUIPropertyManager.SetProperty("#Play.Current.Album", _currentChannel.DisplayName); if ((_currentChannel.IsWebstream()) || (_currentChannel.CurrentProgram == null || _currentChannel.NextProgram == null || string.IsNullOrEmpty(_currentChannel.CurrentProgram.Title) || string.IsNullOrEmpty(_currentChannel.NextProgram.Title))) { GUIPropertyManager.SetProperty("#Play.Current.Title", _currentChannel.DisplayName); // No EPG GUIPropertyManager.SetProperty("#Play.Next.Title", string.Empty); } else { GUIPropertyManager.SetProperty("#Play.Current.Title", _currentChannel.CurrentProgram.Title); GUIPropertyManager.SetProperty("#Play.Next.Title", _currentChannel.NextProgram.Title); } string strLogo = Utils.GetCoverArt(Thumbs.Radio, _currentChannel.DisplayName); if (string.IsNullOrEmpty(strLogo)) { strLogo = "defaultMyRadioBig.png"; } GUIPropertyManager.SetProperty("#Play.Current.Thumb", strLogo); if (g_Player.Playing && !_currentChannel.IsWebstream()) { if (!g_Player.IsTimeShifting || (g_Player.IsTimeShifting && _currentChannel.IsWebstream())) { g_Player.Stop(); } } if (_currentChannel.IsWebstream()) { g_Player.PlayAudioStream(GetPlayPath(_currentChannel)); GUIPropertyManager.SetProperty("#Play.Current.Title", _currentChannel.DisplayName); } else { if (g_Player.IsRadio && g_Player.Playing) { Channel currentlyPlaying = TVHome.Navigator.Channel; if (currentlyPlaying != null && currentlyPlaying.IdChannel == _currentChannel.IdChannel) { return; } } TVHome.ViewChannelAndCheck(_currentChannel); } }
private void OnTvGroup() { List <ChannelGroup> tvGroups = TVHome.Navigator.Groups; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { TVHome.OnSelectGroup(); UpdateList(); } }
/// <summary> /// Create Recording filename based on RTSP url, UNC or real path. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static string GetFileNameForRecording(Recording rec) { bool useRTSP = TVHome.UseRTSP(); string fileName = ""; if (!useRTSP) //SMB mode { bool fileExists = File.Exists(rec.FileName); if (!fileExists) // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.RecordingPath().Length > 0) { //use user defined recording folder as either UNC or network drive fileName = Path.GetFileName(rec.FileName); string fileNameSimple = TVHome.RecordingPath() + "\\" + fileName; fileExists = File.Exists(fileNameSimple); if (!fileExists) //maybe file exist in folder, schedules recs often appear in folders, no way to intelligently determine this. { DirectoryInfo dirInfo = Directory.GetParent(rec.FileName); if (dirInfo != null) { string parentFolderName = dirInfo.Name; fileName = TVHome.RecordingPath() + "\\" + parentFolderName + "\\" + fileName; } } else { fileName = fileNameSimple; } } else // use automatic UNC path { fileName = rec.FileName.Replace(":", ""); fileName = "\\\\" + RemoteControl.HostName + "\\" + fileName; } } else //file exists, return it. { fileName = rec.FileName; } } else //RTSP mode, get RTSP url for file. { fileName = TVHome.TvServer.GetStreamUrlForFileName(rec.IdRecording); } return(fileName); }
private GUIListControl getChannelList() { GUIListControl lstChannels = null; if (TVHome.ShowChannelStateIcons() && lstChannelsWithStateIcons != null) { lstChannels = lstChannelsWithStateIcons; } else { lstChannels = lstChannelsNoStateIcons; } return(lstChannels); }
protected override void OnPageLoad() { if (!TVHome.Connected) { RemoteControl.Clear(); GUIWindowManager.ActivateWindow((int)Window.WINDOW_SETTINGS_TVENGINE); return; } TVHome.WaitForGentleConnection(); if (TVHome.Navigator == null) { TVHome.OnLoaded(); } else if (TVHome.Navigator.Channel == null) { TVHome.m_navigator.ReLoad(); TVHome.LoadSettings(false); } if (TVHome.m_navigator == null) { TVHome.m_navigator = new ChannelNavigator(); // Create the channel navigator (it will load groups and channels) } base.OnPageLoad(); if (btnPriorities != null) { btnPriorities.Visible = false; } //@ ConflictManager.OnConflictsUpdated += new MediaPortal.TV.Recording.ConflictManager.OnConflictsUpdatedHandler(ConflictManager_OnConflictsUpdated); LoadSettings(); needUpdate = false; selectedItem = null; LoadDirectory(); while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0) { m_iSelectedItem--; } GUIControl.SelectItemControl(GetID, listSchedules.GetID, m_iSelectedItem); btnSortBy.SortChanged += new SortEventHandler(SortChanged); }
///<summary> /// streams : 1 /// stream1 : ac3, lang: dan. /// pref_lang : empty /// PreferAC3 : false /// PreferAudioTypeOverLang : false ///</summary> public void GetPreferedAudioStreamIndexTest2() { g_Player.Player = new PlayerSingleAudioStreamAC3Dan(); List <string> prefLangs = new List <string>(); TVHome.PreferredLanguages = prefLangs; //empty TVHome.PreferAC3 = false; TVHome.PreferAudioTypeOverLang = false; eAudioDualMonoMode dualMonoMode = eAudioDualMonoMode.UNSUPPORTED; int index = TVHome.GetPreferedAudioStreamIndex(out dualMonoMode); Assert.AreEqual(0, index, "Wrong audio index returned"); Assert.AreEqual(eAudioDualMonoMode.UNSUPPORTED, dualMonoMode, "dualMonoMode returned should be UNSUPPORTED"); }
///<summary> /// streams : 5 /// stream1 : mpeg1 , lang: dan /// stream2 : mpeg1 dualmono, lang: left: dan right: eng. /// stream3 : mpeg1 dualmono, lang: left: deu right: swe. /// stream4 : ac3 , lang: eng /// stream5 : mpeg1 , lang: eng /// pref_lang : eng /// PreferAC3 : false /// PreferAudioTypeOverLang : false ///</summary> public void GetPreferedAudioStreamIndexTest25() { g_Player.Player = new PlayerMultipleDualMonoAudioStreams(); List <string> prefLangs = new List <string>(); prefLangs.Add("eng"); TVHome.PreferredLanguages = prefLangs; //empty TVHome.PreferAC3 = false; TVHome.PreferAudioTypeOverLang = false; eAudioDualMonoMode dualMonoMode = eAudioDualMonoMode.UNSUPPORTED; int index = TVHome.GetPreferedAudioStreamIndex(out dualMonoMode); Assert.AreEqual(1, index, "Wrong audio index returned"); Assert.AreEqual(eAudioDualMonoMode.RIGHT_MONO, dualMonoMode, "dualMonoMode returned should be RIGHT_MONO"); }
public static bool PlayRecording(Recording rec, double startOffset, g_Player.MediaType mediaType) { string fileName = GetFileNameForRecording(rec); bool useRTSP = TVHome.UseRTSP(); string chapters = useRTSP ? TVHome.TvServer.GetChaptersForFileName(rec.IdRecording) : null; Log.Info("PlayRecording:{0} - using rtsp mode:{1}", fileName, useRTSP); if (g_Player.Play(fileName, mediaType, chapters)) { if (Utils.IsVideo(fileName) && !g_Player.IsRadio) { g_Player.ShowFullScreenWindow(); } if (startOffset > 0) { g_Player.SeekAbsolute(startOffset); } else if (startOffset == -1) { // 5 second margin is used that the TsReader wont stop playback right after it has been started double dTime = g_Player.Duration - 5; g_Player.SeekAbsolute(dTime); } TvRecorded.SetActiveRecording(rec); //populates recording metadata to g_player; g_Player.currentFileName = rec.FileName; g_Player.currentTitle = GetDisplayTitle(rec); g_Player.currentDescription = rec.Description; rec.TimesWatched++; rec.Persist(); return(true); } return(false); }
protected override void OnPageLoad() { TVHome.WaitForGentleConnection(); base.OnPageLoad(); if (btnPriorities != null) { btnPriorities.Visible = false; } //@ ConflictManager.OnConflictsUpdated += new MediaPortal.TV.Recording.ConflictManager.OnConflictsUpdatedHandler(ConflictManager_OnConflictsUpdated); LoadSettings(); needUpdate = false; selectedItem = null; LoadDirectory(); while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0) { m_iSelectedItem--; } GUIControl.SelectItemControl(GetID, listSchedules.GetID, m_iSelectedItem); btnSortBy.SortChanged += new SortEventHandler(SortChanged); }
/// <summary> /// Checks if it is time to zap to a different channel. This is called during Process(). /// </summary> public bool CheckChannelChange() { if (reentrant) { return(false); } try { reentrant = true; // Zapping to another group or channel? if (m_zapgroup != -1 || m_zapchannel != null) { // Time to zap? if (DateTime.Now >= m_zaptime) { // Zapping to another group? if (m_zapgroup != -1 && m_zapgroup != m_currentgroup) { // Change current group and zap to the first channel of the group m_currentgroup = m_zapgroup; if (CurrentGroup != null && CurrentGroup.ReferringGroupMap().Count > 0) { GroupMap gm = (GroupMap)CurrentGroup.ReferringGroupMap()[0]; Channel chan = (Channel)gm.ReferencedChannel(); m_zapchannel = chan; } } m_zapgroup = -1; //if (m_zapchannel != m_currentchannel) // lastViewedChannel = m_currentchannel; // Zap to desired channel if (m_zapchannel != null) // might be NULL after tuning failed { Channel zappingTo = m_zapchannel; //remember to apply the new group also. if (m_zapchannel.CurrentGroup != null) { m_currentgroup = GetGroupIndex(m_zapchannel.CurrentGroup.GroupName); Log.Info("Channel change:{0} on group {1}", zappingTo.DisplayName, m_zapchannel.CurrentGroup.GroupName); } else { Log.Info("Channel change:{0}", zappingTo.DisplayName); } m_zapchannel = null; TVHome.ViewChannel(zappingTo); } m_zapChannelNr = -1; reentrant = false; return(true); } } } finally { reentrant = false; } return(false); }
private void OnShowContextMenu(int iItem, bool clicked) { m_iSelectedItem = iItem; GUIListItem item = GetItem(iItem); if (item == null) { return; } if (item.IsFolder && clicked) { bool noitems = false; if (item.Label == "..") { if (selectedItem != null) { selectedItem = null; } LoadDirectory(); return; } if (selectedItem == null) { IList <Schedule> seriesList = TVHome.Util.GetRecordingTimes(item.TVTag as Schedule); if (seriesList.Count < 1) { noitems = true; // no items existing } else { selectedItem = item.TVTag as Schedule; } } if (noitems == false) { LoadDirectory(); return; } } bool showSeries = btnSeries.Selected; Schedule rec = item.TVTag as Schedule; if (rec == null) { return; } Log.Info("OnShowContextMenu: Rec = {0}", rec.ToString()); GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(rec.ProgramName); if (showSeries && item.IsFolder) { dlg.AddLocalizedString(982); //Cancel this show (618=delete) dlg.AddLocalizedString(888); //Episodes management } else if (rec.Series == false) { dlg.AddLocalizedString(618); //delete } else { dlg.AddLocalizedString(981); //Cancel this show dlg.AddLocalizedString(982); //Delete this entire recording dlg.AddLocalizedString(888); //Episodes management } VirtualCard card; TvServer server = new TvServer(); bool isRec = Schedule.IsScheduleRecording(rec.IdSchedule); //TVHome.IsRecordingSchedule(rec, null, out card); if (isRec) { dlg.AddLocalizedString(979); //Play recording from beginning dlg.AddLocalizedString(980); //Play recording from live point } //Schedule schedDB = Schedule.Retrieve(rec.IdSchedule); //if (schedDB.ScheduleType != (int)ScheduleRecordingType.Once) //{ dlg.AddLocalizedString(1048); // settings //} dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } bool isSchedRec = TvDatabase.Schedule.IsScheduleRecording(rec.IdSchedule); //TVHome.IsRecordingSchedule(rec, null, out card); string fileName = ""; if (isSchedRec) { bool isCardRec = server.IsRecording(rec.ReferencedChannel().IdChannel, out card); if (isCardRec && card != null) { fileName = card.RecordingFileName; } } Log.Info("recording fname:{0}", fileName); switch (dlg.SelectedId) { case 888: ////Episodes management TvPriorities.OnSetEpisodesToKeep(rec); break; case 1048: ////settings Schedule schedule = item.MusicTag as Schedule; if (schedule == null) { schedule = item.TVTag as Schedule; } if (schedule != null) { TVProgramInfo.CurrentRecording = schedule; GUIWindowManager.ActivateWindow((int)Window.WINDOW_TV_PROGRAM_INFO); } return; case 882: ////Quality settings TvPriorities.OnSetQuality(rec); break; case 981: //Cancel this show { var layer = new TvBusinessLayer(); // get the program that this episode is for var progs = layer.GetPrograms(rec.ReferencedChannel(), rec.StartTime, rec.EndTime); // pick up the schedule that is actually used for recording // see TVUtil.GetRecordingTimes where schedules are all spawend as one off types // and this is what rec is (ie. it does not actually exist in the database) var realSchedule = Schedule.Retrieve(rec.IdParentSchedule) ?? rec; bool res = TVUtil.DeleteRecAndSchedWithPrompt(realSchedule, progs[0]); if (res) { LoadDirectory(); } } break; case 982: //Delete series recording goto case 618; case 618: // delete entire recording { bool res = TVUtil.DeleteRecAndEntireSchedWithPrompt(rec, rec.StartTime); if (res) { if (showSeries && !item.IsFolder) { OnShowContextMenu(0, true); return; } else { LoadDirectory(); } } } break; case 979: // Play recording from beginning { Recording recDB = Recording.Retrieve(fileName); if (recDB != null) { TVUtil.PlayRecording(recDB); } } return; case 980: // Play recording from live point { TVHome.ViewChannelAndCheck(rec.ReferencedChannel()); if (g_Player.Playing) { g_Player.ShowFullScreenWindow(); } /* * g_Player.Stop(); * if (System.IO.File.Exists(fileName)) * { * g_Player.Play(fileName, g_Player.MediaType.Recording); * g_Player.SeekAbsolute(g_Player.Duration); * g_Player.ShowFullScreenWindow(); * return; * } * else * { * string url = server.GetRtspUrlForFile(fileName); * Log.Info("recording url:{0}", url); * if (url.Length > 0) * { * g_Player.Play(url, g_Player.MediaType.Recording); * * if (g_Player.Playing) * { * g_Player.SeekAbsolute(g_Player.Duration); * g_Player.SeekAbsolute(g_Player.Duration); * g_Player.ShowFullScreenWindow(); * return; * } * } * }*/ } break; } while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0) { m_iSelectedItem--; } GUIControl.SelectItemControl(GetID, listSchedules.GetID, m_iSelectedItem); }
private void OnClick(int iItem) { m_iSelectedItem = GetSelectedItemNo(); GUIListItem item = GetItem(iItem); if (item == null) { return; } Schedule rec = (Schedule)item.TVTag; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(rec.ProgramName); if (rec.Series == false) { dlg.AddLocalizedString(618); //delete } else { dlg.AddLocalizedString(981); //Delete this recording dlg.AddLocalizedString(982); //Delete series recording dlg.AddLocalizedString(888); //Episodes management } VirtualCard card; TvServer server = new TvServer(); if (server.IsRecordingSchedule(rec.IdSchedule, out card)) { dlg.AddLocalizedString(979); //Play recording from beginning dlg.AddLocalizedString(980); //Play recording from live point } else { IList <TuningDetail> details = Channel.Retrieve(rec.IdChannel).ReferringTuningDetail(); foreach (TuningDetail detail in details) { if (detail.ChannelType == 0) { dlg.AddLocalizedString(882); //Quality settings break; } } } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 888: ////Episodes management OnSetEpisodesToKeep(rec); break; case 882: OnSetQuality(rec); break; case 981: //Delete this recording only { if (server.IsRecordingSchedule(rec.IdSchedule, out card)) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording? dlgYesNo.SetLine(1, GUILocalizeStrings.Get(730)); //This schedule is recording. If you delete dlgYesNo.SetLine(2, GUILocalizeStrings.Get(731)); //the schedule then the recording is stopped. dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { server.StopRecordingSchedule(rec.IdSchedule); CanceledSchedule schedule = new CanceledSchedule(rec.IdSchedule, rec.IdChannel, rec.StartTime); rec.Persist(); server.OnNewSchedule(); } } } else { server.StopRecordingSchedule(rec.IdSchedule); CanceledSchedule schedule = new CanceledSchedule(rec.IdSchedule, rec.IdChannel, rec.StartTime); rec.Persist(); server.OnNewSchedule(); } LoadDirectory(); } break; case 982: //Delete series recording goto case 618; case 618: // delete entire recording { if (server.IsRecordingSchedule(rec.IdSchedule, out card)) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording? dlgYesNo.SetLine(1, GUILocalizeStrings.Get(730)); //This schedule is recording. If you delete dlgYesNo.SetLine(2, GUILocalizeStrings.Get(731)); //the schedule then the recording is stopped. dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { server.StopRecordingSchedule(rec.IdSchedule); rec.Delete(); server.OnNewSchedule(); } } } else { rec.Delete(); server.OnNewSchedule(); } LoadDirectory(); } break; case 979: // Play recording from beginning if (g_Player.Playing && g_Player.IsTVRecording) { g_Player.Stop(true); } //TVHome.IsTVOn = true; TVHome.ViewChannel(rec.ReferencedChannel()); g_Player.SeekAbsolute(0); if (TVHome.Card.IsTimeShifting) { g_Player.ShowFullScreenWindow(); return; } break; case 980: // Play recording from live point //TVHome.IsTVOn = true; TVHome.ViewChannel(rec.ReferencedChannel()); if (TVHome.Card.IsTimeShifting) { if (g_Player.Playing) { g_Player.SeekAsolutePercentage(99); } g_Player.ShowFullScreenWindow(); return; } break; } while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0) { m_iSelectedItem--; } GUIControl.SelectItemControl(GetID, listPriorities.GetID, m_iSelectedItem); }
public override void Process() { TVHome.UpdateProgressPercentageBar(); }
/// <summary> /// Create Recording filename based on RTSP url, UNC or real path. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static string GetFileNameForRecording(Recording rec) { bool useRTSP = TVHome.UseRTSP(); string fileName = ""; if (!useRTSP) //SMB mode { bool fileExists = File.Exists(rec.FileName); if (!fileExists) // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.RecordingPath().Length > 0) { //use user defined recording folder as either UNC or network drive fileName = Path.GetFileName(rec.FileName); string fileNameSimple = TVHome.RecordingPath() + "\\" + fileName; fileExists = File.Exists(fileNameSimple); if (!fileExists) //maybe file exist in folder, schedules recs often appear in folders, no way to intelligently determine this. { DirectoryInfo dirInfo = Directory.GetParent(rec.FileName); if (dirInfo != null) { string parentFolderName = dirInfo.Name; fileName = TVHome.RecordingPath() + "\\" + parentFolderName + "\\" + fileName; } fileExists = File.Exists(fileName); //check with foldername from set UNC Path if (!fileExists) { //Get last foldername of RecordingPath string parentFolderNameRecording = Path.GetFileName(TVHome.RecordingPath().TrimEnd(Path.DirectorySeparatorChar)); parentFolderNameRecording = @"\" + parentFolderNameRecording.Replace(@"\", "\"\"") + @"\"; //Replace "\" with "" and add a "\" at the beginning and end (good for searching the path in the recording filename) //Search the last folder of the set recording path in var rec.FileName int iPos = rec.FileName.IndexOf(parentFolderNameRecording); if (iPos != -1) { //We have found the last Folder of the set recording path in var rec.FileName //Cut the first string (ussaly the TV Server Local Path) and remove the last Recording Folder from string fileName = rec.FileName.Substring(iPos).Replace(parentFolderNameRecording, ""); //Add the recording path fileName = TVHome.RecordingPath() + "\\" + fileName; } } } else { fileName = fileNameSimple; } } else // use automatic UNC path { fileName = rec.FileName.Replace(":", ""); fileName = "\\\\" + RemoteControl.HostName + "\\" + fileName; } } else //file exists, return it. { fileName = rec.FileName; } } else //RTSP mode, get RTSP url for file. { fileName = TVHome.TvServer.GetStreamUrlForFileName(rec.IdRecording); } return(fileName); }
protected override void OnPageLoad() { Log.Info("RadioHome:OnPageLoad"); if (!TVHome.Connected) { RemoteControl.Clear(); GUIWindowManager.ActivateWindow((int)Window.WINDOW_SETTINGS_TVENGINE); return; } if (TVHome.Navigator == null) { TVHome.OnLoaded(); } else if (TVHome.Navigator.Channel == null) { TVHome.m_navigator.ReLoad(); TVHome.LoadSettings(false); } // Create the channel navigator (it will load groups and channels) if (TVHome.m_navigator == null) { TVHome.m_navigator = new ChannelNavigator(); } // Reload ChannelGroups Radio radioLoad = (Radio)GUIWindowManager.GetWindow((int)Window.WINDOW_RADIO); radioLoad.OnAdded(); base.OnPageLoad(); GUIMessage msgStopRecorder = new GUIMessage(GUIMessage.MessageType.GUI_MSG_RECORDER_STOP, 0, 0, 0, 0, 0, null); GUIWindowManager.SendMessage(msgStopRecorder); switch (currentSortMethod) { case SortMethod.Name: btnSortBy.SelectedItem = 0; break; case SortMethod.Type: btnSortBy.SelectedItem = 1; break; case SortMethod.Genre: btnSortBy.SelectedItem = 2; break; case SortMethod.Bitrate: btnSortBy.SelectedItem = 3; break; case SortMethod.Number: btnSortBy.SelectedItem = 4; break; } SelectCurrentItem(); LoadDirectory(currentFolder); SetLastChannel(); if ((_autoTurnOnRadio) && !(g_Player.Playing && g_Player.IsRadio)) { GUIListItem item = facadeLayout.SelectedListItem; if (item != null && item.Label != ".." && !item.IsFolder) { Play(facadeLayout.SelectedListItem); } } btnSortBy.SortChanged += SortChanged; }
/// <summary> /// Fill the list with channels /// </summary> public void FillChannelList() { List <Channel> tvChannelList = GetChannelListByGroup(); benchClock = Stopwatch.StartNew(); DateTime nextEPGupdate = GetNextEpgUpdate(); Dictionary <int, NowAndNext> listNowNext = GetNowAndNext(tvChannelList, nextEPGupdate); benchClock.Stop(); Log.Debug("TvMiniGuide: FillChannelList retrieved {0} programs for {1} channels in {2} ms", listNowNext.Count, tvChannelList.Count, benchClock.ElapsedMilliseconds.ToString()); GUIListItem item = null; string ChannelLogo = ""; //List<int> RecChannels = null; //List<int> TSChannels = null; int SelectedID = 0; int channelID = 0; bool DisplayStatusInfo = true; Dictionary <int, ChannelState> tvChannelStatesList = null; if (TVHome.ShowChannelStateIcons()) { benchClock.Reset(); benchClock.Start(); if (TVHome.Navigator.CurrentGroup.GroupName.Equals(TvConstants.TvGroupNames.AllChannels) || (!g_Player.IsTV && !g_Player.Playing)) { //we have no way of using the cached channelstates on the server in the following situations. // 1) when the "all channels" group is selected - too many channels. // 2) when user is not timeshifting - no user object on the server. User currentUser = new User(); tvChannelStatesList = TVHome.TvServer.GetAllChannelStatesForGroup(TVHome.Navigator.CurrentGroup.IdGroup, currentUser); } else { // use the more speedy approach // ask the server of the cached list of channel states corresponding to the user. tvChannelStatesList = TVHome.TvServer.GetAllChannelStatesCached(TVHome.Card.User); if (tvChannelStatesList == null) { //slow approach. tvChannelStatesList = TVHome.TvServer.GetAllChannelStatesForGroup(TVHome.Navigator.CurrentGroup.IdGroup, TVHome.Card.User); } } benchClock.Stop(); if (tvChannelStatesList != null) { Log.Debug("TvMiniGuide: FillChannelList - {0} channel states for group retrieved in {1} ms", Convert.ToString(tvChannelStatesList.Count), benchClock.ElapsedMilliseconds.ToString()); } } for (int i = 0; i < tvChannelList.Count; i++) { Channel CurrentChan = tvChannelList[i]; if (CurrentChan.VisibleInGuide) { ChannelState CurrentChanState = ChannelState.tunable; channelID = CurrentChan.IdChannel; if (TVHome.ShowChannelStateIcons()) { if (!tvChannelStatesList.TryGetValue(channelID, out CurrentChanState)) { CurrentChanState = ChannelState.tunable; } } //StringBuilder sb = new StringBuilder(); sb.Length = 0; item = new GUIListItem(""); // store here as it is not needed right now - please beat me later.. item.TVTag = CurrentChan; sb.Append(CurrentChan.DisplayName); ChannelLogo = Utils.GetCoverArt(Thumbs.TVChannel, CurrentChan.DisplayName); // if we are watching this channel mark it if (TVHome.Navigator != null && TVHome.Navigator.Channel != null && TVHome.Navigator.Channel.IdChannel == channelID) { item.IsRemote = true; SelectedID = lstChannels.Count; } if (!string.IsNullOrEmpty(ChannelLogo)) { item.IconImageBig = ChannelLogo; item.IconImage = ChannelLogo; } else { item.IconImageBig = string.Empty; item.IconImage = string.Empty; } if (DisplayStatusInfo) { bool showChannelStateIcons = (TVHome.ShowChannelStateIcons() && lstChannelsWithStateIcons != null); switch (CurrentChanState) { case ChannelState.nottunable: item.IsPlayed = true; if (showChannelStateIcons) { item.PinImage = Thumbs.TvIsUnavailableIcon; } else { sb.Append(" "); sb.Append(local1056); } break; case ChannelState.timeshifting: if (showChannelStateIcons) { item.PinImage = Thumbs.TvIsTimeshiftingIcon; } else { sb.Append(" "); sb.Append(local1055); } break; case ChannelState.recording: if (showChannelStateIcons) { item.PinImage = Thumbs.TvIsRecordingIcon; } else { sb.Append(" "); sb.Append(local1054); } break; default: item.IsPlayed = false; if (showChannelStateIcons) { item.PinImage = Thumbs.TvIsAvailableIcon; } break; } } //StringBuilder sbTmp = new StringBuilder(); sbTmp.Length = 0; NowAndNext currentNowAndNext = null; bool hasNowNext = listNowNext.TryGetValue(channelID, out currentNowAndNext); if (hasNowNext) { if (!string.IsNullOrEmpty(currentNowAndNext.TitleNow)) { TVUtil.TitleDisplay(sbTmp, currentNowAndNext.TitleNow, currentNowAndNext.EpisodeName, currentNowAndNext.SeriesNum, currentNowAndNext.EpisodeNum, currentNowAndNext.EpisodePart); } else { sbTmp.Append(local736); } } else { sbTmp.Append(local736); } item.Label2 = sbTmp.ToString(); sbTmp.Insert(0, local789); item.Label3 = sbTmp.ToString(); sbTmp.Length = 0; if (_showChannelNumber == true) { sb.Append(" - "); if (!_byIndex) { sb.Append(tvChannelList[i].ChannelNumber); } else { sb.Append(i + 1); } } if (hasNowNext) { // if the "Now" DB entry is in the future we set MinValue intentionally to avoid wrong percentage calculations DateTime startTime = currentNowAndNext.NowStartTime; if (startTime != SqlDateTime.MinValue.Value) { DateTime endTime = currentNowAndNext.NowEndTime; sb.Append(" - "); sb.Append( CalculateProgress(startTime, endTime).ToString()); sb.Append("%"); if (endTime < nextEPGupdate || nextEPGupdate == DateTime.MinValue) { nextEPGupdate = endTime; SetNextEpgUpdate(endTime); } } } if (hasNowNext && listNowNext[channelID].IdProgramNext != -1) { TVUtil.TitleDisplay(sbTmp, currentNowAndNext.TitleNext, currentNowAndNext.EpisodeNameNext, currentNowAndNext.SeriesNumNext, currentNowAndNext.EpisodeNumNext, currentNowAndNext.EpisodePartNext); } else { sbTmp.Append(local736); } item.Label2 = sb.ToString(); sbTmp.Insert(0, local790); item.Label = sbTmp.ToString(); lstChannels.Add(item); } } benchClock.Stop(); Log.Debug("TvMiniGuide: State check + filling completed after {0} ms", benchClock.ElapsedMilliseconds.ToString()); lstChannels.SelectedListItemIndex = SelectedID; if (lstChannels.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; }