📄 vlcglue.c
字号:
{ mediacontrol_Exception* exception = NULL; unsigned short volume; if( !PyArg_ParseTuple( args, "H", &volume ) ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_sound_set_volume( SELF->mc, volume, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject*MediaControl_sound_get_volume( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; PyObject *py_retval; unsigned short volume; Py_BEGIN_ALLOW_THREADS MC_TRY; volume = mediacontrol_sound_get_volume( SELF->mc, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; py_retval = Py_BuildValue( "H", volume ); return py_retval;}static PyObject*MediaControl_set_rate( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; int rate; if( !PyArg_ParseTuple( args, "i", &rate ) ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_set_rate( SELF->mc, rate, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject*MediaControl_get_rate( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; PyObject *py_retval; int rate; Py_BEGIN_ALLOW_THREADS MC_TRY; rate = mediacontrol_get_rate( SELF->mc, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; py_retval = Py_BuildValue( "i", rate ); return py_retval;}static PyObject*MediaControl_set_fullscreen( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; int fs; if( !PyArg_ParseTuple( args, "i", &fs ) ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_set_fullscreen( SELF->mc, fs, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject*MediaControl_get_fullscreen( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; PyObject *py_retval; int fs; Py_BEGIN_ALLOW_THREADS MC_TRY; fs = mediacontrol_get_fullscreen( SELF->mc, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; py_retval = Py_BuildValue( "i", fs ); return py_retval;}static PyObject*MediaControl_set_visual( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; WINDOWHANDLE visual; if( !PyArg_ParseTuple( args, "i", &visual ) ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_set_visual( SELF->mc, visual, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyMethodDef MediaControl_methods[] ={ {"get_media_position", MediaControl_get_media_position, METH_VARARGS, "get_media_position( origin, key ) -> Position Get current media position." }, { "set_media_position", MediaControl_set_media_position, METH_VARARGS, "set_media_position( Position ) Set media position" }, { "start", MediaControl_start, METH_VARARGS, "start( Position ) Start the player." }, { "pause", MediaControl_pause, METH_VARARGS, "pause( Position ) Pause the player." }, { "resume", MediaControl_resume, METH_VARARGS, "resume( Position ) Resume the player" }, { "stop", MediaControl_stop, METH_VARARGS, "stop( Position ) Stop the player" }, { "exit", MediaControl_exit, METH_VARARGS, "exit( ) Exit the player" }, { "playlist_add_item", MediaControl_playlist_add_item, METH_VARARGS, "playlist_add_item( str ) Add an item to the playlist" }, { "playlist_get_list", MediaControl_playlist_get_list, METH_VARARGS, "playlist_get_list( ) -> list Get the contents of the playlist" }, { "playlist_clear", MediaControl_playlist_clear, METH_VARARGS, "clear( ) Clear the playlist." }, { "snapshot", MediaControl_snapshot, METH_VARARGS, "snapshot( Position ) -> dict Take a snapshot" }, { "display_text", MediaControl_display_text, METH_VARARGS, "display_text( str, Position, Position ) Display a text on the video" }, { "get_stream_information", MediaControl_get_stream_information, METH_VARARGS, "get_stream_information( ) -> dict Get information about the stream"}, { "sound_get_volume", MediaControl_sound_get_volume, METH_VARARGS, "sound_get_volume( ) -> int Get the volume" }, { "sound_set_volume", MediaControl_sound_set_volume, METH_VARARGS, "sound_set_volume( int ) Set the volume" }, { "set_visual", MediaControl_set_visual, METH_VARARGS, "set_visual( int ) Set the embedding window visual ID" }, { "get_rate", MediaControl_get_rate, METH_VARARGS, "get_rate( ) -> int Get the rate" }, { "set_rate", MediaControl_set_rate, METH_VARARGS, "set_rate( int ) Set the rate" }, { "get_fullscreen", MediaControl_get_fullscreen, METH_VARARGS, "get_fullscreen( ) -> int Get the fullscreen status" }, { "set_fullscreen", MediaControl_set_fullscreen, METH_VARARGS, "set_fullscreen( int ) Set the fullscreen status" }, { NULL, NULL, 0, NULL },};static PyTypeObject MediaControl_Type ={ PyObject_HEAD_INIT( NULL ) 0, /*ob_size*/ "vlc.MediaControl", /*tp_name*/ sizeof( MediaControl_Type ), /*tp_basicsize*/ 0, /*tp_itemsize*/ ( destructor )MediaControl_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "Control of a VLC instance.", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ MediaControl_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ MediaControl_new, /* tp_new */};/*********************************************************************** * Position ***********************************************************************/static intPyPosition_init( PyPosition *self, PyObject *args, PyObject *kwds ){ self->origin = mediacontrol_AbsolutePosition; self->key = mediacontrol_MediaTime; self->value = 0; return 0;}mediacontrol_PositionKeypositionKey_py_to_c( PyObject * py_key ){ mediacontrol_PositionKey key_position = mediacontrol_MediaTime; int key; if( !PyArg_Parse( py_key, "i", &key ) ) { PyErr_SetString ( MediaControl_InternalException, "Invalid key value" ); return key_position; } switch ( key ) { case 0: key = mediacontrol_ByteCount; break; case 1: key = mediacontrol_SampleCount; break; case 2: key = mediacontrol_MediaTime; break; } return key_position;}mediacontrol_PositionOriginpositionOrigin_py_to_c( PyObject * py_origin ){ mediacontrol_PositionOrigin origin_position = mediacontrol_AbsolutePosition; int origin; if( !PyArg_Parse( py_origin,"i", &origin ) ) { PyErr_SetString( MediaControl_InternalException, "Invalid origin value" ); return origin_position; } switch ( origin ) { case 0: origin_position = mediacontrol_AbsolutePosition; break; case 1: origin_position = mediacontrol_RelativePosition; break; case 2: origin_position = mediacontrol_ModuloPosition; break; } return origin_position;}/* Methods for transforming the Position Python object to Position structure*/mediacontrol_Position*position_py_to_c( PyObject * py_position ){ mediacontrol_Position * a_position = NULL; PyPosition *pos = ( PyPosition* )py_position; a_position = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) ); if( !a_position ) { PyErr_SetString( PyExc_MemoryError, "Out of memory" ); return NULL; } if( !py_position ) { /* If we give a NULL value, it will be considered as a 0 relative position in mediatime */ a_position->origin = mediacontrol_RelativePosition; a_position->key = mediacontrol_MediaTime; a_position->value = 0; } else if( PyObject_IsInstance( py_position, ( PyObject* )&PyPosition_Type ) ) { a_position->origin = pos->origin; a_position->key = pos->key; a_position->value = ntohll(pos->value); } else { /* Feature: if we give an integer, it will be considered as a relative position in mediatime */ a_position->origin = mediacontrol_RelativePosition; a_position->key = mediacontrol_MediaTime; a_position->value = PyLong_AsLongLong( py_position ); } return a_position;}PyPosition*position_c_to_py( mediacontrol_Position *position ){ PyPosition* py_retval; py_retval = PyObject_New( PyPosition, &PyPosition_Type ); py_retval->origin = position->origin; py_retval->key = position->key; py_retval->value = position->value; return py_retval;}static PyMethodDef PyPosition_methods[] ={ { NULL } /* Sentinel */};static PyMemberDef PyPosition_members[] ={ { "origin", T_INT, offsetof( PyPosition, origin ), 0, "Position origin" }, { "key", T_INT, offsetof( PyPosition, key ), 0, "Position key" }, { "value", T_ULONG, offsetof( PyPosition, value ), 0, "Position value" }, { NULL } /* Sentinel */};static PyTypeObject PyPosition_Type ={ PyObject_HEAD_INIT( NULL ) 0, /*ob_size*/ "vlc.Position", /*tp_name*/ sizeof( PyPosition_Type ), /*tp_basicsize*/ 0, /*tp_itemsize*/ 0, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "Represent a Position with origin, key and value", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ PyPosition_methods, /* tp_methods */ PyPosition_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ ( initproc )PyPosition_init, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -