From 75c8f52aa0f10554fa7b5060a2c49efa4eb8d986 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 11 Sep 2011 10:34:06 +0000 Subject: [PATCH] NowPlayingPlugin: Added SHUFFLE/REPEAT support to foobar2000. --- Plugins/PluginNowPlaying/PlayerFoobar.cpp | 46 +++++++++++++++++++++++ Plugins/PluginNowPlaying/PlayerFoobar.h | 5 ++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Plugins/PluginNowPlaying/PlayerFoobar.cpp b/Plugins/PluginNowPlaying/PlayerFoobar.cpp index 7018d3da..8e5df7f2 100644 --- a/Plugins/PluginNowPlaying/PlayerFoobar.cpp +++ b/Plugins/PluginNowPlaying/PlayerFoobar.cpp @@ -273,6 +273,26 @@ LRESULT CALLBACK CPlayerFoobar::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR player->FindLyrics(); } } + token = wcstok(NULL, L"\t"); + if (token) + { + switch (_wtoi(token)) + { + case 0: + player->m_Shuffle = player->m_Repeat = false; + break; + + case 1: + player->m_Shuffle = true; + player->m_Repeat = false; + break; + + case 2: + player->m_Shuffle = false; + player->m_Repeat = true; + break; + } + } } } return 0; @@ -358,6 +378,32 @@ void CPlayerFoobar::SetPosition(int position) SendMessage(m_FooWindow, WM_USER, position, FOO_SETPOSITION); } +/* +** SetShuffle +** +** Handles the SetShuffle bang. +** +*/ +void CPlayerFoobar::SetShuffle(bool state) +{ + m_Shuffle = state; + m_Repeat = state ? !m_Shuffle : m_Shuffle; + SendMessage(m_FooWindow, WM_USER, state ? 1 : 0, FOO_SETORDER); +} + +/* +** SetRepeat +** +** Handles the SetRepeat bang. +** +*/ +void CPlayerFoobar::SetRepeat(bool state) +{ + m_Repeat = state; + m_Shuffle = state ? !m_Repeat : m_Repeat; + SendMessage(m_FooWindow, WM_USER, state ? 2 : 0, FOO_SETORDER); +} + /* ** SetVolume ** diff --git a/Plugins/PluginNowPlaying/PlayerFoobar.h b/Plugins/PluginNowPlaying/PlayerFoobar.h index 7a3bd4d7..b5be9012 100644 --- a/Plugins/PluginNowPlaying/PlayerFoobar.h +++ b/Plugins/PluginNowPlaying/PlayerFoobar.h @@ -38,6 +38,8 @@ public: virtual void SetPosition(int position); virtual void SetRating(int rating) {} virtual void SetVolume(int volume); + virtual void SetShuffle(bool state); + virtual void SetRepeat(bool state); virtual void ClosePlayer(); virtual void OpenPlayer(std::wstring& path); @@ -70,7 +72,8 @@ private: FOO_QUITPLAYER, FOO_SETCALLBACK, FOO_REMOVECALLBACK, - FOO_SETPOSITION + FOO_SETPOSITION, + FOO_SETORDER }; void Initialize();