private void CommandBinding_PlayVideo(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(AnimeEpisodeVM)) { VideoLocalVM vid = this.DataContext as VideoLocalVM; bool force = true; if (vid.ResumePosition > 0) { AskResumeVideo ask = new AskResumeVideo(vid.ResumePosition); ask.Owner = Window.GetWindow(this); if (ask.ShowDialog() == true) { force = false; } } MainWindow.videoHandler.PlayVideo(vid, force); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static VideoInfo ToVideoInfo(this VideoLocalVM vid, bool forcebegining) { if (string.IsNullOrEmpty(vid.LocalFileSystemFullPath)) { if (vid.Media?.Parts == null || vid.Media.Parts.Count == 0) { throw new Exception("There is no media information loaded in the video selected, we're unable to stream the media"); } Tuple <string, List <string> > t = GetInfoFromMedia(vid.Media); return(new VideoInfo { Uri = t.Item1, SubtitlePaths = t.Item2, IsUrl = true, Duration = vid.Duration, ResumePosition = forcebegining ? 0 : vid.ResumePosition, VideoLocalId = vid.VideoLocalID, VideoLocal = vid, WasWatched = vid.WatchedDate.HasValue }); } return(new VideoInfo { Uri = vid.LocalFileSystemFullPath, IsUrl = false, Duration = vid.Duration, ResumePosition = forcebegining ? 0 : vid.ResumePosition, VideoLocalId = vid.VideoLocalID, VideoLocal = vid, WasWatched = vid.WatchedDate.HasValue }); }
private void CommandBinding_OpenFolder(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; if (File.Exists(vid.FullPath)) { Utils.OpenFolderAndSelectFile(vid.FullPath); } else { MessageBox.Show(Properties.Resources.MSG_ERR_FileNotFound, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void CommandBinding_RescanFile(object sender, ExecutedRoutedEventArgs e) { try { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; EnableDisableControls(false); JMMServerVM.Instance.clientBinaryHTTP.RescanFile(vid.VideoLocalID); } MessageBox.Show(Properties.Resources.MSG_INFO_AddedQueueCmds, "Done", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } EnableDisableControls(true); }
private void CommandBinding_DeleteFile(object sender, ExecutedRoutedEventArgs e) { try { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; MessageBoxResult res = MessageBox.Show(string.Format(Properties.Resources.Unrecognized_ConfirmDelete, vid.FullPath), Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { EnableDisableControls(false); string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalAndFile(vid.VideoLocalID); if (result.Length > 0) { MessageBox.Show(result, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } else { RefreshIgnoredFiles(); } } } if (obj.GetType() == typeof(MultipleVideos)) { MultipleVideos mv = obj as MultipleVideos; MessageBoxResult res = MessageBox.Show(string.Format(Properties.Resources.Unrecognized_DeleteSelected, mv.VideoLocalIDs.Count), Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { EnableDisableControls(false); foreach (int id in mv.VideoLocalIDs) { JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalAndFile(id); } RefreshIgnoredFiles(); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } EnableDisableControls(true); }
public void PlayVideo(VideoLocalVM vid) { try { string defaultplayer; switch (UserSettingsVM.Instance.DefaultPlayer_GroupList) { case (int)DefaultVideoPlayer.MPC: defaultplayer = "mpc-hc"; break; case (int)DefaultVideoPlayer.PotPlayer: defaultplayer = "PotPlayerMini"; break; case (int)DefaultVideoPlayer.VLC: defaultplayer = "vlc"; break; default: defaultplayer = ""; break; } if (vid.FullPath.Contains("http:")) { try { Process.Start(defaultplayer, '"' + vid.FullPath.Replace(@"\", "/") + '"'); } catch (Exception e) { Process.Start(defaultplayer + "64", '"' + vid.FullPath.Replace(@"\", "/") + '"'); } } else { try { if (string.IsNullOrEmpty(defaultplayer)) { Process.Start(new ProcessStartInfo(vid.FullPath)); } else { Process.Start(defaultplayer, '"' + vid.FullPath + '"'); } } catch (Exception e) { Process.Start(defaultplayer + "64", '"' + vid.FullPath.Replace(@"\", "/") + '"'); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void PlayVideo(VideoLocalVM vid) { try { Process.Start(new ProcessStartInfo(vid.FullPath)); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
/*public AVDumpVM(VideoDetailedVM vid) { this.FullPath = vid.FullPath; this.FileSize = vid.VideoLocal_FileSize; this.ED2KDump = ""; this.AVDumpFullResult = ""; this.HasBeenDumped = false; this.IsBeingDumped = false; this.DumpStatus = "To be processed"; }*/ public AVDumpVM(VideoLocalVM vid) { this.FullPath = vid.LocalFileSystemFullPath; this.FileSize = vid.FileSize; this.ED2KDump = ""; this.AVDumpFullResult = ""; this.HasBeenDumped = false; this.IsBeingDumped = false; this.DumpStatus = "To be processed"; this.VideoLocal = vid; }
private void CommandBinding_DeleteFile(object sender, ExecutedRoutedEventArgs e) { try { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; MessageBoxResult res = MessageBox.Show(string.Format("Are you sure you want to delete this file: {0}", vid.FullPath), "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalAndFile(vid.VideoLocalID); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { RefreshUnrecognisedFiles(); } } } if (obj.GetType() == typeof(MultipleVideos)) { MultipleVideos mv = obj as MultipleVideos; MessageBoxResult res = MessageBox.Show(string.Format("Are you sure you want to delete the {0} selected files", mv.VideoLocalIDs.Count), "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { foreach (int id in mv.VideoLocalIDs) { JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalAndFile(id); } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void DisplayEpisodes() { try { VideoLocalVM vidLocal = this.DataContext as VideoLocalVM; if (vidLocal != null) { lbEpisodes.ItemsSource = vidLocal.GetEpisodes(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public bool ResumeOrPlay(VideoLocalVM fileToPlay) { try { curEpisode = null; int timeMovieStopped = 0; if (!File.Exists(fileToPlay.FullPath)) { Utils.DialogMsg("Error", "File could not be found!"); return(false); } BaseConfig.MyAnimeLog.Write("Getting time stopped for : {0}", fileToPlay.FullPath); timeMovieStopped = GetTimeStopped(fileToPlay.FullPath); BaseConfig.MyAnimeLog.Write("Time stopped for : {0} - {1}", fileToPlay.FullPath, timeMovieStopped); curFileName = fileToPlay.FullPath; #region Ask user to Resume if (timeMovieStopped > 0) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(900)); //resume movie? dlgYesNo.SetLine(1, fileToPlay.FileName); dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + MediaPortal.Util.Utils.SecondsToHMSString(timeMovieStopped)); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) // reset resume data in DB { timeMovieStopped = 0; } } } #endregion Play(timeMovieStopped, fileToPlay.DefaultAudioLanguage, fileToPlay.DefaultSubtitleLanguage); return(true); } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Error inResumeOrPlay : {0}", ex.ToString()); } return(false); }
private void DgVideos_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { ccDetail.Content = null; ccDetailMultiple.Content = null; AnyVideosSelected = dgVideos.SelectedItems.Count > 0; OneVideoSelected = dgVideos.SelectedItems.Count == 1; MultipleVideosSelected = dgVideos.SelectedItems.Count > 1; MultipleTypeRange = cboMultiType.SelectedIndex == 0; MultipleTypeSingle = cboMultiType.SelectedIndex == 1; // if only one video selected if (OneVideoSelected) { VideoLocalVM vid = dgVideos.SelectedItem as VideoLocalVM; ccDetail.Content = vid; } // if only one video selected if (MultipleVideosSelected) { MultipleVideos mv = new MultipleVideos(); mv.SelectedCount = dgVideos.SelectedItems.Count; mv.VideoLocalIDs = new List <int>(); mv.VideoLocals = new List <VideoLocalVM>(); foreach (object obj in dgVideos.SelectedItems) { VideoLocalVM vid = obj as VideoLocalVM; mv.VideoLocalIDs.Add(vid.VideoLocalID); mv.VideoLocals.Add(vid); } ccDetailMultiple.Content = mv; } SetConfirmDetails(); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void workerAvdump_DoWork(object sender, DoWorkEventArgs e) { VideoLocalVM vid = e.Argument as VideoLocalVM; //Create process System.Diagnostics.Process pProcess = new System.Diagnostics.Process(); //strCommand is path and file name of command to run string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string filePath = System.IO.Path.Combine(appPath, "AVDump2CL.exe"); if (!File.Exists(filePath)) { e.Result = "Could not find AvDump2 CLI: " + filePath; return; } if (string.IsNullOrEmpty(vid?.LocalFileSystemFullPath)) { e.Result = "Unable to map video file : " + vid.FileName; return; } if (!File.Exists(vid.LocalFileSystemFullPath)) { e.Result = "Could not find Video File: " + vid.LocalFileSystemFullPath; return; } pProcess.StartInfo.FileName = filePath; //strCommandParameters are parameters to pass to program string fileName = (char)34 + vid.LocalFileSystemFullPath + (char)34; pProcess.StartInfo.Arguments = string.Format(@" --Auth={0}:{1} --LPort={2} --PrintEd2kLink -t {3}", JMMServerVM.Instance.AniDB_Username, JMMServerVM.Instance.AniDB_AVDumpKey, JMMServerVM.Instance.AniDB_AVDumpClientPort, fileName); pProcess.StartInfo.UseShellExecute = false; pProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; pProcess.StartInfo.RedirectStandardOutput = true; pProcess.StartInfo.CreateNoWindow = true; pProcess.Start(); string strOutput = pProcess.StandardOutput.ReadToEnd(); //Wait for process to finish pProcess.WaitForExit(); e.Result = strOutput; }
private void CommandBinding_RestoreFile(object sender, ExecutedRoutedEventArgs e) { try { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; EnableDisableControls(false); string result = JMMServerVM.Instance.clientBinaryHTTP.SetIgnoreStatusOnFile(vid.VideoLocalID, false); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { RefreshIgnoredFiles(); } } if (obj.GetType() == typeof(MultipleVideos)) { MultipleVideos mv = obj as MultipleVideos; foreach (int id in mv.VideoLocalIDs) { string result = JMMServerVM.Instance.clientBinaryHTTP.SetIgnoreStatusOnFile(id, false); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } RefreshIgnoredFiles(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } EnableDisableControls(true); }
void lbVideos_SelectionChanged(object sender, SelectionChangedEventArgs e) { // get detailed video, episode and series info ccDetail.Content = null; ccSeriesDetail.Content = null; if (lbVideos.SelectedItems.Count == 0) { return; } if (lbVideos.SelectedItem == null) { return; } VideoLocalVM vid = lbVideos.SelectedItem as VideoLocalVM; displayingVidID = vid.VideoLocalID; EnableDisableControls(false); try { this.Cursor = Cursors.Wait; ccDetail.Content = vid; // get the episode(s) List <JMMServerBinary.Contract_AnimeEpisode> rawEps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForFile( vid.VideoLocalID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (rawEps.Count > 0) { AnimeEpisodeVM ep = new AnimeEpisodeVM(rawEps[0]); ccSeriesDetail.Content = ep; } this.Cursor = Cursors.Arrow; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; EnableDisableControls(true); } }
private bool FileSearchFilter(object obj) { VideoLocalVM vid = obj as VideoLocalVM; if (vid == null) { return(true); } int index = vid.FilePath.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase); if (index > -1) { return(true); } return(false); }
public void PlayVideo(VideoLocalVM vid, bool forcebegining) { try { IVideoPlayer player = ResolvePlayer(); if (player == null) { throw new Exception("Please configure a Video Player"); } VideoInfo info = vid.ToVideoInfo(forcebegining); recentlyPlayedFiles[info.VideoLocalId] = info; player.Play(info); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED: { int iControl = message.SenderControlId; if (iControl == (int)m_Facade.GetID) { GUIListItem item = m_Facade.SelectedListItem; if (item == null || item.TVTag == null) { return(true); } // unlinked files if (item.TVTag.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = item.TVTag as VideoLocalVM; if (vid != null) { setGUIProperty("Utilities.UnlinkedFile.Folder", Path.GetDirectoryName(vid.FullPath)); setGUIProperty("Utilities.UnlinkedFile.FileName", Path.GetFileName(vid.FullPath)); setGUIProperty("Utilities.UnlinkedFile.Size", Utils.FormatFileSize(vid.FileSize)); setGUIProperty("Utilities.UnlinkedFile.Hash", vid.Hash); setGUIProperty("Utilities.UnlinkedFile.FileExists", File.Exists(vid.FullPath) ? "YES" : "NO"); } } } } return(true); default: return(base.OnMessage(message)); } }
private void CommandBinding_DeleteLink(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(AnimeEpisodeVM)) { AnimeEpisodeVM ep = obj as AnimeEpisodeVM; VideoLocalVM vid = this.DataContext as VideoLocalVM; string res = JMMServerVM.Instance.clientBinaryHTTP.RemoveAssociationOnFile(vid.VideoLocalID, ep.AniDB_EpisodeID); if (res.Length > 0) { MessageBox.Show(res, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (ep != null) { MainListHelperVM.Instance.UpdateHeirarchy(ep); DisplayEpisodes(); } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void lbVideos_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { ccDetail.Content = null; ccDetailMultiple.Content = null; OneVideoSelected = lbVideos.SelectedItems.Count == 1; MultipleVideosSelected = lbVideos.SelectedItems.Count > 1; // if only one video selected if (OneVideoSelected) { VideoLocalVM vid = lbVideos.SelectedItem as VideoLocalVM; ccDetail.Content = vid; } // if only one video selected if (MultipleVideosSelected) { MultipleVideos mv = new MultipleVideos(); mv.SelectedCount = lbVideos.SelectedItems.Count; mv.VideoLocalIDs = new List <int>(); foreach (object obj in lbVideos.SelectedItems) { VideoLocalVM vid = obj as VideoLocalVM; mv.VideoLocalIDs.Add(vid.VideoLocalID); } ccDetailMultiple.Content = mv; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private bool FileSearchFilter(object obj) { VideoLocalVM vid = obj as VideoLocalVM; if (vid == null) { return(true); } foreach (VideoLocal_PlaceVM n in vid.Places) { int index = n.FilePath.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase); if (index > -1) { return(true); } /* * index = vid.FileDirectory.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase); * if (index > -1) return true;*/ } return(false); }
private void CommandBinding_AvdumpFile(object sender, ExecutedRoutedEventArgs e) { try { MainWindow MainWindow = (MainWindow)Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } if (obj.GetType() == typeof(AnimeEpisodeVM)) { AnimeEpisodeVM ep = obj as AnimeEpisodeVM; VideoLocalVM vid = this.DataContext as VideoLocalVM; MainWindow.ShowPinnedFileAvDump(vid); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void PlayVideo(VideoLocalVM vid) { try { IVideoPlayer player = ResolvePlayer(); if (player == null) { throw new Exception("Please configure a Video Player"); } if (AppSettings.UseStreaming && vid.Media != null && vid.Media.Parts != null && vid.Media.Parts.Count > 0 && !IsLocalMachine(vid.Media.Parts[0].Key)) { Tuple <string, List <string> > t = GetInfoFromMedia(vid.Media); player.PlayUrl(t.Item1, t.Item2); } else { player.PlayVideoOrPlaylist(vid.FullPath); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void CommandBinding_PlayVideo(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; MainWindow.videoHandler.PlayVideo(vid); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void CommandBinding_DeleteFile(object sender, ExecutedRoutedEventArgs e) { try { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } if (obj.GetType() == typeof(VideoLocalVM)) { VideoLocalVM vid = obj as VideoLocalVM; AskDeleteFile dlg = new AskDeleteFile(string.Format(Properties.Resources.DeleteFile_Title, vid.FileName), Properties.Resources.Unrecognized_ConfirmDelete + "\r\n\r\n" + Properties.Resources.DeleteFile_Confirm, vid.Places); dlg.Owner = Window.GetWindow(this); bool?res = dlg.ShowDialog(); if (res.HasValue && res.Value) { EnableDisableControls(false); string tresult = string.Empty; this.Cursor = Cursors.Wait; foreach (VideoLocal_PlaceVM lv in dlg.Selected) { string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalPlaceAndFile(lv.VideoLocal_Place_ID); if (result.Length > 0) { tresult += result + "\r\n"; } } if (!string.IsNullOrEmpty(tresult)) { MessageBox.Show(tresult, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } RefreshIgnoredFiles(); } } if (obj.GetType() == typeof(MultipleVideos)) { MultipleVideos mv = obj as MultipleVideos; AskDeleteFile dlg = new AskDeleteFile(Properties.Resources.DeleteFile_Multiple, Properties.Resources.Unrecognized_DeleteSelected + "\r\n\r\n" + Properties.Resources.DeleteFile_Confirm, mv.VideoLocals.SelectMany(a => a.Places).ToList()); dlg.Owner = Window.GetWindow(this); bool?res = dlg.ShowDialog(); if (res.HasValue && res.Value) { EnableDisableControls(false); string tresult = string.Empty; this.Cursor = Cursors.Wait; foreach (VideoLocal_PlaceVM lv in dlg.Selected) { string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalPlaceAndFile(lv.VideoLocal_Place_ID); if (result.Length > 0) { tresult += result + "\r\n"; } } if (!string.IsNullOrEmpty(tresult)) { MessageBox.Show(tresult, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } RefreshIgnoredFiles(); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } EnableDisableControls(true); }
public void PlayVideo(VideoLocalVM vid) { try { defaultplayer = UserSettingsVM.Instance.DefaultPlayer_GroupList.ToString(); switch (defaultplayer) { case "1": defaultplayer = "mpc-hc"; break; case "2": defaultplayer = "PotPlayerMini"; break; case "3": defaultplayer = "vlc"; break; default: defaultplayer = "vlc"; break; } if (vid.FullPath.Contains("http:")) { try { Process.Start(defaultplayer, '"' + vid.FullPath.Replace(@"\", "/") + '"'); } catch (Exception e) { Process.Start(defaultplayer + "64", '"' + vid.FullPath.Replace(@"\", "/") + '"'); } } else { try { Process.Start(defaultplayer, '"' + vid.FullPath + '"'); } catch (Exception e) { Process.Start(defaultplayer + "64", '"' + vid.FullPath.Replace(@"\", "/") + '"'); } } defaultplayer = UserSettingsVM.Instance.DefaultPlayer_GroupList.ToString(); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void btnConfirm_Click(object sender, RoutedEventArgs e) { try { Window parentWindow = Window.GetWindow(this); // if only one video selected if (OneVideoSelected) { EnableDisableControls(false); VideoLocalVM vid = dgVideos.SelectedItem as VideoLocalVM; if (cboMultiType.SelectedIndex == 0) { // single file to multiple episodes // eg a file is a double episode int startEpNum = 0, endEpNum = 0; int.TryParse(txtStartEpNum.Text, out startEpNum); int.TryParse(txtEndEpNumSingle.Text, out endEpNum); string result = ""; // make sure the episode range is valid // make sure the last episode number is within the valid range AnimeSeriesVM series = lbSeries.SelectedItem as AnimeSeriesVM; if (series.LatestRegularEpisodeNumber < endEpNum || startEpNum <= 0 && endEpNum <= 0 && endEpNum <= startEpNum) { // otherwise allow the user to refresh it from anidb MessageBoxResult res = MessageBox.Show(Properties.Resources.MSG_ERR_InvalidEpGetAnime, "Error", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (res == MessageBoxResult.Yes) { result = JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(series.AniDB_ID); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); EnableDisableControls(true); return; } else { // check again if (series.LatestRegularEpisodeNumber < endEpNum) { MessageBox.Show(Properties.Resources.MSG_ERR_InvalidEp, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); EnableDisableControls(true); return; } } } else { EnableDisableControls(true); return; } } result = JMMServerVM.Instance.clientBinaryHTTP.AssociateSingleFileWithMultipleEpisodes(vid.VideoLocalID, series.AnimeSeriesID.Value, startEpNum, endEpNum); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { RefreshUnrecognisedFiles(); } } else { // single file to a single episode AnimeEpisodeVM ep = cboEpisodes.SelectedItem as AnimeEpisodeVM; string result = JMMServerVM.Instance.clientBinaryHTTP.AssociateSingleFile(vid.VideoLocalID, ep.AnimeEpisodeID); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { RefreshUnrecognisedFiles(); //MainListHelperVM.Instance.UpdateHeirarchy(ep, ((MainWindow)parentWindow).epListMain); MainListHelperVM.Instance.UpdateHeirarchy(ep); } } } // if multiple videos selected if (MultipleVideosSelected) { int startEpNum = 0, endEpNum = 0; int.TryParse(txtStartEpNum.Text, out startEpNum); if (MultipleTypeRange) { endEpNum = startEpNum + dgVideos.SelectedItems.Count - 1; } else { endEpNum = startEpNum; } // make sure the last episode number is within the valid range AnimeSeriesVM series = lbSeries.SelectedItem as AnimeSeriesVM; if (series.LatestRegularEpisodeNumber < endEpNum && startEpNum > 0) { // otherwise allow the user to refresh it from anidb MessageBoxResult res = MessageBox.Show(Properties.Resources.MSG_ERR_InvalidEpGetAnime, "Error", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (res == MessageBoxResult.Yes) { string result = JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(series.AniDB_ID); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); EnableDisableControls(true); return; } else { // check again if (series.LatestRegularEpisodeNumber < endEpNum) { MessageBox.Show(Properties.Resources.MSG_ERR_InvalidEp, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); EnableDisableControls(true); return; } } } else { EnableDisableControls(true); return; } } // get all the selected videos List <int> vidIDs = new List <int>(); foreach (object obj in dgVideos.SelectedItems) { VideoLocalVM vid = obj as VideoLocalVM; vidIDs.Add(vid.VideoLocalID); } string msg = JMMServerVM.Instance.clientBinaryHTTP.AssociateMultipleFiles(vidIDs, series.AnimeSeriesID.Value, startEpNum, MultipleTypeSingle); if (msg.Length > 0) { MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { RefreshUnrecognisedFiles(); //MainListHelperVM.Instance.UpdateHeirarchy(ep, ((MainWindow)parentWindow).epListMain); //ep.RefreshFilesForEpisode(); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } EnableDisableControls(true); }
public void ShowPinnedFileAvDump(VideoLocalVM vid) { try { foreach (AVDumpVM dumpTemp in MainListHelperVM.Instance.AVDumpFiles) { if (dumpTemp.FullPath == vid.LocalFileSystemFullPath) return; } AVDumpVM dump = new AVDumpVM(vid); MainListHelperVM.Instance.AVDumpFiles.Add(dump); tabControl1.SelectedIndex = TAB_MAIN_FileManger; tabFileManager.SelectedIndex = TAB_FileManger_Avdump; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
protected override void OnShowContextMenu() { try { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) { return; } VideoLocalVM vid = currentitem.TVTag as VideoLocalVM; if (vid == null) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlg.Reset(); dlg.SetHeading("File options"); dlg.Add("Play file"); dlg.Add("Rehash file"); dlg.Add("Ignore file"); dlg.Add("Delete file from disk"); dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId == 1) { MainWindow.vidHandler.ResumeOrPlay(vid); return; } if (dlg.SelectedId == 2) { JMMServerVM.Instance.clientBinaryHTTP.RehashFile(vid.VideoLocalID); Utils.DialogMsg("Done", "Action has been queued on server"); return; } if (dlg.SelectedId == 3) { JMMServerVM.Instance.clientBinaryHTTP.SetIgnoreStatusOnFile(vid.VideoLocalID, true); RefreshUnlinkedFiles(); return; } if (dlg.SelectedId == 4) { if (!Utils.DialogConfirm("Are you sure you want to delete this file?")) { return; } JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalAndFile(vid.VideoLocalID); RefreshUnlinkedFiles(); } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Error in menu: {0}", ex); } }
public void PlayVideo(VideoLocalVM vid, bool forcebegining) { try { IVideoPlayer player = ResolvePlayer(); if (player == null) throw new Exception("Please configure a Video Player"); VideoInfo info = vid.ToVideoInfo(forcebegining); recentlyPlayedFiles[info.VideoLocalId]=info; player.Play(info); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void btnLoadFiles_Click(object sender, RoutedEventArgs e) { try { if (!JMMServerVM.Instance.ServerOnline) return; ViewFiles.Refresh(); this.Cursor = Cursors.Wait; EnableDisableControls(false); List<JMMServerBinary.Contract_VideoLocal> rawVids = new List<JMMServerBinary.Contract_VideoLocal>(); if (LoadTypeIsRandom) { rawVids = JMMServerVM.Instance.clientBinaryHTTP.RandomFileRenamePreview(udRandomFiles.Value.Value, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); /*List<int> testIDs = new List<int>(); testIDs.Add(6041); // Gekijouban Bleach: Fade to Black Kimi no Na o Yobu testIDs.Add(6784); // Fate/Stay Night: Unlimited Blade Works testIDs.Add(5975); // Toaru Majutsu no Index testIDs.Add(7599); // Toaru Majutsu no Index II testIDs.Add(8694); // Gekijouban Toaru Majutsu no Index (movie) testIDs.Add(6071); // Quiz Magic Academy: The Original Animation testIDs.Add(4145); // Amaenaide yo!! Katsu!! testIDs.Add(2369); // Bleach testIDs.Add(69); // One Piece foreach (int animeID in testIDs) { List<JMMServerBinary.Contract_VideoLocal> raws = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(animeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); rawVids.AddRange(raws); }*/ } if (LoadTypeIsAll) { rawVids = JMMServerVM.Instance.clientBinaryHTTP.RandomFileRenamePreview(int.MaxValue, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); } if (LoadTypeIsSeries) { Window wdw = Window.GetWindow(this); SelectGroupSeriesForm frm = new SelectGroupSeriesForm(); frm.Owner = wdw; frm.Init(); bool? result = frm.ShowDialog(); if (result.HasValue && result.Value == true) { if (frm.SelectedObject.GetType() == typeof(AnimeGroupVM)) { AnimeGroupVM grp = frm.SelectedObject as AnimeGroupVM; foreach (AnimeSeriesVM ser in grp.AllAnimeSeries) { List<JMMServerBinary.Contract_VideoLocal> raws = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(ser.AniDB_ID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); rawVids.AddRange(raws); } } if (frm.SelectedObject.GetType() == typeof(AnimeSeriesVM)) { AnimeSeriesVM ser = frm.SelectedObject as AnimeSeriesVM; List<JMMServerBinary.Contract_VideoLocal> raws = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(ser.AniDB_ID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); rawVids.AddRange(raws); } } } foreach (JMMServerBinary.Contract_VideoLocal raw in rawVids) { VideoLocalVM vid = new VideoLocalVM(raw); VideoLocalRenamedVM ren = new VideoLocalRenamedVM(); ren.VideoLocalID = vid.VideoLocalID; ren.VideoLocal = vid; ren.Success = false; FileResults.Add(ren); } FileCount = FileResults.Count; this.Cursor = Cursors.Arrow; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; EnableDisableControls(true); } }
void btnLoadFiles_Click(object sender, RoutedEventArgs e) { try { if (!JMMServerVM.Instance.ServerOnline) { return; } ViewFiles.Refresh(); this.Cursor = Cursors.Wait; EnableDisableControls(false); List <JMMServerBinary.Contract_VideoLocal> rawVids = new List <JMMServerBinary.Contract_VideoLocal>(); if (LoadTypeIsRandom) { rawVids = JMMServerVM.Instance.clientBinaryHTTP.RandomFileRenamePreview(udRandomFiles.Value.Value, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); /*List<int> testIDs = new List<int>(); * * testIDs.Add(6041); // Gekijouban Bleach: Fade to Black Kimi no Na o Yobu * testIDs.Add(6784); // Fate/Stay Night: Unlimited Blade Works * testIDs.Add(5975); // Toaru Majutsu no Index * testIDs.Add(7599); // Toaru Majutsu no Index II * testIDs.Add(8694); // Gekijouban Toaru Majutsu no Index (movie) * testIDs.Add(6071); // Quiz Magic Academy: The Original Animation * testIDs.Add(4145); // Amaenaide yo!! Katsu!! * testIDs.Add(2369); // Bleach * testIDs.Add(69); // One Piece * foreach (int animeID in testIDs) * { * List<JMMServerBinary.Contract_VideoLocal> raws = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(animeID, * JMMServerVM.Instance.CurrentUser.JMMUserID.Value); * * rawVids.AddRange(raws); * }*/ } if (LoadTypeIsAll) { rawVids = JMMServerVM.Instance.clientBinaryHTTP.RandomFileRenamePreview(int.MaxValue, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); } if (LoadTypeIsSeries) { Window wdw = Window.GetWindow(this); SelectGroupSeriesForm frm = new SelectGroupSeriesForm(); frm.Owner = wdw; frm.Init(); bool?result = frm.ShowDialog(); if (result.HasValue && result.Value == true) { if (frm.SelectedObject.GetType() == typeof(AnimeGroupVM)) { AnimeGroupVM grp = frm.SelectedObject as AnimeGroupVM; foreach (AnimeSeriesVM ser in grp.AllAnimeSeries) { List <JMMServerBinary.Contract_VideoLocal> raws = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(ser.AniDB_ID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); rawVids.AddRange(raws); } } if (frm.SelectedObject.GetType() == typeof(AnimeSeriesVM)) { AnimeSeriesVM ser = frm.SelectedObject as AnimeSeriesVM; List <JMMServerBinary.Contract_VideoLocal> raws = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(ser.AniDB_ID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); rawVids.AddRange(raws); } } } foreach (JMMServerBinary.Contract_VideoLocal raw in rawVids) { VideoLocalVM vid = new VideoLocalVM(raw); VideoLocalRenamedVM ren = new VideoLocalRenamedVM(); ren.VideoLocalID = vid.VideoLocalID; ren.VideoLocal = vid; ren.Success = false; FileResults.Add(ren); } FileCount = FileResults.Count; this.Cursor = Cursors.Arrow; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; EnableDisableControls(true); } }