Ejemplo n.º 1
0
        private void UpdateValues()
        {
            IMJCurPlaylistAutomation currentPlaylist      = MJ.GetCurPlaylist();
            IMJFileAutomation        currentTrack         = currentPlaylist.GetFile(currentPlaylist.Position);
            IMJPlaybackAutomation    currentPlaybackTrack = MJ.GetPlayback();

            // Update values
            if (currentPlaylist.Position == 0 && !currentPlaylist.Continuous)
            {
                m_PreviousTrackTextControl.Text = "-";
            }
            else
            {
                m_PreviousTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetPreviousFile()).Name;
            }
            m_CurrentTrackTextControl.Text = currentTrack.Name;
            if (!currentPlaylist.GetCanPlayNext() || (currentPlaylist.Position >= (currentPlaylist.GetNumberFiles() - 1) && !currentPlaylist.Continuous))
            {
                m_NextTrackTextControl.Text = "-";
            }
            else
            {
                m_NextTrackTextControl.Text = currentPlaylist.GetFile(currentPlaylist.GetNextFile()).Name;
            }

            m_CurrentTrackProgressControl.Min     = 0;
            m_CurrentTrackProgressControl.Max     = currentTrack.Duration;
            m_CurrentTrackProgressControl.Current = currentPlaybackTrack.Position;

            m_CurrentTrackPositionTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentPlaybackTrack.Position)).ToString("g");
            m_CurrentTrackDurationTextControl.Text = TimeSpan.FromSeconds(Convert.ToDouble(currentTrack.Duration)).ToString("g");

            if (m_RaisePriorityUntil > DateTime.Now)
            {
                if (!QvgaDevice.ForegroundApplet)
                {
                    QvgaDevice.ForegroundApplet = true;
                }
                m_UpdatePriority = UpdatePriorities.Alert;
            }
            else
            {
                if (QvgaDevice.ForegroundApplet)
                {
                    QvgaDevice.ForegroundApplet = false;
                }
                m_UpdatePriority = UpdatePriorities.Normal;
            }
        }
        private void setWindowTitle()
        {
            IMJPlaybackAutomation playback = mcRef.GetPlayback();

            if (playback.State != MJPlaybackStates.PLAYSTATE_STOPPED && displayArtistTrackName.Checked)
            {
                Windows7Taskbar.SetThumbnailTooltip((IntPtr)mcRef.GetWindowHandle(), nowPlayingFile.Artist + " - " + nowPlayingFile.Name);
                SetWindowText((IntPtr)mcRef.GetWindowHandle(), nowPlayingFile.Artist + " - " + nowPlayingFile.Name);
            }
            else
            {
                SetWindowText((IntPtr)mcRef.GetWindowHandle(), oldWindowText.ToString());
                Windows7Taskbar.SetThumbnailTooltip((IntPtr)mcRef.GetWindowHandle(), oldWindowText.ToString());
            }
        }
        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;
        }