📄 vlcglue.c
字号:
ppsz_args[i_index] = strdup( PyString_AsString( PyObject_Str( PySequence_GetItem( py_list, i_index ) ) ) ); } ppsz_args[i_size] = NULL; Py_DECREF( py_list ); } else { /* No arguments were given. Clear the exception raised by PyArg_ParseTuple. */ PyErr_Clear( ); } Py_BEGIN_ALLOW_THREADS MC_TRY; self->mc = mediacontrol_new( ppsz_args, exception ); MC_EXCEPT; Py_END_ALLOW_THREADS Py_INCREF( self ); return ( PyObject * )self;}static voidMediaControl_dealloc( PyObject *self ){ PyMem_DEL( self );}/** * Return the current position in the stream. The returned value can be relative or absolute ( according to PositionOrigin ) and the unit is set by PositionKey */static PyObject *MediaControl_get_media_position( PyObject *self, PyObject *args ){ mediacontrol_Position* pos; mediacontrol_Exception* exception = NULL; PyObject *py_origin; PyObject *py_key; PyObject *py_retval; mediacontrol_PositionOrigin origin; mediacontrol_PositionKey key; if( !PyArg_ParseTuple( args, "OO", &py_origin, &py_key ) ) return NULL; origin = positionOrigin_py_to_c( py_origin ); key = positionKey_py_to_c( py_key ); Py_BEGIN_ALLOW_THREADS MC_TRY; pos = mediacontrol_get_media_position( SELF->mc, origin, key, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; py_retval = ( PyObject* )position_c_to_py( pos ); free( pos ); return py_retval;}/** Set the media position */static PyObject *MediaControl_set_media_position( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; mediacontrol_Position *a_position; PyObject *py_pos; if( !PyArg_ParseTuple( args, "O", &py_pos ) ) return NULL; a_position = position_py_to_c( py_pos ); if( !a_position ) { PyErr_SetString( PyExc_MemoryError, "Out of memory" ); return NULL; } Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_set_media_position( SELF->mc, a_position, exception ); free( a_position ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_start( PyObject *self, PyObject *args ){ mediacontrol_Position *a_position; mediacontrol_Exception *exception = NULL; PyObject *py_pos; if( !PyArg_ParseTuple( args, "O", &py_pos ) ) { /* No argument. Use a default 0 value. */ PyErr_Clear( ); py_pos = NULL; } a_position = position_py_to_c( py_pos ); if( !a_position ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_start( SELF->mc, a_position, exception ); free( a_position ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_pause( PyObject *self, PyObject *args ){ mediacontrol_Position *a_position; mediacontrol_Exception *exception = NULL; PyObject *py_pos; if( !PyArg_ParseTuple( args, "O", &py_pos ) ) { /* No argument. Use a default 0 value. */ PyErr_Clear( ); py_pos = NULL; } a_position = position_py_to_c( py_pos ); if( !a_position ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_pause( SELF->mc, a_position, exception ); free( a_position ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_resume( PyObject *self, PyObject *args ){ mediacontrol_Position *a_position; mediacontrol_Exception *exception = NULL; PyObject *py_pos; if( !PyArg_ParseTuple( args, "O", &py_pos ) ) { /* No argument. Use a default 0 value. */ PyErr_Clear( ); py_pos = NULL; } a_position = position_py_to_c( py_pos ); if( !a_position ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_start( SELF->mc, a_position, exception ); free( a_position ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_stop( PyObject *self, PyObject *args ){ mediacontrol_Position *a_position; mediacontrol_Exception *exception = NULL; PyObject *py_pos; if( !PyArg_ParseTuple( args, "O", &py_pos ) ) { /* No argument. Use a default 0 value. */ PyErr_Clear( ); py_pos = NULL; } a_position = position_py_to_c( py_pos ); if( !a_position ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_stop( SELF->mc, a_position, exception ); free( a_position ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_exit( PyObject *self, PyObject *args ){ mediacontrol_exit( SELF->mc ); Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_playlist_add_item( PyObject *self, PyObject *args ){ char *psz_file; mediacontrol_Exception *exception = NULL; if( !PyArg_ParseTuple( args, "s", &psz_file ) ) return NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_playlist_add_item( SELF->mc, psz_file, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_playlist_clear( PyObject *self, PyObject *args ){ mediacontrol_Exception *exception = NULL; Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_playlist_clear( SELF->mc, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; Py_INCREF( Py_None ); return Py_None;}static PyObject *MediaControl_playlist_get_list( PyObject *self, PyObject *args ){ PyObject *py_retval; mediacontrol_Exception *exception = NULL; mediacontrol_PlaylistSeq* pl; int i_index; int i_playlist_size; Py_BEGIN_ALLOW_THREADS MC_TRY; pl = mediacontrol_playlist_get_list( SELF->mc, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; i_playlist_size = pl->size; py_retval = PyList_New( i_playlist_size ); for ( i_index = 0 ; i_index < i_playlist_size ; i_index++ ) { PyList_SetItem( py_retval, i_index, Py_BuildValue( "s", pl->data[i_index] ) ); } mediacontrol_PlaylistSeq__free( pl ); return py_retval;}static PyObject *MediaControl_snapshot( PyObject *self, PyObject *args ){ mediacontrol_RGBPicture *p_retval = NULL; mediacontrol_Exception* exception = NULL; mediacontrol_Position *a_position = NULL; PyObject *py_pos = NULL; PyObject *py_obj = NULL; if( !PyArg_ParseTuple( args, "O", &py_pos ) ) return NULL; a_position = position_py_to_c( py_pos ); Py_BEGIN_ALLOW_THREADS MC_TRY; p_retval = mediacontrol_snapshot( SELF->mc, a_position, exception ); free( a_position ); Py_END_ALLOW_THREADS MC_EXCEPT; if( !p_retval ) { Py_INCREF( Py_None ); return Py_None; } /* FIXME: create a real RGBPicture object */ py_obj = PyDict_New(); PyDict_SetItemString( py_obj, "width", Py_BuildValue( "i", p_retval->width ) ); PyDict_SetItemString( py_obj, "height", Py_BuildValue( "i", p_retval->height ) ); PyDict_SetItemString( py_obj, "type", Py_BuildValue( "i", p_retval->type ) ); PyDict_SetItemString( py_obj, "data", Py_BuildValue( "s#", p_retval->data, p_retval->size ) ); PyDict_SetItemString( py_obj, "date", Py_BuildValue( "L", p_retval->date ) ); return py_obj;}static PyObject*MediaControl_display_text( PyObject *self, PyObject *args ){ mediacontrol_Exception* exception = NULL; PyObject *py_begin, *py_end; char* message; mediacontrol_Position * begin; mediacontrol_Position * end; if( !PyArg_ParseTuple( args, "sOO", &message, &py_begin, &py_end ) ) return NULL; begin = position_py_to_c( py_begin ); end = position_py_to_c( py_end ); Py_BEGIN_ALLOW_THREADS MC_TRY; mediacontrol_display_text( SELF->mc, message, begin, end, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; free( begin ); free( end ); Py_INCREF( Py_None ); return Py_None;}static PyObject*MediaControl_get_stream_information( PyObject *self, PyObject *args ){ mediacontrol_StreamInformation *retval = NULL; mediacontrol_Exception* exception = NULL; PyObject *py_obj; Py_BEGIN_ALLOW_THREADS MC_TRY; retval = mediacontrol_get_stream_information( SELF->mc, mediacontrol_MediaTime, exception ); Py_END_ALLOW_THREADS MC_EXCEPT; py_obj = PyDict_New( ); /* FIXME: create a real StreamInformation object */ PyDict_SetItemString( py_obj, "status", Py_BuildValue( "i", retval->streamstatus ) ); PyDict_SetItemString( py_obj, "url", Py_BuildValue( "s", retval->url ) ); PyDict_SetItemString( py_obj, "position", Py_BuildValue( "L", retval->position ) ); PyDict_SetItemString( py_obj, "length", Py_BuildValue( "L", retval->length ) ); free( retval->url ); free( retval ); return py_obj;}static PyObject*MediaControl_sound_set_volume( PyObject *self, PyObject *args )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -