Skip to content

Commit

Permalink
sys: add action "switchplayer" that allows switch of forced player
Browse files Browse the repository at this point in the history
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
elupus committed Jan 20, 2013
1 parent 859ab5f commit c945aab
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions system/keymaps/keyboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
30 changes: 30 additions & 0 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions xbmc/cores/playercorefactory/PlayerCoreFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/playercorefactory/PlayerCoreFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions xbmc/guilib/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions xbmc/input/ButtonTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit c945aab

Please sign in to comment.