Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[python] added missing OnPlayBack* events to python

  • Loading branch information...
commit 0ea2bdcf4ac81773f505e8bfb5bd9891b851f5d0 1 parent 65a2b34
Scott Johns nuka1195 authored
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);
31 xbmc/interfaces/python/xbmcmodule/PythonPlayer.cpp
View
@@ -130,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__},
Please sign in to comment.
Something went wrong with that request. Please try again.