diff options
author | Anton Fedchin <anightik@gmail.com> | 2018-01-18 17:18:28 +0300 |
---|---|---|
committer | Anton Fedchin <anightik@gmail.com> | 2018-01-18 17:18:28 +0300 |
commit | 3648b3899cc994ab232375deffeb98b7be5a87d4 (patch) | |
tree | 8debb489749ddcf7de6286d11f7f916a135b67be | |
parent | 089ffc36375a0bb374c6e3402d3dad3624ea749d (diff) |
[win10] make the uwp app working in background and handles media buttons.
-rw-r--r-- | tools/windows/packaging/uwp/package.appxmanifest.in | 4 | ||||
-rw-r--r-- | xbmc/windowing/win10/WinEventsWin10.cpp | 55 | ||||
-rw-r--r-- | xbmc/windowing/win10/WinEventsWin10.h | 3 |
3 files changed, 61 insertions, 1 deletions
diff --git a/tools/windows/packaging/uwp/package.appxmanifest.in b/tools/windows/packaging/uwp/package.appxmanifest.in index c4bf60359b..1b4a619151 100644 --- a/tools/windows/packaging/uwp/package.appxmanifest.in +++ b/tools/windows/packaging/uwp/package.appxmanifest.in @@ -3,7 +3,8 @@ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" - IgnorableNamespaces="uap mp"> + xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" + IgnorableNamespaces="mp uap uap3"> <Identity Name="@APP_PACKAGE_IDENTITY@" ProcessorArchitecture="@SDK_TARGET_ARCH@" Publisher="CN=@APP_PACKAGE_PUBLISHER@" Version="@APP_VERSION_CODE@.0" /> <mp:PhoneIdentity PhoneProductId="0175E9D8-B885-4F34-BE46-F3BA2C70C00C" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> @@ -234,5 +235,6 @@ <uap:Capability Name="removableStorage" /> <uap:Capability Name="userAccountInformation" /> <uap:Capability Name="videosLibrary" /> + <uap3:Capability Name="backgroundMediaPlayback" /> </Capabilities> </Package>
\ No newline at end of file diff --git a/xbmc/windowing/win10/WinEventsWin10.cpp b/xbmc/windowing/win10/WinEventsWin10.cpp index 7fd1918b29..a90345f081 100644 --- a/xbmc/windowing/win10/WinEventsWin10.cpp +++ b/xbmc/windowing/win10/WinEventsWin10.cpp @@ -31,6 +31,7 @@ #include "utils/log.h" #include "utils/SystemInfo.h" #include "windowing/windows/WinKeyMap.h" +#include "xbmc/GUIUserMessages.h" #include "WinEventsWin10.h" using namespace PERIPHERALS; @@ -38,6 +39,7 @@ using namespace KODI::MESSAGING; using namespace Windows::Devices::Input; using namespace Windows::Foundation; using namespace Windows::Graphics::Display; +using namespace Windows::Media; using namespace Windows::System; using namespace Windows::UI::Core; using namespace Windows::UI::Input; @@ -134,6 +136,17 @@ void CWinEventsWin10::InitEventHandlers(CoreWindow^ window) // system SystemNavigationManager^ sysNavManager = SystemNavigationManager::GetForCurrentView(); sysNavManager->BackRequested += ref new EventHandler<BackRequestedEventArgs^>(CWinEventsWin10::OnBackRequested); + // requirement for backgroup playback + m_smtc = SystemMediaTransportControls::GetForCurrentView(); + if (m_smtc)
+ {
+ m_smtc->IsPlayEnabled = true; + m_smtc->IsPauseEnabled = true; + m_smtc->IsStopEnabled = true; + m_smtc->ButtonPressed += ref new TypedEventHandler<SystemMediaTransportControls^, SystemMediaTransportControlsButtonPressedEventArgs^>
+ (CWinEventsWin10::OnSystemMediaButtonPressed);
+ m_smtc->IsEnabled = true; + } } void CWinEventsWin10::UpdateWindowSize() @@ -466,3 +479,45 @@ void CWinEventsWin10::OnBackRequested(Platform::Object^ sender, Windows::UI::Cor } args->Handled = true; }
+
+void CWinEventsWin10::OnSystemMediaButtonPressed(SystemMediaTransportControls^ sender, SystemMediaTransportControlsButtonPressedEventArgs^ args)
+{
+ int action = ACTION_NONE;
+ switch (args->Button)
+ {
+ case SystemMediaTransportControlsButton::ChannelDown:
+ action = ACTION_CHANNEL_DOWN;
+ break;
+ case SystemMediaTransportControlsButton::ChannelUp:
+ action = ACTION_CHANNEL_UP;
+ break;
+ case SystemMediaTransportControlsButton::FastForward:
+ action = ACTION_PLAYER_FORWARD;
+ break;
+ case SystemMediaTransportControlsButton::Rewind:
+ action = ACTION_PLAYER_REWIND;
+ break;
+ case SystemMediaTransportControlsButton::Next:
+ action = ACTION_NEXT_ITEM;
+ break;
+ case SystemMediaTransportControlsButton::Previous:
+ action = ACTION_PREV_ITEM;
+ break;
+ case SystemMediaTransportControlsButton::Pause:
+ case SystemMediaTransportControlsButton::Play:
+ action = ACTION_PLAYER_PLAYPAUSE;
+ break;
+ case SystemMediaTransportControlsButton::Stop:
+ action = ACTION_STOP;
+ break;
+ case SystemMediaTransportControlsButton::Record:
+ action = ACTION_RECORD;
+ break;
+ default: + break;
+ }
+ if (action != ACTION_NONE)
+ {
+ CApplicationMessenger::GetInstance().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(action)));
+ }
+}
diff --git a/xbmc/windowing/win10/WinEventsWin10.h b/xbmc/windowing/win10/WinEventsWin10.h index ec08d97cbb..5c7d38c3cc 100644 --- a/xbmc/windowing/win10/WinEventsWin10.h +++ b/xbmc/windowing/win10/WinEventsWin10.h @@ -57,11 +57,14 @@ public: static void OnDisplayContentsInvalidated(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); // system static void OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args); + // system media handlers + static void OnSystemMediaButtonPressed(Windows::Media::SystemMediaTransportControls^, Windows::Media::SystemMediaTransportControlsButtonPressedEventArgs^); private: void UpdateWindowSize(); void Kodi_KeyEvent(unsigned int vkey, unsigned scancode, unsigned keycode, bool isDown); Concurrency::concurrent_queue<XBMC_Event> m_events; + Windows::Media::SystemMediaTransportControls^ m_smtc{ nullptr }; }; #endif // WINDOW_EVENTS_WIN10_H |