Skip to content
Browse files

sys: add action "switchplayer" that allows switch of forced player

This allow moving a playing item to a another player (remote upnp
for example) and attaching to a remote upnp player already playing

It's hooked up to "y" on keyboard currently.

squash into switching
  • Loading branch information...
1 parent 859ab5f commit c945aab0dcef207dc4eb3542089186b1cecca643 @elupus elupus committed
View
1 system/keymaps/keyboard.xml
@@ -41,6 +41,7 @@
<q>Queue</q>
<f>FastForward</f>
<r>Rewind</r>
+ <y>SwitchPlayer</y>
<left>Left</left>
<right>Right</right>
<up>Up</up>
View
30 xbmc/Application.cpp
@@ -2847,6 +2847,36 @@ bool CApplication::OnAction(const CAction &action)
}
}
+
+ if (action.GetID() == ACTION_SWITCH_PLAYER)
+ {
+ if(IsPlaying())
+ {
+ VECPLAYERCORES cores;
+ CFileItem item(*m_itemCurrentFile.get());
+ CPlayerCoreFactory::GetPlayers(item, cores);
+ PLAYERCOREID core = CPlayerCoreFactory::SelectPlayerDialog(cores);
+ if(core != EPC_NONE)
+ {
+ g_application.m_eForcedNextPlayer = core;
+ item.m_lStartOffset = GetTime() * 75;
+ PlayFile(item, true);
+ }
+ }
+ else
+ {
+ VECPLAYERCORES cores;
+ CPlayerCoreFactory::GetRemotePlayers(cores);
+ PLAYERCOREID core = CPlayerCoreFactory::SelectPlayerDialog(cores);
+ if(core != EPC_NONE)
+ {
+ CFileItem item;
+ g_application.m_eForcedNextPlayer = core;
+ PlayFile(item, false);
+ }
+ }
+ }
+
if (g_peripherals.OnAction(action))
return true;
View
11 xbmc/cores/playercorefactory/PlayerCoreFactory.cpp
@@ -232,6 +232,17 @@ void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecC
CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: added %"PRIuS" players", vecCores.size());
}
+void CPlayerCoreFactory::GetRemotePlayers( VECPLAYERCORES &vecCores )
+{
+ CSingleLock lock(s_section);
+ for(unsigned int i = 0; i < s_vecCoreConfigs.size(); i++)
+ {
+ if(s_vecCoreConfigs[i]->m_eCore != EPC_UPNPPLAYER)
+ continue;
+ vecCores.push_back(i+1);
+ }
+}
+
PLAYERCOREID CPlayerCoreFactory::GetDefaultPlayer( const CFileItem& item )
{
VECPLAYERCORES vecCores;
View
2 xbmc/cores/playercorefactory/PlayerCoreFactory.h
@@ -76,6 +76,8 @@ class CPlayerCoreFactory
static void GetPlayers( VECPLAYERCORES &vecCores, bool audio, bool video ); //All audio players and/or video players
static void GetPlayers( VECPLAYERCORES &vecCores ); //All players
+ static void GetRemotePlayers( VECPLAYERCORES &vecCores ); //All remote players we can attach to
+
static PLAYERCOREID GetDefaultPlayer( const CFileItem& item );
static PLAYERCOREID SelectPlayerDialog(VECPLAYERCORES &vecCores, float posX = 0, float posY = 0);
View
2 xbmc/guilib/Key.h
@@ -315,6 +315,8 @@
#define ACTION_FILTER 233
+#define ACTION_SWITCH_PLAYER 234
+
// Window ID defines to make the code a bit more readable
#define WINDOW_INVALID 9999
#define WINDOW_HOME 10000
View
1 xbmc/input/ButtonTranslator.cpp
@@ -142,6 +142,7 @@ static const ActionMapping actions[] =
{"rewind" , ACTION_PLAYER_REWIND},
{"play" , ACTION_PLAYER_PLAY},
{"playpause" , ACTION_PLAYER_PLAYPAUSE},
+ {"switchplayer" , ACTION_SWITCH_PLAYER},
{"delete" , ACTION_DELETE_ITEM},
{"copy" , ACTION_COPY_ITEM},
{"move" , ACTION_MOVE_ITEM},

0 comments on commit c945aab

Please sign in to comment.
Something went wrong with that request. Please try again.