⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 npolibvlc.cpp

📁 VLC Player Source Code
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_playItem:                if( (argCount == 1) && isNumberValue(args[0]) )                {                    libvlc_playlist_play(p_plugin->getVLC(), numberValue(args[0]), 0, NULL, &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_togglepause:                if( argCount == 0 )                {                    libvlc_playlist_pause(p_plugin->getVLC(), &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_stop:                if( argCount == 0 )                {                    libvlc_playlist_stop(p_plugin->getVLC(), &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_next:                if( argCount == 0 )                {                    libvlc_playlist_next(p_plugin->getVLC(), &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_prev:                if( argCount == 0 )                {                    libvlc_playlist_prev(p_plugin->getVLC(), &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_clear: /* deprecated */                if( argCount == 0 )                {                    libvlc_playlist_clear(p_plugin->getVLC(), &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            case ID_playlist_removeitem: /* deprecated */                if( (argCount == 1) && isNumberValue(args[0]) )                {                    libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex);                    if( libvlc_exception_raised(&ex) )                    {                        NPN_SetException(this, libvlc_exception_get_message(&ex));                        libvlc_exception_clear(&ex);                        return INVOKERESULT_GENERIC_ERROR;                    }                    else                    {                        VOID_TO_NPVARIANT(result);                        return INVOKERESULT_NO_ERROR;                    }                }                return INVOKERESULT_NO_SUCH_METHOD;            default:                ;        }    }    return INVOKERESULT_GENERIC_ERROR;}void LibvlcPlaylistNPObject::parseOptions(const NPString &nps, int *i_options, char*** ppsz_options){    if( nps.utf8length )    {        char *s = stringValue(nps);        char *val = s;        if( val )        {            long capacity = 16;            char **options = (char **)malloc(capacity*sizeof(char *));            if( options )            {                int nOptions = 0;                char *end = val + nps.utf8length;                while( val < end )                {                    // skip leading blanks                    while( (val < end)                        && ((*val == ' ' ) || (*val == '\t')) )                        ++val;                    char *start = val;                    // skip till we get a blank character                    while( (val < end)                        && (*val != ' ' )                        && (*val != '\t') )                    {                        char c = *(val++);                        if( ('\'' == c) || ('"' == c) )                        {                            // skip till end of string                            while( (val < end) && (*(val++) != c ) );                        }                    }                    if( val > start )                    {                        if( nOptions == capacity )                        {                            capacity += 16;                            char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));                             if( ! moreOptions )                            {                                /* failed to allocate more memory */                                delete s;                                /* return what we got so far */                                *i_options = nOptions;                                *ppsz_options = options;                                return;                            }                            options = moreOptions;                        }                        *(val++) = '\0';                        options[nOptions++] = strdup(start);                    }                    else                        // must be end of string                        break;                }                *i_options = nOptions;                *ppsz_options = options;            }            delete s;        }    }}void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options, char*** ppsz_options){    /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */    NPVariant value;    /* we are expecting to have a Javascript Array object */    NPIdentifier propId = NPN_GetStringIdentifier("length");    if( NPN_GetProperty(_instance, obj, propId, &value) )    {        int count = numberValue(value);        NPN_ReleaseVariantValue(&value);        if( count )        {            long capacity = 16;            char **options = (char **)malloc(capacity*sizeof(char *));            if( options )            {                int nOptions = 0;                while( nOptions < count )                {                    propId = NPN_GetIntIdentifier(nOptions);                    if( ! NPN_GetProperty(_instance, obj, propId, &value) )                        /* return what we got so far */                        break;                    if( ! NPVARIANT_IS_STRING(value) )                    {                        /* return what we got so far */                        NPN_ReleaseVariantValue(&value);                        break;                    }                    if( nOptions == capacity )                    {                        capacity += 16;                        char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));                         if( ! moreOptions )                        {                            /* failed to allocate more memory */                            NPN_ReleaseVariantValue(&value);                            /* return what we got so far */                            *i_options = nOptions;                            *ppsz_options = options;                            break;                        }                        options = moreOptions;                    }                    options[nOptions++] = stringValue(value);                }                *i_options = nOptions;                *ppsz_options = options;            }        }    }}/*** implementation of libvlc video object*/const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = {    "fullscreen",    "height",    "width",    "aspectRatio",    "subtitle",    "crop",    "teletext"};enum LibvlcVideoNPObjectPropertyIds{    ID_video_fullscreen,    ID_video_height,    ID_video_width,    ID_video_aspectratio,    ID_video_subtitle,    ID_video_crop,    ID_video_teletext};const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVariant &result){    /* is plugin still running */    if( _instance->pdata )    {        VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);        libvlc_exception_t ex;        libvlc_exception_init(&ex);        libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);        if( libvlc_exception_raised(&ex) )        {            NPN_SetException(this, libvlc_exception_get_message(&ex));            libvlc_exception_clear(&ex);            return INVOKERESULT_GENERIC_ERROR;        }        switch( index )        {            case ID_video_fullscreen:            {                int val = libvlc_get_fullscreen(p_md, &ex);                libvlc_media_player_release(p_md);                if( libvlc_exception_raised(&ex) )                {                    NPN_SetException(this, libvlc_exception_get_message(&ex));                    libvlc_exception_clear(&ex);                    return INVOKERESULT_GENERIC_ERROR;                }                BOOLEAN_TO_NPVARIANT(val, result);                return INVOKERESULT_NO_ERROR;            }            case ID_video_height:            {                int val = libvlc_video_get_height(p_md, &ex);                libvlc_media_player_release(p_md);                if( libvlc_exception_raised(&ex) )                {                    NPN_SetException(this, libvlc_exception_get_message(&ex));                    libvlc_exception_clear(&ex);                    return INVOKERESULT_GENERIC_ERROR;                }                INT32_TO_NPVARIANT(val, result);                return INVOKERESULT_NO_ERROR;            }            case ID_video_width:            {                int val = libvlc_video_get_width(p_md, &ex);                libvlc_media_player_release(p_md);                if( libvlc_exception_raised(&ex) )                {                    NPN_SetException(this, libvlc_exception_get_message(&ex));                    libvlc_exception_clear(&ex);                    return INVOKERESULT_GENERIC_ERROR;                }                INT32_TO_NPVARIANT(val, result);                return INVOKERESULT_NO_ERROR;            }            case ID_video_aspectratio:            {                NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);                libvlc_media_player_release(p_md);                if( libvlc_exception_raised(&ex) )                {                    NPN_SetException(this, libvlc_exception_get_message(&ex));                    libvlc_exception_clear(&ex);                    return INVOKERESULT_GENERIC_ERROR;                }                if( !psz_aspect )                    return INVOKERESULT_GENERIC_ERROR;                STRINGZ_TO_NPVARIANT(psz_aspect, result);                return INVOKERESULT_NO_ERROR;            }            case ID_video_subtitle:            {                int i_spu = libvlc_video_get_spu(p_md, &ex);                libvlc_media_player_release(p_md);                if( libvlc_exception_raised(&ex) )                {                    NPN_SetException(this, libvlc_exception_get_message(&ex));                    libvlc_exception_clear(&ex);                    return INVOKERESULT_GENERIC_ERROR;                }                INT32_TO_NPVARIANT(i_spu, result);                return INVOKERESULT_NO_ERROR;            }            case ID_video_crop:            {                NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);                libvlc_media_player_release(p_md);                if( libvlc_exception_raised(&ex) )                {                    NPN_SetException(this, libvlc_exception_get_message(&ex));                    libvlc_exception_clear(&ex)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -