private bool setFieldValue(IMJFileAutomation file, string jrField, string value, bool isDisplayName = false) { try { if (isDisplayName) { FieldMap.TryGetValue(jrField.ToLower(), out jrField); } bool ok = file.Set(jrField, value); if (!ok) { if (file.Get(jrField, false) == value) { ok = true; } } return(ok); } catch { } return(false); }
private JRFile getFieldValues(IMJFileAutomation file, List <string> fields = null, bool formatted = true) { lastException = null; try { // get fields Dictionary <string, string> JRfields = new Dictionary <string, string>(); JRfields["date imported"] = getFieldValue(file, "date imported", formatted); // datetime / epoch JRfields["date (release)"] = getFieldValue(file, "date (release)", formatted); // date / days since 1900 JRfields["date"] = getFieldValue(file, "date", formatted); // date / days since 1900 JRfields["date (year)"] = getFieldValue(file, "date (year)", formatted); // year JRfields["name"] = getFieldValue(file, "name", formatted); JRfields["filename"] = getFieldValue(file, "filename", formatted); JRfields["file size"] = getFieldValue(file, "file size", formatted); JRfields["media sub type"] = getFieldValue(file, "media sub type", formatted); JRfields["media type"] = getFieldValue(file, "media type", formatted); if (fields != null && fields.Count > 0) { foreach (string f in fields) { if (!JRfields.ContainsKey(f.ToLower())) { JRfields[f.ToLower()] = getFieldValue(file, f, formatted); } } } JRFile info = new JRFile(file.GetKey(), JRfields); return(info); } catch (Exception ex) { Logger.Log(ex, "JRiverAPI.getMovieInfo()"); lastException = ex; } return(null); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { playback = mcRef.GetPlayback(); //customWindow = Windows7.DesktopIntegration.CustomWindowsManager.CreateWindowsManager((IntPtr)mcRef.GetWindowHandle(), IntPtr.Zero); //IMJFileAutomation nowPlayingFile; //nowPlayingFile = mcRef.GetCurPlaylist().GetFile(mcRef.GetCurPlaylist().Position); int i = 0; string prevFile = ""; string currentFile = ""; while (playback.State != MJPlaybackStates.PLAYSTATE_STOPPED) { nowPlayingFile = mcRef.GetCurPlaylist().GetFile(mcRef.GetCurPlaylist().Position); setWindowsPeak(); if (enableCoverArt.Checked) { Windows7Taskbar.EnableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); currentFile = nowPlayingFile.GetImageFile(MJImageFileFlags.IMAGEFILE_THUMBNAIL_MEDIUM); if (!string.IsNullOrEmpty(currentFile)) { if (currentFile != prevFile) { setPreview(currentFile); } } else { Windows7Taskbar.DisableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); } prevFile = currentFile; } else { Windows7Taskbar.DisableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); } createThumbnail(getDisplayWindowHandle()); if (trackProgress.Checked) { if (playback.State == MJPlaybackStates.PLAYSTATE_PLAYING) { windowsTaskbar.SetProgressState(TaskbarProgressBarState.Normal); addUserInfoText("Duration: " + playback.Duration); if (nowPlayingFile.Duration <= 0) windowsTaskbar.SetProgressState(TaskbarProgressBarState.Indeterminate); else { if (playback.Position >= 0) windowsTaskbar.SetProgressValue(playback.Position, nowPlayingFile.Duration); } } else if (playback.State == MJPlaybackStates.PLAYSTATE_PAUSED) windowsTaskbar.SetProgressState(TaskbarProgressBarState.Paused); } else if (playlistProgress.Checked) { windowsTaskbar.SetProgressState(playback.State != MJPlaybackStates.PLAYSTATE_PAUSED ? TaskbarProgressBarState.Normal : TaskbarProgressBarState.Paused); windowsTaskbar.SetProgressValue(mcRef.GetCurPlaylist().Position, mcRef.GetCurPlaylist().GetNumberFiles()); } else { windowsTaskbar.SetProgressState(TaskbarProgressBarState.NoProgress); } setWindowTitle(); System.Threading.Thread.Sleep(500); GC.Collect(); i++; } //Windows7Taskbar.DisableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); windowsTaskbar.SetProgressState(TaskbarProgressBarState.NoProgress); return; }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { playback = mcRef.GetPlayback(); //customWindow = Windows7.DesktopIntegration.CustomWindowsManager.CreateWindowsManager((IntPtr)mcRef.GetWindowHandle(), IntPtr.Zero); //IMJFileAutomation nowPlayingFile; //nowPlayingFile = mcRef.GetCurPlaylist().GetFile(mcRef.GetCurPlaylist().Position); int i = 0; string prevFile = ""; string currentFile = ""; while (playback.State != MJPlaybackStates.PLAYSTATE_STOPPED) { nowPlayingFile = mcRef.GetCurPlaylist().GetFile(mcRef.GetCurPlaylist().Position); setWindowsPeak(); if (enableCoverArt.Checked) { Windows7Taskbar.EnableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); currentFile = nowPlayingFile.GetImageFile(MJImageFileFlags.IMAGEFILE_THUMBNAIL_MEDIUM); if (!string.IsNullOrEmpty(currentFile)) { if (currentFile != prevFile) { setPreview(currentFile); } } else { Windows7Taskbar.DisableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); } prevFile = currentFile; } else { Windows7Taskbar.DisableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); } createThumbnail(getDisplayWindowHandle()); if (trackProgress.Checked) { if (playback.State == MJPlaybackStates.PLAYSTATE_PLAYING) { windowsTaskbar.SetProgressState(TaskbarProgressBarState.Normal); addUserInfoText("Duration: " + playback.Duration); if (nowPlayingFile.Duration <= 0) { windowsTaskbar.SetProgressState(TaskbarProgressBarState.Indeterminate); } else { if (playback.Position >= 0) { windowsTaskbar.SetProgressValue(playback.Position, nowPlayingFile.Duration); } } } else if (playback.State == MJPlaybackStates.PLAYSTATE_PAUSED) { windowsTaskbar.SetProgressState(TaskbarProgressBarState.Paused); } } else if (playlistProgress.Checked) { windowsTaskbar.SetProgressState(playback.State != MJPlaybackStates.PLAYSTATE_PAUSED ? TaskbarProgressBarState.Normal : TaskbarProgressBarState.Paused); windowsTaskbar.SetProgressValue(mcRef.GetCurPlaylist().Position, mcRef.GetCurPlaylist().GetNumberFiles()); } else { windowsTaskbar.SetProgressState(TaskbarProgressBarState.NoProgress); } setWindowTitle(); System.Threading.Thread.Sleep(500); GC.Collect(); i++; } //Windows7Taskbar.DisableCustomWindowPreview((IntPtr)mcRef.GetWindowHandle()); windowsTaskbar.SetProgressState(TaskbarProgressBarState.NoProgress); return; }