Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[win10] make the uwp app working in background and handles media butt… #13388

Merged
merged 1 commit into from Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion tools/windows/packaging/uwp/package.appxmanifest.in
Expand Up @@ -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" />
Expand Down Expand Up @@ -234,5 +235,6 @@
<uap:Capability Name="removableStorage" />
<uap:Capability Name="userAccountInformation" />
<uap:Capability Name="videosLibrary" />
<uap3:Capability Name="backgroundMediaPlayback" />
</Capabilities>
</Package>
55 changes: 55 additions & 0 deletions xbmc/windowing/win10/WinEventsWin10.cpp
Expand Up @@ -31,13 +31,15 @@
#include "utils/log.h"
#include "utils/SystemInfo.h"
#include "windowing/windows/WinKeyMap.h"
#include "xbmc/GUIUserMessages.h"
#include "WinEventsWin10.h"

using namespace PERIPHERALS;
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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)));
}
}
3 changes: 3 additions & 0 deletions xbmc/windowing/win10/WinEventsWin10.h
Expand Up @@ -57,11 +57,14 @@ class CWinEventsWin10 : public IWinEvents
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