Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[python] added missing onPlayback* events to python #1001

Merged
merged 2 commits into from

4 participants

Scott Johns jmarshallnz Martijn Kaijser Sascha Montellese
Scott Johns

[python] added support for params in SPyEvent(_Function)

is push one to add the missing onPlayback* events to python. replaces #994.

thanks @jmarshallnz, but i think it was hopeless to correct my other branch.

jmarshallnz
Owner

Is the other commit coming as well?

Scott Johns

Shortly

Scott Johns

shall we leave the other changes for another time and close #994

jmarshallnz
Owner

Sure - changes look fine. Will assign to the June window.

jmarshallnz jmarshallnz was assigned
Scott Johns

thanks for your effort and thanks for the code snippets you supplied.

xbmc/interfaces/python/xbmcmodule/PythonPlayer.cpp
@@ -29,12 +29,12 @@
struct SPyEvent
{
- SPyEvent(CPythonPlayer* player
- , const char* function)
+ SPyEvent(CPythonPlayer *player, const char *function, std::vector<int> &params=std::vector<int>())
Sascha Montellese Owner

Any reason for the params parameter being a reference and not a const reference?

no good reason. will up the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
jmarshallnz
Owner

Mind squashing the fixup commit into 4b0b760. With that done I'm happy to pull it in.

Scott Johns

My Internet is flaking, so I'm on my phone, but what is squashing. I get a not valid Git command and nothing in help.

Martijn Kaijser

combining two or more commits into one commit.
search for "git squash" to get more info

jmarshallnz
Owner

git rebase -i HEAD~5.

Rearrange commits so the one you want to squash is just after the one you want to squash into, then mark it as a fixup (f) or as squash (s).

Scott Johns

Ok I think I have it rebased correctly, but no Internet on the computer will try in the next day or so.

Scott Johns

well i don't know. i think i messed it up again.

jmarshallnz
Owner

You merged (or pulled) instead of rebasing.

From your python_onPlaybackEvents branch, rebase onto your master branch (which I assume is virgin from xbmc's master - if not, rebase on origin/master or whatever your upstream branch is).

git rebase master

That should get rid of the merge commits etc.

The key when maintaining feature branches is to never pull in changes from master unless you have to (you didn't here as far as I can tell), and then, it's preferable to rebase on master instead of merging.

Scott Johns

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

jmarshallnz
Owner

If you're sure your local branch is correct, git push -f to force push it up.

Scott Johns nuka1195 [python] added support for params in SPyEvent(_Function)
fixup!
changed SPyEvent function params to a const vector
65a2b34
Scott Johns

well i think i lost all the other commits. will have to do this later, but i think the function is correct now.

Scott Johns

65a2b34 and 0ea2bdc is what you want.

jmarshallnz
Owner

Cheers - looks good.

jmarshallnz jmarshallnz merged commit 0f2f1de into from
Tobias Hieta tru referenced this pull request from a commit in plexinc/plex-home-theater-public
Tobias Hieta tru Fix dim screensaver when playing movies.
Fixes #1001
a89709f
Tobias Hieta tru referenced this pull request from a commit in RasPlex/plex-home-theatre
Tobias Hieta tru Fix dim screensaver when playing movies.
Fixes #1001
c563dbb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 3, 2012
  1. Scott Johns

    [python] added support for params in SPyEvent(_Function)

    nuka1195 authored
    fixup!
    changed SPyEvent function params to a const vector
Commits on Jun 4, 2012
  1. Scott Johns
This page is out of date. Refresh to see the latest.
60 xbmc/interfaces/python/XBPython.cpp
View
@@ -181,6 +181,66 @@ void XBPython::OnPlayBackStopped()
}
}
+// message all registered callbacks that playback speed changed (FF/RW)
+void XBPython::OnPlayBackSpeedChanged(int iSpeed)
+{
+ CSingleLock lock(m_critSection);
+ if (m_bInitialized)
+ {
+ PlayerCallbackList::iterator it = m_vecPlayerCallbackList.begin();
+ while (it != m_vecPlayerCallbackList.end())
+ {
+ ((IPlayerCallback*)(*it))->OnPlayBackSpeedChanged(iSpeed);
+ it++;
+ }
+ }
+}
+
+// message all registered callbacks that player is seeking
+void XBPython::OnPlayBackSeek(int iTime, int seekOffset)
+{
+ CSingleLock lock(m_critSection);
+ if (m_bInitialized)
+ {
+ PlayerCallbackList::iterator it = m_vecPlayerCallbackList.begin();
+ while (it != m_vecPlayerCallbackList.end())
+ {
+ ((IPlayerCallback*)(*it))->OnPlayBackSeek(iTime, seekOffset);
+ it++;
+ }
+ }
+}
+
+// message all registered callbacks that player chapter seeked
+void XBPython::OnPlayBackSeekChapter(int iChapter)
+{
+ CSingleLock lock(m_critSection);
+ if (m_bInitialized)
+ {
+ PlayerCallbackList::iterator it = m_vecPlayerCallbackList.begin();
+ while (it != m_vecPlayerCallbackList.end())
+ {
+ ((IPlayerCallback*)(*it))->OnPlayBackSeekChapter(iChapter);
+ it++;
+ }
+ }
+}
+
+// message all registered callbacks that next item has been queued
+void XBPython::OnQueueNextItem()
+{
+ CSingleLock lock(m_critSection);
+ if (m_bInitialized)
+ {
+ PlayerCallbackList::iterator it = m_vecPlayerCallbackList.begin();
+ while (it != m_vecPlayerCallbackList.end())
+ {
+ ((IPlayerCallback*)(*it))->OnQueueNextItem();
+ it++;
+ }
+ }
+}
+
void XBPython::RegisterPythonPlayerCallBack(IPlayerCallback* pCallback)
{
CSingleLock lock(m_critSection);
6 xbmc/interfaces/python/XBPython.h
View
@@ -56,7 +56,11 @@ class XBPython :
virtual void OnPlayBackPaused();
virtual void OnPlayBackResumed();
virtual void OnPlayBackStopped();
- virtual void OnQueueNextItem() {};
+ virtual void OnPlayBackSpeedChanged(int iSpeed);
+ virtual void OnPlayBackSeek(int iTime, int seekOffset);
+ virtual void OnPlayBackSeekChapter(int iChapter);
+ virtual void OnQueueNextItem();
+
virtual void Announce(ANNOUNCEMENT::AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data);
void RegisterPythonPlayerCallBack(IPlayerCallback* pCallback);
void UnregisterPythonPlayerCallBack(IPlayerCallback* pCallback);
45 xbmc/interfaces/python/xbmcmodule/PythonPlayer.cpp
View
@@ -29,12 +29,12 @@ using namespace PYXBMC;
struct SPyEvent
{
- SPyEvent(CPythonPlayer* player
- , const char* function)
+ SPyEvent(CPythonPlayer *player, const char *function, const std::vector<int> &params=std::vector<int>())
{
m_player = player;
m_player->Acquire();
m_function = function;
+ m_params = params;
}
~SPyEvent()
@@ -44,6 +44,7 @@ struct SPyEvent
const char* m_function;
CPythonPlayer* m_player;
+ std::vector<int> m_params;
};
/*
@@ -55,7 +56,14 @@ static int SPyEvent_Function(void* e)
PyObject* ret = NULL;
if(object->m_player->m_callback)
- ret = PyObject_CallMethod(object->m_player->m_callback, (char*)object->m_function, NULL);
+ {
+ if (object->m_params.size() == 2)
+ ret = PyObject_CallMethod(object->m_player->m_callback, (char*)object->m_function, "ii", object->m_params[0], object->m_params[1]);
+ else if (object->m_params.size() == 1)
+ ret = PyObject_CallMethod(object->m_player->m_callback, (char*)object->m_function, "i", object->m_params[0]);
+ else
+ ret = PyObject_CallMethod(object->m_player->m_callback, (char*)object->m_function, NULL);
+ }
if(ret)
{
@@ -122,6 +130,37 @@ void CPythonPlayer::OnPlayBackResumed()
g_pythonParser.PulseGlobalEvent();
}
+void CPythonPlayer::OnPlayBackSpeedChanged(int iSpeed)
+{
+ std::vector<int> params;
+ params.push_back(iSpeed);
+ PyXBMC_AddPendingCall(m_state, SPyEvent_Function, new SPyEvent(this, "onPlayBackSpeedChanged", params));
+ g_pythonParser.PulseGlobalEvent();
+}
+
+void CPythonPlayer::OnPlayBackSeek(int iTime, int seekOffset)
+{
+ std::vector<int> params;
+ params.push_back(iTime);
+ params.push_back(seekOffset);
+ PyXBMC_AddPendingCall(m_state, SPyEvent_Function, new SPyEvent(this, "onPlayBackSeek", params));
+ g_pythonParser.PulseGlobalEvent();
+}
+
+void CPythonPlayer::OnPlayBackSeekChapter(int iChapter)
+{
+ std::vector<int> params;
+ params.push_back(iChapter);
+ PyXBMC_AddPendingCall(m_state, SPyEvent_Function, new SPyEvent(this, "onPlayBackSeekChapter", params));
+ g_pythonParser.PulseGlobalEvent();
+}
+
+void CPythonPlayer::OnQueueNextItem()
+{
+ PyXBMC_AddPendingCall(m_state, SPyEvent_Function, new SPyEvent(this, "onQueueNextItem"));
+ g_pythonParser.PulseGlobalEvent();
+}
+
void CPythonPlayer::SetCallback(PyThreadState *state, PyObject *object)
{
/* python lock should be held */
9 xbmc/interfaces/python/xbmcmodule/PythonPlayer.h
View
@@ -30,6 +30,10 @@ int Py_XBMC_Event_OnPlayBackEnded(void* arg);
int Py_XBMC_Event_OnPlayBackStopped(void* arg);
int Py_XBMC_Event_OnPlayBackPaused(void* arg);
int Py_XBMC_Event_OnPlayBackResumed(void* arg);
+int Py_XBMC_Event_OnPlayBackSpeedChanged(int iSpeed);
+int Py_XBMC_Event_OnPlayBackSeek(int iTime, int seekOffset);
+int Py_XBMC_Event_OnPlayBackSeekChapter(int iChapter);
+int Py_XBMC_Event_OnQueueNextItem(void* arg);
class CPythonPlayer : public IPlayerCallback
{
@@ -41,7 +45,10 @@ class CPythonPlayer : public IPlayerCallback
void OnPlayBackPaused();
void OnPlayBackResumed();
void OnPlayBackStopped();
- void OnQueueNextItem() {}; // unimplemented
+ void OnPlayBackSpeedChanged(int iSpeed);
+ void OnPlayBackSeek(int iTime, int seekOffset);
+ void OnPlayBackSeekChapter(int iChapter);
+ void OnQueueNextItem();
void Acquire();
void Release();
61 xbmc/interfaces/python/xbmcmodule/player.cpp
View
@@ -326,6 +326,63 @@ namespace PYXBMC
return Py_None;
}
+ // Player_OnPlayBackSpeedChanged(speed)
+ PyDoc_STRVAR(onPlayBackSpeedChanged__doc__,
+ "onPlayBackSpeedChanged(speed) -- onPlayBackSpeedChanged method.\n"
+ "\n"
+ "speed : integer - current speed of player.\n"
+ "\n"
+ "*Note, negative speed means player is rewinding, 1 is normal playback speed.\n"
+ "\n"
+ "Will be called when players speed changes. (eg. user FF/RW)");
+
+ PyObject* Player_OnPlayBackSpeedChanged(PyObject *self, PyObject *args)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ // Player_OnPlayBackSeek(time, seekOffset)
+ PyDoc_STRVAR(onPlayBackSeek__doc__,
+ "onPlayBackSeek(time, seekOffset) -- onPlayBackSeek method.\n"
+ "\n"
+ "time : integer - time to seek to.\n"
+ "seekOffset : integer - ?.\n"
+ "\n"
+ "Will be called when user seeks to a time");
+
+ PyObject* Player_OnPlayBackSeek(PyObject *self, PyObject *args)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ // Player_OnPlayBackSeekChapter(chapter)
+ PyDoc_STRVAR(onPlayBackSeekChapter__doc__,
+ "onPlayBackSeekChapter(chapter) -- onPlayBackSeekChapter method.\n"
+ "\n"
+ "chapter : integer - chapter to seek to.\n"
+ "\n"
+ "Will be called when user performs a chapter seek");
+
+ PyObject* Player_OnPlayBackSeekChapter(PyObject *self, PyObject *args)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ // Player_OnQueueNextItem()
+ PyDoc_STRVAR(onQueueNextItem__doc__,
+ "onQueueNextItem() -- onQueueNextItem method.\n"
+ "\n"
+ "Will be called when player requests next item");
+
+ PyObject* Player_OnQueueNextItem(PyObject *self, PyObject *args)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
// Player_IsPlaying
PyDoc_STRVAR(isPlaying__doc__,
"isPlaying() -- returns True is xbmc is playing a file.");
@@ -698,6 +755,10 @@ namespace PYXBMC
{(char*)"onPlayBackStopped", (PyCFunction)Player_OnPlayBackStopped, METH_VARARGS, onPlayBackStopped__doc__},
{(char*)"onPlayBackPaused", (PyCFunction)Player_OnPlayBackPaused, METH_VARARGS, onPlayBackPaused__doc__},
{(char*)"onPlayBackResumed", (PyCFunction)Player_OnPlayBackResumed, METH_VARARGS, onPlayBackResumed__doc__},
+ {(char*)"onPlayBackSpeedChanged", (PyCFunction)Player_OnPlayBackSpeedChanged, METH_VARARGS, onPlayBackSpeedChanged__doc__},
+ {(char*)"onPlayBackSeek", (PyCFunction)Player_OnPlayBackSeek, METH_VARARGS, onPlayBackSeek__doc__},
+ {(char*)"onPlayBackSeekChapter", (PyCFunction)Player_OnPlayBackSeekChapter, METH_VARARGS, onPlayBackSeekChapter__doc__},
+ {(char*)"onQueueNextItem", (PyCFunction)Player_OnQueueNextItem, METH_VARARGS, onQueueNextItem__doc__},
{(char*)"isPlaying", (PyCFunction)Player_IsPlaying, METH_VARARGS, isPlaying__doc__},
{(char*)"isPlayingAudio", (PyCFunction)Player_IsPlayingAudio, METH_VARARGS, isPlayingAudio__doc__},
{(char*)"isPlayingVideo", (PyCFunction)Player_IsPlayingVideo, METH_VARARGS, isPlayingVideo__doc__},
Something went wrong with that request. Please try again.