diff options
author | amet <amet.nospam@gmail.com> | 2011-01-11 00:52:54 +0400 |
---|---|---|
committer | amet <amet.nospam@gmail.com> | 2011-01-11 01:08:31 +0400 |
commit | fba3a7dec03b898a114320adf97c201e97e4503e (patch) | |
tree | c751a834d70065b3a11f4dc64fa07d7e4187aef0 | |
parent | f080498e604619bf43d93597e5c89ae97e5f8f15 (diff) |
added: xbmc.Player().getAvailableAudioStreams() and xbmc.Player().setAudioStream()
usage:
- xbmc.Player().getAvailableAudioStreams() returns a language list of all available audio streams for the currently playing movie. e.g ['Italian', 'English', 'German']
- xbmc.Player().setAudioStream(1) sets Audio stream to 'English'
-rw-r--r-- | xbmc/cores/IPlayer.h | 1 | ||||
-rw-r--r-- | xbmc/lib/libPython/xbmcmodule/player.cpp | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/xbmc/cores/IPlayer.h b/xbmc/cores/IPlayer.h index 629e260ae0..03975f51eb 100644 --- a/xbmc/cores/IPlayer.h +++ b/xbmc/cores/IPlayer.h @@ -116,6 +116,7 @@ public: virtual int GetAudioStream() { return -1; } virtual void GetAudioStreamName(int iStream, CStdString &strStreamName){}; virtual void SetAudioStream(int iStream){}; + virtual void GetAudioStreamLanguage(int iStream, CStdString &strLanguage){}; virtual TextCacheStruct_t* GetTeletextCache() { return NULL; }; virtual void LoadPage(int p, int sp, unsigned char* buffer) {}; diff --git a/xbmc/lib/libPython/xbmcmodule/player.cpp b/xbmc/lib/libPython/xbmcmodule/player.cpp index 3c8694462e..5a2cb09fc8 100644 --- a/xbmc/lib/libPython/xbmcmodule/player.cpp +++ b/xbmc/lib/libPython/xbmcmodule/player.cpp @@ -30,6 +30,7 @@ #include "listitem.h" #include "FileItem.h" #include "Settings.h" +#include "LangCodeExpander.h" using namespace MUSIC_INFO; @@ -539,6 +540,55 @@ namespace PYXBMC return NULL; } + // Player_getAvailableAudioStreams + PyDoc_STRVAR(getAvailableAudioStreams__doc__, + "getAvailableAudioStreams() -- get Audio stream names\n"); + + PyObject* Player_getAvailableAudioStreams(PyObject *self) + { + if (g_application.m_pPlayer) + { + PyObject *list = PyList_New(0); + for (int iStream=0; iStream < g_application.m_pPlayer->GetAudioStreamCount(); iStream++) + { + CStdString strName; + CStdString FullLang; + g_application.m_pPlayer->GetAudioStreamLanguage(iStream, strName); + g_LangCodeExpander.Lookup(FullLang, strName); + PyList_Append(list, Py_BuildValue("s", FullLang.c_str())); + } + return list; + } + + Py_INCREF(Py_None); + return Py_None; + } + + // Player_setAudioStream + PyDoc_STRVAR(setAudioStream__doc__, + "setAudioStream(stream) -- set Audio Stream \n" + "\n" + "stream : int\n" + "\n" + "example:\n" + " - setAudioStream(1)\n"); + + PyObject* Player_setAudioStream(PyObject *self, PyObject *args) + { + int iStream; + if (!PyArg_ParseTuple(args, (char*)"i", &iStream)) return NULL; + + if (g_application.m_pPlayer) + { + int streamCount = g_application.m_pPlayer->GetAudioStreamCount(); + if(iStream <= streamCount) + g_application.m_pPlayer->SetAudioStream(iStream); + } + + Py_INCREF(Py_None); + return Py_None; + } + PyMethodDef Player_methods[] = { {(char*)"play", (PyCFunction)Player_Play, METH_VARARGS|METH_KEYWORDS, play__doc__}, {(char*)"stop", (PyCFunction)pyPlayer_Stop, METH_VARARGS, stop__doc__}, @@ -563,6 +613,8 @@ namespace PYXBMC {(char*)"setSubtitles", (PyCFunction)Player_SetSubtitles, METH_VARARGS, setSubtitles__doc__}, {(char*)"getSubtitles", (PyCFunction)Player_GetSubtitles, METH_NOARGS, getSubtitles__doc__}, {(char*)"disableSubtitles", (PyCFunction)Player_DisableSubtitles, METH_NOARGS, DisableSubtitles__doc__}, + {(char*)"getAvailableAudioStreams", (PyCFunction)Player_getAvailableAudioStreams, METH_NOARGS, getAvailableAudioStreams__doc__}, + {(char*)"setAudioStream", (PyCFunction)Player_setAudioStream, METH_VARARGS, setAudioStream__doc__}, {NULL, NULL, 0, NULL} }; |