// Image play method public bool OnPlayBD(String drive, int parentId) { Log.Info("SelectBDHandler: OnPlayBD() playing BD {0}", drive); string currentFile = g_Player.CurrentFile; if (g_Player.Playing && Util.Utils.IsISOImage(currentFile) && IsBDPlayList(ref currentFile)) //if (g_Player.Playing && IsBDPlayList(ref currentFile)) { return(true); } if (Util.Utils.getDriveType(drive) == 5) //cd or dvd drive { string driverLetter = drive.Substring(0, 1); string fileName = String.Format(@"{0}:\BDMV\index.bdmv", driverLetter); if (File.Exists(fileName)) { IMDBMovie movieDetails = new IMDBMovie(); //string name = DaemonTools._MountedIsoFile; int idFileImg = VideoDatabase.GetFileId(fileName); int idMovieImg = VideoDatabase.GetMovieId(fileName); /* * int timeMovieStopped = 0; * byte[] resumeData = null; * * if ((idMovieImg >= 0) && (idFileImg >= 0)) * { * timeMovieStopped = VideoDatabase.GetMovieStopTimeAndResumeData(idFileImg, out resumeData); * * if (timeMovieStopped > 0) * { * string title = Path.GetFileName(fileName); * VideoDatabase.GetMovieInfoById(idMovieImg, ref movieDetails); * * if (movieDetails.Title != string.Empty) * { * title = movieDetails.Title; * } * * GUIResumeDialog.Result result = * GUIResumeDialog.ShowResumeDialog(title, timeMovieStopped, * GUIResumeDialog.MediaType.DVD); * * if (result == GUIResumeDialog.Result.Abort) * return false; * * if (result == GUIResumeDialog.Result.PlayFromBeginning) * timeMovieStopped = 0; * } * } */ if (g_Player.Playing) { g_Player.Stop(); } g_Player.PlayBD(drive + @"\BDMV\index.bdmv"); g_Player.ShowFullScreenWindow(); /* * if (g_Player.Playing && timeMovieStopped > 0) * { * g_Player.SeekAbsolute(timeMovieStopped); * } */ return(true); } } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(3); //my videos Log.Error("SelectBDHandler: OnPlayBD() Plz Insert Disk"); dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(parentId); return(true); }
public bool OnPlayDVD(String drive, int parentId) { Log.Info("SelectDVDHandler: OnPlayDVD() playing DVD {0}", drive); if (g_Player.Playing && g_Player.IsDVD) { if (g_Player.CurrentFile.Equals(drive + @"\VIDEO_TS\VIDEO_TS.IFO")) { return(true); } } if (Util.Utils.getDriveType(drive) == 5) //cd or dvd drive { string driverLetter = drive.Substring(0, 1); string fileName = String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", driverLetter); if (!VirtualDirectories.Instance.Movies.RequestPin(fileName)) { return(false); } if (File.Exists(fileName)) { IMDBMovie movieDetails = new IMDBMovie(); VideoDatabase.GetMovieInfo(fileName, ref movieDetails); int idFile = VideoDatabase.GetFileId(fileName); int idMovie = VideoDatabase.GetMovieId(fileName); int timeMovieStopped = 0; byte[] resumeData = null; if ((idMovie >= 0) && (idFile >= 0)) { timeMovieStopped = VideoDatabase.GetMovieStopTimeAndResumeData(idFile, out resumeData, g_Player.SetResumeBDTitleState); //Log.Info("GUIVideoFiles: OnPlayBackStopped for DVD - idFile={0} timeMovieStopped={1} resumeData={2}", idFile, timeMovieStopped, resumeData); if (timeMovieStopped > 0) { string title = Path.GetFileName(fileName); VideoDatabase.GetMovieInfoById(idMovie, ref movieDetails); if (movieDetails.Title != string.Empty) { title = movieDetails.Title; } GUIResumeDialog.Result result = GUIResumeDialog.ShowResumeDialog(title, timeMovieStopped, GUIResumeDialog.MediaType.DVD); if (result == GUIResumeDialog.Result.Abort) { return(false); } if (result == GUIResumeDialog.Result.PlayFromBeginning) { timeMovieStopped = 0; } } } if (g_Player.Playing) { g_Player.Stop(); } g_Player.PlayDVD(drive + @"\VIDEO_TS\VIDEO_TS.IFO"); g_Player.ShowFullScreenWindow(); if (g_Player.Playing && timeMovieStopped > 0) { if (g_Player.IsDVD) { g_Player.Player.SetResumeState(resumeData); } else { Log.Debug("SelectDVDHandler.OnPlayDVD - skipping"); g_Player.SeekAbsolute(timeMovieStopped); } } return(true); } } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(3); //my videos Log.Error("SelectDVDHandler: OnPlayDVD() Plz Insert Disk (ShowSelectDriveDialog)"); dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(parentId); return(false); }
protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == _searchButton) { _selectedTitleIndex = 0; _selectedProgramIndex = 0; if (_rules.Count > 0) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.Attention)); dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.ContinueWithPrevResults)); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GetID); if (!dlgYesNo.IsConfirmed) { _rules.Clear(); if (_viewsList != null && _viewsList.Count > 0) { _viewsList.Clear(); } } } } VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); if (keyboard != null) { keyboard.Reset(); keyboard.IsSearchKeyboard = true; keyboard.Text = String.Empty; keyboard.DoModal(GetID); if (keyboard.IsConfirmed) { if (keyboard.Text == string.Empty) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoValidSearchText)); dlgOk.DoModal(GetID); } } else { switch (_currentSearchMethod) { case SearchInMethod.Title: _rules.Add(ScheduleRuleType.TitleContains, keyboard.Text); break; case SearchInMethod.Description: _rules.Add(ScheduleRuleType.DescriptionContains, keyboard.Text); break; case SearchInMethod.ProgramInfo: _rules.Add(ScheduleRuleType.ProgramInfoContains, keyboard.Text); break; case SearchInMethod.Actor: _rules.Add(ScheduleRuleType.WithActor, keyboard.Text); break; case SearchInMethod.DirectedBy: _rules.Add(ScheduleRuleType.DirectedBy, keyboard.Text); break; } ShowSearchResults(string.Empty); } } } } else if (control == _searchMethodButton) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(467); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnTitle)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDescription)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnProgramInfo)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnActor)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDirectedBy)); dlg.SelectedLabel = (int)_currentSearchMethod; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _currentSearchMethod = (SearchInMethod)(dlg.SelectedLabel); UpdateButtonStates(); } else if (control == _selectChannelsButton) { List <ChannelGroup> groups = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(this._channelType)); ChannelGroup _selectedGroup = new ChannelGroup(); if (groups.Count > 0) { if (groups.Count > 1) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGroup)); foreach (ChannelGroup group in groups) { dlg.Add(group.GroupName); } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _selectedGroup = groups[dlg.SelectedId - 1]; } else { _selectedGroup = groups[0]; } List <Channel> channels = new List <Channel>(); if (_channelArguments.Count > 0) { List <Channel> channels2 = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true)); foreach (Channel channel in channels2) { if (!_channelArguments.Contains(channel.ChannelId)) { channels.Add(channel); } } } else { channels = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true)); } if (channels.Count > 0) { GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg2 == null) { return; } dlg2.Reset(); dlg2.SetHeading(GetChannelArgumentsString(true)); foreach (Channel channel in channels) { dlg2.Add(channel.DisplayName); } // show dialog and wait for result dlg2.DoModal(GetID); if (dlg2.SelectedId == -1) { return; } _channelArguments.Add(channels[dlg2.SelectedId - 1].ChannelId); UpdateButtonStates(); } else { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreChannelsToAdd)); dlgOk.DoModal(GetID); } } } } else if (control == _selectCategoriesButton) { List <string> categories = new List <string>(); string[] _categories = new string[0]; _categories = GuideAgent.GetAllCategories(); foreach (string categorie in _categories) { if (!_categorieArguments.Contains(categorie)) { categories.Add(categorie); } } if (categories.Count > 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GetCategorieArgumentString(true)); foreach (string categorie in categories) { dlg.Add(categorie); } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _categorieArguments.Add(dlg.SelectedLabelText); UpdateButtonStates(); } else { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreCategoriesToAdd)); dlgOk.DoModal(GetID); } } } else if (control == _clearButton) { OnClearRules(true); ShowSearchResults(string.Empty); UpdateButtonStates(); } else if (control == _sortByButton) { if (_isInSubDirectory) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(495); //Sort Options dlg.AddLocalizedString(620); //channel dlg.AddLocalizedString(621); //date dlg.AddLocalizedString(268); //title/name // set the focus to currently used sort method dlg.SelectedLabel = (int)_currentSortMethod; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _currentSortMethod = (SortMethod)dlg.SelectedLabel; OnSort(); } } else if (control == _viewsList) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, control.GetID, 0, 0, null); OnMessage(msg); int iItem = (int)msg.Param1; if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { OnSelectItem(iItem); } if (actionType == Action.ActionType.ACTION_SHOW_INFO) { OnShowContextMenu(); } } }
private void ShowSearchResults(string selectedTitle) { GUIControl.ClearControl(GetID, _viewsList.GetID); if (_rules == null || _rules.Count == 0) { _viewsList.Clear(); _selectedTitle = string.Empty; _isInSubDirectory = false; return; } List <ScheduleRule> rules = new List <ScheduleRule>(); for (int i = 0; i < _rules.Count; i++) { rules.Add(_rules[i]); } if (selectedTitle != string.Empty) { rules.Add(ScheduleRuleType.TitleEquals, selectedTitle); } if (_categorieArguments.Count > 0) { rules.Add(ScheduleRuleType.CategoryEquals, _categorieArguments.ToArray()); } if (_channelArguments.Count > 0) { rules.Add(ScheduleRuleType.Channels, _channelArguments.ToArray()); } Schedule _schedule = SchedulerAgent.CreateNewSchedule(this._channelType, ScheduleType.Recording); _schedule.Rules = rules; UpcomingProgram[] _searchResults = SchedulerAgent.GetUpcomingPrograms(_schedule, true); if (_searchResults.Length < 1) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlg.SetLine(1, Utility.GetLocalizedText(TextId.NoProgrammesFound)); dlg.DoModal(GUIWindowManager.ActiveWindow); _isInSubDirectory = false; _selectedTitle = string.Empty; return; } _selectedTitle = selectedTitle; if (selectedTitle == string.Empty) { List <String> upcomingTitles = new List <String>(); foreach (UpcomingProgram program in _searchResults) { if (!upcomingTitles.Contains(program.Title)) { upcomingTitles.Add(program.Title); _viewsList.Add(CreateListItem(program, true)); } } _isInSubDirectory = false; } else { GUIListItem item = new GUIListItem(); item.Label = _parentDirectoryLabel; item.IsFolder = true; Utils.SetDefaultIcons(item); _viewsList.Add(item); foreach (UpcomingProgram program in _searchResults) { _viewsList.Add(CreateListItem(program, false)); } _isInSubDirectory = true; } string strObjects = string.Format("{0}", _viewsList.Count - (_isInSubDirectory ? 1 : 0)); GUIPropertyManager.SetProperty("#itemcount", strObjects); OnSort(); int selectedItemIndex; if (_isInSubDirectory) { selectedItemIndex = _selectedProgramIndex; } else { selectedItemIndex = _selectedTitleIndex; } while (selectedItemIndex >= _viewsList.Count && selectedItemIndex > 0) { selectedItemIndex--; } GUIControl.SelectItemControl(GetID, _viewsList.GetID, selectedItemIndex); UpdateProperties(); }
/// <summary> /// Network share enumeration from netShare parameter resource /// </summary> /// <param name="netShare">Network resource</param> private void GetNetworkFolders(string netShare) { ArrayList netComputers = NetShareCollection.GetComputersOnNetwork(); if (netComputers == null || netComputers.Count == 0) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(GUILocalizeStrings.Get(1020)); dlgOk.SetLine(1, GUILocalizeStrings.Get(300056)); //No network resources found. dlgOk.SetLine(2, GUILocalizeStrings.Get(300057)); // Try manual search. dlgOk.DoModal(GetID); GetStringFromKeyboard(ref netShare); } else { GUIDialogSelect dlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(924); // Menu dlg.EnableButton(true); dlg.SetButtonLabel(413); // manual // Add list to dlg menu foreach (string netWrkst in netComputers) { dlg.Add(netWrkst); } // Show dialog menu dlg.DoModal(GetID); if (dlg.IsButtonPressed) { GetStringFromKeyboard(ref netShare); } else if (dlg.SelectedLabel == -1) { return; } else { netShare = dlg.SelectedLabelText; } } if (string.IsNullOrEmpty(netShare) || !netShare.StartsWith(@"\\") || (netShare.StartsWith(@"\\") && netShare.Length <= 2)) { netShare = GUILocalizeStrings.Get(145); return; } // Get selected network resource shared folders _userNetFolder = netShare; NetShareCollection netShares = NetShareCollection.GetShares(netShare); SetFolderHistory(); _folders.Clear(); GUIListItem goBack = new GUIListItem(); goBack.Label = ".."; goBack.Label2 = ".."; _folders.Add(goBack); foreach (NetShare share in netShares) { if (share.IsFileSystem && share.ShareType == ShareType.Disk) { GUIListItem netFolder = new GUIListItem(); string nFolder = Path.GetFileName(share.Root.FullName); netFolder.Label = nFolder.ToUpperInvariant(); netFolder.Label2 = share.Root.FullName; _folders.Add(netFolder); } } }
public static void ShowResultsDialog(bool abortedByUser, bool completedSuccessfully, int coversGrabbed, int parentWindowID) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlg != null) { string line1Text = ""; string line2Text = ""; // The user cancelled the grab if (abortedByUser) { line1Text = GUILocalizeStrings.Get(4507); if (line1Text.Length == 0) { line1Text = "Cover art grabber aborted by user"; } } else { if (completedSuccessfully) { if (coversGrabbed > 0) { line1Text = GUILocalizeStrings.Get(4508); if (line1Text.Length == 0) { line1Text = "Cover art grab completed successfuly"; } } // The grab succeeded but all of the covers were up to date else { line1Text = GUILocalizeStrings.Get(4512); if (line1Text.Length == 0) { line1Text = "All covers up to date"; } } } else { line1Text = GUILocalizeStrings.Get(4509); if (line1Text.Length == 0) { line1Text = "Cover art grab completed with errors"; } } string fmtString = GUILocalizeStrings.Get(4510); if (fmtString.Length == 0 || fmtString.IndexOf("{0}") == -1) { fmtString = "{0} cover art images updated"; } line2Text = string.Format(fmtString, coversGrabbed); } string caption = GUILocalizeStrings.Get(4511); if (caption.Length == 0) { caption = "Cover Art Grabber Done"; } dlg.SetHeading(caption); dlg.SetLine(1, line1Text); dlg.SetLine(2, line2Text); dlg.DoModal(parentWindowID); } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); // Default folder (select/deselect on click) - settings saved if (control == videosShareListcontrol) { OnSetDefaultFolder(); } // Add new folder if (control == btnAdd) { // reset menu position _selectedOption = -1; // reset folder browser ClearFolders(); // Clear folder info ClearFolderInfoData(); _userNetFolder = GUILocalizeStrings.Get(145); // Network // Show menu OnAddEditFolder(); // Define new folder GUIListItem item = new GUIListItem(); // Watch for last parameter (my version with selective thumbs will use that) ShareData shareData = new ShareData("", "", "", true); item.AlbumInfoTag = shareData; _shareFolderListItem = item; // Check new data CheckCurrentShareData(); if (_error) { _error = false; GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(257); dlgOk.SetLine(1, GUILocalizeStrings.Get(300053)); // Error in folder data dlgOk.SetLine(2, GUILocalizeStrings.Get(300054)); // Name or path couldn't be empty dlgOk.DoModal(GUIWindowManager.ActiveWindow); return; } // Prepare folder info data FolderInfo(_shareFolderListItem).DefaultLayout = SettingsSharesHelper.ProperLayoutFromDefault(_folderDefaultLayoutIndex); FolderInfo(_shareFolderListItem).Name = _folderName; FolderInfo(_shareFolderListItem).Folder = _folderPath; FolderInfo(_shareFolderListItem).CreateThumbs = _folderCreateThumbs; FolderInfo(_shareFolderListItem).EachFolderIsMovie = _folderEachFolderIsMovie; FolderInfo(_shareFolderListItem).PinCode = _folderPin; // Almost forgot this, needed for proper sort :) _shareFolderListItem.Label = _folderName; _shareFolderListItem.OnItemSelected += OnItemSelected; // Add new folder in list videosShareListcontrol.Add(_shareFolderListItem); GUIListItem newItem = _shareFolderListItem; Sort(); int index = videosShareListcontrol.ListItems.IndexOf(newItem); videosShareListcontrol.SelectedListItemIndex = index; } // Edit folder if (control == btnEdit) { string name = _folderName; string path = _folderPath; // reset menu position _selectedOption = -1; OnAddEditFolder(); // Check new data CheckCurrentShareData(); if (_error) { _error = false; GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(257); dlgOk.SetLine(1, GUILocalizeStrings.Get(300053)); // Error in folder data dlgOk.SetLine(2, GUILocalizeStrings.Get(300054)); // Name or path couldn't be empty dlgOk.DoModal(GUIWindowManager.ActiveWindow); _folderName = name; _folderPath = path; return; } // Update changes FolderInfo(_shareFolderListItem).Name = _folderName; _shareFolderListItem.Label = _folderName; FolderInfo(_shareFolderListItem).Folder = _folderPath; FolderInfo(_shareFolderListItem).PinCode = _folderPin; FolderInfo(_shareFolderListItem).CreateThumbs = _folderCreateThumbs; FolderInfo(_shareFolderListItem).EachFolderIsMovie = _folderEachFolderIsMovie; FolderInfo(_shareFolderListItem).DefaultLayout = SettingsSharesHelper.ProperLayoutFromDefault(_folderDefaultLayoutIndex); // Add changes to a listitem videosShareListcontrol.SelectedListItem.AlbumInfoTag = _shareFolderListItem.AlbumInfoTag; videosShareListcontrol.SelectedListItem.Label = _folderName; // Sort list GUIListItem newItem = _shareFolderListItem; Sort(); int index = videosShareListcontrol.ListItems.IndexOf(newItem); videosShareListcontrol.SelectedListItemIndex = index; } // Remove folder - settings saved if (control == btnRemove) { OnRemoveFolder(); } // Reset folders - settings saved if (control == btnReset) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(927)); // Warning dlgYesNo.SetLine(1, GUILocalizeStrings.Get(300055)); // this will delete folders dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { OnResetFolders(); } } } }
/// <summary> /// Loads a playlist and starts the playback /// </summary> /// <param name="playListFileName">Filename of the playlist</param> private void LoadPlayList(string playListFileName) { IPlayListIO loader = PlayListFactory.CreateIO(playListFileName); PlayList playlist = new PlayList(); if (!loader.Load(playlist, playListFileName)) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(6); dlgOk.SetLine(1, 477); dlgOk.SetLine(2, String.Empty); dlgOk.DoModal(GetID); } return; } if (playlist.Count == 1) { string movieFileName = playlist[0].FileName + ".mplayer"; if (movieFileName.StartsWith("rtsp:")) { movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5); } if (g_Player.Play(movieFileName)) { if (g_Player.Player != null && g_Player.IsVideo) { GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO); } } return; } PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Clear(); for (int i = 0; i < playlist.Count; ++i) { string movieFileName = playlist[i].FileName + ".mplayer"; if (movieFileName.StartsWith("rtsp:")) { movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5); } playlist[i].FileName = movieFileName; PlayListItem playListItem = playlist[i]; playListItem.Type = PlayListItem.PlayListItemType.Unknown; PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playListItem); } if (PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Count > 0) { PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO); PlaylistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; PlaylistPlayer.Reset(); PlaylistPlayer.Play(0); if (g_Player.Player != null && g_Player.IsVideo) { GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO); } } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == buttonReset) { labelCurrent.Label = DefaultSetting; SetCheckMarksBasedOnString(DefaultSetting); } else if (control == buttonAdd) { VirtualKeyboard vk = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); vk.Reset(); vk.DoModal(GetID); string newStep = vk.Text; if (string.IsNullOrEmpty(newStep)) { return; } string error = verifySkipStep(newStep); if (error != null) { GUIDialogOK errDialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); errDialog.SetHeading(257); errDialog.SetLine(1, error); errDialog.DoModal(GetID); } else { AddStep(Convert.ToInt16(newStep)); // Already verifed, so no numberformatexception can occur } } else if (control == buttonRemove) { GUIDialogSelect2 dlgSel = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT2); dlgSel.Reset(); dlgSel.SetHeading(200040); // Remove skip step foreach (string token in labelCurrent.Label.Split(new char[] { ',', ';', ' ' })) { if (token == string.Empty) { continue; } dlgSel.Add(token); } dlgSel.DoModal(GetID); if (dlgSel.SelectedLabel != -1) { try { RemoveStep(Convert.ToInt16(dlgSel.SelectedLabelText)); } catch (Exception) { // Should never happen } } } else if (control is GUICheckMarkControl) { int stepSize = 5; if (control == checkMarkButtonStep1) { stepSize = 5; } else if (control == checkMarkButtonStep2) { stepSize = 15; } else if (control == checkMarkButtonStep3) { stepSize = 30; } else if (control == checkMarkButtonStep4) { stepSize = 45; } else if (control == checkMarkButtonStep5) { stepSize = 60; } else if (control == checkMarkButtonStep6) { stepSize = 180; } else if (control == checkMarkButtonStep7) { stepSize = 300; } else if (control == checkMarkButtonStep8) { stepSize = 420; } else if (control == checkMarkButtonStep9) { stepSize = 600; } else if (control == checkMarkButtonStep10) { stepSize = 900; } else if (control == checkMarkButtonStep11) { stepSize = 1800; } else if (control == checkMarkButtonStep12) { stepSize = 2700; } else if (control == checkMarkButtonStep13) { stepSize = 3600; } else if (control == checkMarkButtonStep14) { stepSize = 5400; } else if (control == checkMarkButtonStep15) { stepSize = 7200; } else if (control == checkMarkButtonStep16) { stepSize = 10800; } if (!((GUICheckMarkControl)control).Selected) { RemoveStep(stepSize); } else { AddStep(stepSize); } } if (control == btnTimeoutValue) { int number; string getNumber = _timeOutValue.ToString(); GetStringFromKeyboard(ref getNumber, -1); if (Int32.TryParse(getNumber, out number)) { _timeOutValue = number; } SetProperties(); } if (control == btnSkipValue) { int number; string getNumber = _skipValue.ToString(); GetStringFromKeyboard(ref getNumber, -1); if (Int32.TryParse(getNumber, out number)) { _skipValue = number; } SetProperties(); } if (control == btnRelative) { if (btnRelative.Selected) { btnConstant.Selected = false; } else { btnConstant.Selected = true; } } if (control == btnConstant) { if (btnConstant.Selected) { btnRelative.Selected = false; } else { btnRelative.Selected = true; } } base.OnClicked(controlId, control, actionType); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { // we don't want the user to start another search while one is already active if (_workerCompleted == false) { return; } // Here we want to open the OSD Keyboard to enter the searchstring if (control == buttonSearch) { // If the search Button was clicked we need to bring up the search keyboard. VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); if (null == keyboard) { return; } string searchterm = string.Empty; //keyboard.IsSearchKeyboard = true; keyboard.Reset(); keyboard.Text = ""; keyboard.DoModal(GetID); // show it... Log.Info("Wikipedia: OSD keyboard loaded!"); // If input is finished, the string is saved to the searchterm var. if (keyboard.IsConfirmed) { searchterm = keyboard.Text; // If there was a string entered try getting the article. if (searchterm != "") { Log.Info("Wikipedia: Searchterm gotten from OSD keyboard: {0}", searchterm); GetAndDisplayArticle(searchterm); } // Else display an error dialog. else { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading(GUILocalizeStrings.Get(257)); // Error dlg.SetLine(1, GUILocalizeStrings.Get(2500)); // No searchterm entered! dlg.SetLine(2, string.Empty); dlg.SetLine(3, GUILocalizeStrings.Get(2501)); // Please enter a valid searchterm! dlg.DoModal(GUIWindowManager.ActiveWindow); } } } // This is the control to select the local Wikipedia site. if (control == buttonLocal) { // Create a new selection dialog. GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(GUILocalizeStrings.Get(2502)); //Select your local Wikipedia: // Add all the local sites we want to be displayed starting with int 0. Settings langreader = new Settings(Config.GetFile(Config.Dir.Config, "wikipedia.xml")); String allsites = langreader.GetValueAsString("Allsites", "sitenames", ""); Log.Info("Wikipedia: available sites: " + allsites); String[] siteArray = allsites.Split(','); for (int i = 0; i < siteArray.Length; i++) { int stringno = langreader.GetValueAsInt(siteArray[i], "string", 2006); pDlgOK.Add(GUILocalizeStrings.Get(stringno)); //English, German, French ... } pDlgOK.DoModal(GetID); if (pDlgOK.SelectedLabel >= 0) { SelectLocalWikipedia(pDlgOK.SelectedLabel, siteArray); } } } // The Button holding the Links to other articles if (control == buttonLinks) { if (linkArray.Count > 0) { // Create a new selection dialog. GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(GUILocalizeStrings.Get(2505)); //Links to other articles: // Add all the links from the linkarray. foreach (string link in linkArray) { pDlgOK.Add(link); } pDlgOK.DoModal(GetID); if (pDlgOK.SelectedLabel >= 0) { Log.Info("Wikipedia: new search from the links array: {0}", pDlgOK.SelectedLabelText); GetAndDisplayArticle(pDlgOK.SelectedLabelText); } } } else { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading(GUILocalizeStrings.Get(257)); // Error dlg.SetLine(1, GUILocalizeStrings.Get(2506)); // No Links from this article. dlg.DoModal(GUIWindowManager.ActiveWindow); } } // The Button containing a list of all images from the article if (control == buttonImages) { if (imagedescArray.Count > 0) { // Create a new selection dialog. GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(GUILocalizeStrings.Get(2507)); //Images from this article // Add all the images from the imagearray. foreach (string image in imagedescArray) { pDlgOK.Add(image); } pDlgOK.DoModal(GetID); if (pDlgOK.SelectedLabel >= 0) { Log.Info("Wikipedia: new search from the image array: {0}", imagedescArray[pDlgOK.SelectedId - 1]); GetAndDisplayImage(imagenameArray[pDlgOK.SelectedId - 1].ToString(), imagedescArray[pDlgOK.SelectedId - 1].ToString()); } } } else { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading(GUILocalizeStrings.Get(257)); // Error dlg.SetLine(1, GUILocalizeStrings.Get(2508)); // No Images referenced in this article. dlg.DoModal(GUIWindowManager.ActiveWindow); } } // Back to the text button to switch from image view if (control == buttonBack) { if (!txtArticle.IsVisible) { GUIControl.ShowControl(GetID, txtArticle.GetID); } if (imageControl.IsVisible) { GUIControl.HideControl(GetID, imageControl.GetID); } if (!searchtermLabel.IsVisible) { GUIControl.ShowControl(GetID, searchtermLabel.GetID); } if (imagedescLabel.IsVisible) { GUIControl.HideControl(GetID, imagedescLabel.GetID); } if (buttonBack.IsVisible) { GUIControl.HideControl(GetID, buttonBack.GetID); GUIControl.FocusControl(GetID, buttonSearch.GetID); } } base.OnClicked(controlId, control, actionType); }
// Changed - covers and the same movie name protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == btnRefresh) { // Check Internet connection if (!Win32API.IsConnectedToInternet()) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(257); dlgOk.SetLine(1, GUILocalizeStrings.Get(703)); dlgOk.DoModal(GUIWindowManager.ActiveWindow); return; } string title = currentMovie.Title; int id = currentMovie.ID; string file = currentMovie.Path + "\\" + currentMovie.File; // Delete covers FanArt.DeleteCovers(title, id); //Delete fanarts FanArt.DeleteFanarts(file, title); if (IMDBFetcher.RefreshIMDB(this, ref currentMovie, false, false, true)) { if ((imageSearchThread != null) && (imageSearchThread.IsAlive)) { imageSearchThread.Abort(); imageSearchThread = null; } imdbCoverArtUrl = currentMovie.ThumbURL; coverArtUrls = new string[1]; coverArtUrls[0] = imdbCoverArtUrl; ResetSpinControl(); Refresh(false); Update(); // Start images search thread SearchImages(); } return; } if (control == spinImages) { int item = spinImages.Value - 1; if (item < 0 || item >= coverArtUrls.Length) { item = 0; } if (currentMovie.ThumbURL == coverArtUrls[item]) { return; } currentMovie.ThumbURL = coverArtUrls[item]; // Title suffix for problem with covers and movie with the same name string titleExt = currentMovie.Title + "{" + currentMovie.ID + "}"; string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt); string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); Util.Utils.FileDelete(coverArtImage); // // 07.11.2010 Deda: Cache entry Flag change for cover thumb file // Util.Utils.DoInsertNonExistingFileIntoCache(coverArtImage); // Util.Utils.FileDelete(largeCoverArtImage); Refresh(false); Update(); int idMovie = currentMovie.ID; if (idMovie >= 0) { VideoDatabase.SetThumbURL(idMovie, currentMovie.ThumbURL); } return; } if (control == btnCast) { viewmode = ViewMode.Cast; Update(); } if (control == btnPlot) { viewmode = ViewMode.Plot; Update(); } if (control == btnReview) { viewmode = ViewMode.Review; Update(); } if (control == btnWatched) { if (currentMovie.Watched > 0) { GUIPropertyManager.SetProperty("#iswatched", "no"); currentMovie.Watched = 0; VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, false); ArrayList files = new ArrayList(); VideoDatabase.GetFiles(currentMovie.ID, ref files); foreach (string file in files) { int fileId = VideoDatabase.GetFileId(file); VideoDatabase.DeleteMovieStopTime(fileId); } } else { GUIPropertyManager.SetProperty("#iswatched", "yes"); currentMovie.Watched = 1; VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, true); } VideoDatabase.SetWatched(currentMovie); } if (control == spinDisc) { string selectedItem = spinDisc.GetLabel(); int idMovie = currentMovie.ID; if (idMovie > 0) { if (selectedItem != "HD" && selectedItem != "share") { VideoDatabase.SetDVDLabel(idMovie, selectedItem); } else { VideoDatabase.SetDVDLabel(idMovie, "HD"); } } } if (control == btnPlay) { int id = currentMovie.ID; ArrayList files = new ArrayList(); VideoDatabase.GetFiles(id, ref files); if (files.Count > 1) { GUIVideoFiles._stackedMovieFiles = files; GUIVideoFiles._isStacked = true; GUIVideoFiles.MovieDuration(files); } GUIVideoFiles.PlayMovie(id, false); return; } }
private static bool WakeupSystem(byte[] hwAddress, string wakeupTarget, int timeout) { int waited = 0; WakeOnLanManager wakeOnLanManager = new WakeOnLanManager(); Log.Debug("WOLMgr: Ping {0}", wakeupTarget); if (wakeOnLanManager.Ping(wakeupTarget, 200)) { Log.Debug("WOLMgr: {0} already started", wakeupTarget); return(true); } GUIDialogProgress progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS progressDialog.Reset(); progressDialog.SetHeading(GUILocalizeStrings.Get(1990)); progressDialog.ShowProgressBar(true); progressDialog.SetLine(1, GUILocalizeStrings.Get(1991)); progressDialog.StartModal(GUIWindowManager.ActiveWindow); // First, try to send WOL Packet if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast)) { Log.Debug("WOLMgr: FAILED to send the first wake-on-lan packet!"); } while (waited < timeout) { int percentange = (waited * 100) / timeout; progressDialog.SetPercentage(percentange); progressDialog.Progress(); Log.Debug("WOLMgr: Ping {0}", wakeupTarget); if (wakeOnLanManager.Ping(wakeupTarget, 200)) { progressDialog.SetPercentage(100); progressDialog.Progress(); progressDialog.Close(); int waittime; using (Settings xmlreader = new MPSettings()) { waittime = xmlreader.GetValueAsInt("WOL", "WaitTimeAfterWOL", 0); } if (waittime > 0) { GUIDialogProgress progressDialog2 = (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS progressDialog2.Reset(); progressDialog2.SetHeading(string.Empty); progressDialog2.ShowProgressBar(true); progressDialog2.SetLine(1, GUILocalizeStrings.Get(1994)); progressDialog2.StartModal(GUIWindowManager.ActiveWindow); waited = waittime; for (int i = waited; waited != 0; waited--) { percentange = (waited * 100) / waittime; progressDialog2.SetPercentage(percentange); progressDialog2.Progress(); System.Threading.Thread.Sleep(1000); } progressDialog2.SetPercentage(0); progressDialog2.Progress(); progressDialog2.Close(); } return(true); } // Send WOL Packet if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast)) { Log.Debug("WOLMgr: Sending the wake-on-lan packet failed (local network maybe not ready)! {0}s", waited); } Log.Debug("WOLMgr: System {0} still not reachable, waiting... {1}s", wakeupTarget, waited); System.Threading.Thread.Sleep(1000); waited++; } // Timeout was reached and WOL packet can't be send (we stop here) Log.Debug("WOLMgr: FAILED to send wake-on-lan packet after the timeout {0}, try increase the value!", timeout); progressDialog.SetPercentage(100); progressDialog.Progress(); progressDialog.Close(); GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(GUILocalizeStrings.Get(1992)); // Not available dlgOk.SetLine(1, GUILocalizeStrings.Get(1993)); dlgOk.DoModal(GUIWindowManager.ActiveWindow); return(false); }
private void AddLocation() { string city = ""; if (!GetKeyboard(ref city) || String.IsNullOrEmpty(city)) { return; } try { // Perform actual search WeatherChannel weather = new WeatherChannel(); ArrayList cities = weather.SearchCity(city); if (cities.Count <= 0) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.SetHeading(8); dlg.SetLine(1, 412); dlg.SetLine(2, ""); dlg.DoModal(GetID); return; } GUIDialogMenu dialogCitySelect = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dialogCitySelect != null) { dialogCitySelect.Reset(); dialogCitySelect.ShowQuickNumbers = false; dialogCitySelect.SetHeading(396); // Select Location foreach (WeatherChannel.City _city in cities) { dialogCitySelect.Add(_city.Name + " (" + _city.Id + ")"); } dialogCitySelect.DoModal(GetID); if (dialogCitySelect.SelectedLabel >= 0) { WeatherChannel.City newcity = (WeatherChannel.City)cities[dialogCitySelect.SelectedLabel]; LocationInfo loc = new LocationInfo(); loc.City = newcity.Name; loc.CityCode = newcity.Id; loc.UrlSattelite = ""; loc.UrlTemperature = ""; loc.UrlUvIndex = ""; loc.UrlWinds = ""; loc.UrlHumidity = ""; loc.UrlPrecip = ""; availableLocations.Add(loc); SaveLocations(); SetDefaultLocation(); // Reset the default location as necessary InitDefaultLocation(); // Refresh default location button as necessary } } } catch (Exception ex) { Log.Error("MyWeather settings error: {0}", ex.ToString()); } }
public string ShowSelectDriveDialog(int parentId, bool DVDonly) { Log.Info("SelectDVDHandler: ShowSelectDVDDialog()"); //check if dvd is inserted List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem item = (GUIListItem)rootDrives[i]; if (Util.Utils.getDriveType(item.Path) == 5) //cd or dvd drive { string driverLetter = item.Path.Substring(0, 1); string fileName = DVDonly ? String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", driverLetter) : String.Format(@"{0}:\", driverLetter); if (DVDonly && !File.Exists(fileName)) { rootDrives.RemoveAt(i); } else if (!DVDonly && !Directory.Exists(fileName)) { rootDrives.RemoveAt(i); } } else { rootDrives.RemoveAt(i); } } if (rootDrives.Count > 0) { try { if (rootDrives.Count == 1) { GUIListItem ritem = (GUIListItem)rootDrives[0]; return(ritem.Path); // Only one DVD available, play it! } SetIMDBThumbs(rootDrives, false); // Display a dialog with all drives to select from GUIDialogSelect2 dlgSel = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_SELECT2); if (null == dlgSel) { Log.Info("SelectDVDHandler: Could not open dialog, defaulting to first drive found"); GUIListItem ritem = (GUIListItem)rootDrives[0]; return(ritem.Path); } dlgSel.Reset(); dlgSel.SetHeading(DVDonly ? 196 : 2201); // Choose movie | select source for (int i = 0; i < rootDrives.Count; i++) { GUIListItem dlgItem = new GUIListItem(); dlgItem = (GUIListItem)rootDrives[i]; Log.Debug("SelectDVDHandler: adding list item of possible playback location - {0}", dlgItem.Path); dlgSel.Add(dlgItem); } dlgSel.DoModal(parentId); if (dlgSel.SelectedLabel != -1) { return(dlgSel.SelectedLabelText.Substring(1, 2)); } else { return(null); } } catch (Exception ex) { Log.Warn("SelectDVDHandler: could not determine dvd path - {0},{1}", ex.Message, ex.StackTrace); return(null); } } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(1020); //information Log.Error("SelectDVDHandler: ShowSelectDriveDialog - Plz Insert Disk"); dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(parentId); Log.Info("SelectDVDHandler: did not find a movie"); return(null); }
public bool ResumeOrPlay(DBEpisode episode) { try { MPTVSeriesLog.Write("Attempting to play: ", episode[DBEpisode.cFilename].ToString(), MPTVSeriesLog.LogLevel.Debug); // don't have this file ! if (episode[DBEpisode.cFilename].ToString().Length == 0) { return(false); } // check that we are not playing an episode out of episode if unwatched // ignore specials as they can be pretty out of wack! #region PlayBack Order // check sort order so our check is accurate var series = Helper.getCorrespondingSeries(episode[DBOnlineEpisode.cSeriesID]); bool dvdSortOrder = series[DBOnlineSeries.cEpisodeSortOrder] == "DVD"; string seasonField = dvdSortOrder ? DBOnlineEpisode.cCombinedSeason : DBOnlineEpisode.cSeasonIndex; string episodeField = dvdSortOrder ? DBOnlineEpisode.cCombinedEpisodeNumber : DBOnlineEpisode.cEpisodeIndex; if (DBOption.GetOptions(DBOption.cCheckPlayOutOfOrder) && !episode[DBOnlineEpisode.cWatched] && episode[seasonField] > 0 && episode[episodeField] > 1) { // first get the next unwatched episode from previously played // we are only interested in current season (could be multi-user watching multiple seasons) // API for GetNextUnwatched is not desirable as that works from Date Watched, we only care about watched here var conditions = new SQLCondition(); conditions.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, episode[DBOnlineSeries.cSeriesID], SQLConditionType.Equal); conditions.Add(new DBOnlineEpisode(), seasonField, episode[seasonField], SQLConditionType.Equal); conditions.Add(new DBOnlineEpisode(), episodeField, episode[episodeField], SQLConditionType.LessThan); conditions.Add(new DBOnlineEpisode(), episodeField, 0, SQLConditionType.GreaterThan); var episodes = DBEpisode.Get(conditions, false); if (episodes != null && episodes.Count > 0) { // set logical playback order based on sort order episodes.Sort(); // if the previous found episode is not watched then we are playing out of order // if we have a gap in episode collection then assume it has not been watched (this check is needed when user does not download all episode info) if (!episodes.Last()[DBOnlineEpisode.cWatched] || (episode[episodeField] - episodes.Last()[episodeField]) > 1) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); dlgYesNo.SetHeading(Translation.Warning); dlgYesNo.SetLine(1, Translation.PlaybackOutOfOrderLine1); dlgYesNo.SetLine(2, string.Format("{0} - {1}x{2}", series.ToString(), episode[seasonField], episode[episodeField] - 1)); dlgYesNo.SetLine(3, Translation.PlaybackOutOfOrderLine2); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) { return(false); } } } } #endregion m_previousEpisode = m_currentEpisode; m_currentEpisode = episode; int timeMovieStopped = m_currentEpisode[DBEpisode.cStopTime]; // Check if file is an Image e.g. ISO string filename = m_currentEpisode[DBEpisode.cFilename]; m_bIsImageFile = Helper.IsImageFile(filename); #region Invoke Before Playback // see if we have an invokeOption set up string invoke = (string)DBOption.GetOptions(DBOption.cInvokeExtBeforePlayback); if (!string.IsNullOrEmpty(invoke)) { string invokeArgs = (string)DBOption.GetOptions(DBOption.cInvokeExtBeforePlaybackArgs); try { // replace any placeholders in the arguments for the script if any have been supplied. if (!string.IsNullOrEmpty(invokeArgs)) { invokeArgs = FieldGetter.resolveDynString(invokeArgs, m_currentEpisode, true); } invoke = FieldGetter.resolveDynString(invoke, m_currentEpisode, true); // use ProcessStartInfo instead of Process.Start(string) as latter produces a "cannot find file" // error if you pass in command line arguments. // also allows us to run the script hidden, preventing, for example, a command prompt popping up. ProcessStartInfo psi = new ProcessStartInfo(invoke, invokeArgs); psi.WindowStyle = ProcessWindowStyle.Hidden; Process proc = System.Diagnostics.Process.Start(psi); MPTVSeriesLog.Write(string.Format("Sucessfully Invoked BeforeFilePlay Command: '{0}' '{1}'", invoke, invokeArgs)); // if not present in database this evaluates to false. If present and not a valid bool then // it evaluates to true bool waitForExit = (bool)DBOption.GetOptions(DBOption.cInvokeExtBeforePlaybackWaitForExit); // if true this thread will wait for the external user script to complete before continuing. if (waitForExit) { proc.WaitForExit(); } } catch (Exception e) { MPTVSeriesLog.Write(string.Format("Unable to Invoke BeforeFilePlay Command: '{0}' '{1}'", invoke, invokeArgs)); MPTVSeriesLog.Write(e.Message); } } #endregion #region Removable Media Handling if (!File.Exists(m_currentEpisode[DBEpisode.cFilename])) { string episodeVolumeLabel = m_currentEpisode[DBEpisode.cVolumeLabel].ToString(); if (string.IsNullOrEmpty(episodeVolumeLabel)) { episodeVolumeLabel = LocalParse.getImportPath(m_currentEpisode[DBEpisode.cFilename]); } // ask the user to input cd/dvd, usb disk or confirm network drive is connected GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null == dlgOK) { return(false); } dlgOK.SetHeading(Translation.insertDisk); dlgOK.SetLine(1, Translation.InsertDiskMessage1); dlgOK.SetLine(2, Translation.InsertDiskMessage2); dlgOK.SetLine(3, Translation.InsertDiskMessage3); dlgOK.SetLine(4, string.Format(Translation.InsertDiskMessage4, episodeVolumeLabel)); dlgOK.DoModal(GUIWindowManager.ActiveWindow); if (!File.Exists(m_currentEpisode[DBEpisode.cFilename])) { return(false); // still not found, return to list } } #endregion #region Ask user to Resume // skip this if we are using an External Player bool bExternalPlayer = m_bIsImageFile ? m_bIsExternalDVDPlayer : m_bIsExternalPlayer; if (timeMovieStopped > 0 && !bExternalPlayer) { MPTVSeriesLog.Write("Asking user to resume episode from: " + Utils.SecondsToHMSString(timeMovieStopped)); GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(Translation.ResumeEpisode); dlgYesNo.SetLine(1, m_currentEpisode.onlineEpisode.CompleteTitle); dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + Utils.SecondsToHMSString(timeMovieStopped)); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); // reset resume data in DB if (!dlgYesNo.IsConfirmed) { timeMovieStopped = 0; m_currentEpisode[DBEpisode.cStopTime] = timeMovieStopped; m_currentEpisode.Commit(); MPTVSeriesLog.Write("User selected to start episode from beginning", MPTVSeriesLog.LogLevel.Debug); } else { MPTVSeriesLog.Write("User selected to resume episode", MPTVSeriesLog.LogLevel.Debug); // dont scrobble first of double episode if resuming past halfway double duration = m_currentEpisode[DBEpisode.cLocalPlaytime]; } } } #endregion Play(timeMovieStopped); return(true); } catch (Exception e) { MPTVSeriesLog.Write("TVSeriesPlugin.VideoHandler.ResumeOrPlay()\r\n" + e.ToString()); return(false); } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnChange) { if (GetKeyboard(ref _hostName)) { RemoteControl.Clear(); RemoteControl.HostName = _hostName; if (lblHostName != null) { lblHostName.Label = _hostName; } GUIPropertyManager.SetProperty("#TV.setup.hostname", _hostName); CheckTvServiceStatus(); List <string> portErrors = new List <string>(); bool tvServerOk = CheckTvServerConnection(portErrors); bool databaseOk = CheckDatabaseConnection(portErrors); bool streamingOk = CheckStreamingConnection(tvServerOk, databaseOk, portErrors); //Show the check results dialog to the user GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (tvServerOk && databaseOk && streamingOk) { //TVHome.OnPageLoadDone = false; RemoteControl.UseIncreasedTimeoutForInitialConnection = true; TVHome.Navigator.ReLoad(); Settings xmlreader = new MPSettings(); TVHome.Navigator.LoadSettings(xmlreader); if (pDlgOK != null) { pDlgOK.SetHeading(GUILocalizeStrings.Get(605)); pDlgOK.SetLine(1, GUILocalizeStrings.Get(200064)); // Connected to TvServer pDlgOK.SetLine(2, ""); pDlgOK.SetLine(3, ""); pDlgOK.DoModal(GUIWindowManager.ActiveWindow); } //goto TV home, even directly fullscreen if configured this way. GUIWindowManager.ActivateWindow((int)Window.WINDOW_TV, true); return; } RemoteControl.Clear(); pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (pDlgOK != null) { if (portErrors.Count > 0) { pDlgOK.SetHeading(GUILocalizeStrings.Get(200065)); // Some ports seem to be blocked for (int i = 0; i < 4; i++) { if (i < portErrors.Count) { pDlgOK.SetLine(i + 1, portErrors[i]); } else { pDlgOK.SetLine(i + 1, ""); } } pDlgOK.DoModal(GUIWindowManager.ActiveWindow); } pDlgOK.SetHeading(GUILocalizeStrings.Get(605)); if (tvServerOk) { pDlgOK.SetLine(1, GUILocalizeStrings.Get(200064)); // Connected to TvServer } else { pDlgOK.SetLine(1, GUILocalizeStrings.Get(200066)); // Unable to connect to TvServer } if (databaseOk) { pDlgOK.SetLine(2, GUILocalizeStrings.Get(200067)); // Connected to database } else { pDlgOK.SetLine(2, GUILocalizeStrings.Get(200068)); // Unable to connect to database } if (portErrors.Count == 0) { pDlgOK.SetLine(3, GUILocalizeStrings.Get(200069)); // All ip ports seem to be fine } else { pDlgOK.SetLine(3, GUILocalizeStrings.Get(200070)); // Please check firewall } pDlgOK.DoModal(GUIWindowManager.ActiveWindow); return; } } } else if (control == btnBack) { SwitchToHomeView(); } base.OnClicked(controlId, control, actionType); }
/// <summary> /// Tries to start the playback of an disc /// </summary> /// <returns>true, if successful</returns> private void OnPlayDisc() { String url = ""; string[] drives = Environment.GetLogicalDrives(); bool discFound = false; foreach (string driveElement in drives) { if (Utils.getDriveType(driveElement) == 5) { string driveLetter = driveElement.Substring(0, 1); if (File.Exists(String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", driveLetter))) { if (_useDvdnav) { url = "dvdnav://" + driveLetter + ":.mplayer"; } else { url = "dvd://" + driveLetter + ":.mplayer"; } discFound = true; break; } if (File.Exists(String.Format(@"{0}:\MPEGAV\AVSEQ01.DAT", driveLetter))) { url = "vcd://" + String.Format(@"{0}:\MPEGAV\AVSEQ01.DAT", driveLetter) + ".mplayer"; discFound = true; break; } if (File.Exists(String.Format(@"{0}:\MPEG2\AVSEQ01.MPG", driveLetter))) { url = "svcd://" + String.Format(@"{0}:\MPEG2\AVSEQ01.MPG", driveLetter) + ".mplayer"; discFound = true; break; } if (File.Exists(String.Format(@"{0}:\MPEG2\AVSEQ01.MPEG", driveLetter))) { url = "svcd://" + String.Format(@"{0}:\MPEG2\AVSEQ01.MPEG", driveLetter) + ".mplayer"; discFound = true; break; } } } if (discFound) { if (g_Player.Playing) { g_Player.Stop(); } g_Player.Play(url); GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO); return; } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(3); //my videos dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(GetID); return; }