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

📄 vlcshell.cpp

📁 VLC Player Source Code
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);    if( NULL == p_plugin )        return NPERR_NO_ERROR;    instance->pdata = NULL;#if XP_WIN    HWND win = (HWND)p_plugin->getWindow().window;    WNDPROC winproc = p_plugin->getWindowProc();    if( winproc )    {        /* reset WNDPROC */        SetWindowLong( win, GWL_WNDPROC, (LONG)winproc );    }#endif    delete p_plugin;    return NPERR_NO_ERROR;}NPError NPP_SetWindow( NPP instance, NPWindow* window ){#if defined(XP_UNIX) && !defined(__APPLE__)    Window control;    unsigned int i_control_height = 0, i_control_width = 0;#endif    if( ! instance )    {        return NPERR_INVALID_INSTANCE_ERROR;    }    /* NPP_SetWindow may be called before NPP_New (Opera) */    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);    if( NULL == p_plugin )    {        /* we should probably show a splash screen here */        return NPERR_NO_ERROR;    }#if defined(XP_UNIX) && !defined(__APPLE__)    control = p_plugin->getControlWindow();#endif    libvlc_instance_t *p_vlc = p_plugin->getVLC();    /*     * PLUGIN DEVELOPERS:     *  Before setting window to point to the     *  new window, you may wish to compare the new window     *  info to the previous window (if any) to note window     *  size changes, etc.     */    /* retrieve current window */    NPWindow& curwin = p_plugin->getWindow();#ifdef XP_MACOSX    if( window && window->window )    {        /* check if plugin has a new parent window */        CGrafPtr drawable = (((NP_Port*) (window->window))->port);        if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )        {            /* set/change parent window */            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);        }        /* as MacOS X video output is windowless, set viewport */        libvlc_rectangle_t view, clip;        /*        ** browser sets port origin to top-left location of plugin        ** relative to GrafPort window origin is set relative to document,        ** which of little use for drawing        */        view.top     = ((NP_Port*) (window->window))->porty;        view.left    = ((NP_Port*) (window->window))->portx;        view.bottom  = window->height+view.top;        view.right   = window->width+view.left;        /* clipRect coordinates are also relative to GrafPort */        clip.top     = window->clipRect.top;        clip.left    = window->clipRect.left;        clip.bottom  = window->clipRect.bottom;        clip.right   = window->clipRect.right;        libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);        /* remember new window */        p_plugin->setWindow(*window);    }    else if( curwin.window ) {        /* change/set parent */        libvlc_video_set_parent(p_vlc, 0, NULL);        curwin.window = NULL;    }#endif /* XP_MACOSX */#ifdef XP_WIN    if( window && window->window )    {        /* check if plugin has a new parent window */        HWND drawable = (HWND) (window->window);        if( !curwin.window || drawable != curwin.window )        {            /* reset previous window settings */            HWND oldwin = (HWND)p_plugin->getWindow().window;            WNDPROC oldproc = p_plugin->getWindowProc();            if( oldproc )            {                /* reset WNDPROC */                SetWindowLong( oldwin, GWL_WNDPROC, (LONG)oldproc );            }            /* attach our plugin object */            SetWindowLongPtr((HWND)drawable, GWLP_USERDATA,                             reinterpret_cast<LONG_PTR>(p_plugin));            /* install our WNDPROC */            p_plugin->setWindowProc( (WNDPROC)SetWindowLong( drawable,                                             GWL_WNDPROC, (LONG)Manage ) );            /* change window style to our liking */            LONG style = GetWindowLong((HWND)drawable, GWL_STYLE);            style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;            SetWindowLong((HWND)drawable, GWL_STYLE, style);            /* change/set parent */            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);            /* remember new window */            p_plugin->setWindow(*window);            /* Redraw window */            InvalidateRect( (HWND)drawable, NULL, TRUE );            UpdateWindow( (HWND)drawable );        }    }    else if ( curwin.window )    {        /* reset WNDPROC */        HWND oldwin = (HWND)curwin.window;        SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );        p_plugin->setWindowProc(NULL);        /* change/set parent */        libvlc_video_set_parent(p_vlc, 0, NULL);        curwin.window = NULL;    }#endif /* XP_WIN */#ifdef XP_UNIX    /* default to hidden toolbar, shown at the end of this method if asked *     * developers note : getToolbarSize need to wait the end of this method     */    i_control_height = 0;    i_control_width = window->width;    if( window && window->window )    {        Window  parent  = (Window) window->window;        if( !curwin.window || (parent != (Window)curwin.window) )        {            Display *p_display = ( (NPSetWindowCallbackStruct *)                                   window->ws_info )->display;            XResizeWindow( p_display, parent, window->width, window->height );            int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));            /* create windows */            Window video = XCreateSimpleWindow( p_display, parent, 0, 0,                           window->width, window->height - i_control_height,                           0, i_blackColor, i_blackColor );            Window controls = (Window) NULL;            controls = XCreateSimpleWindow( p_display, parent,                            0, window->height - i_control_height-1,                            window->width, i_control_height-1,                            0, i_blackColor, i_blackColor );            XMapWindow( p_display, parent );            XMapWindow( p_display, video );            if( controls ) { XMapWindow( p_display, controls ); }            XFlush(p_display);            /* bind events */            Widget w = XtWindowToWidget( p_display, parent );            XtAddEventHandler( w, ExposureMask, FALSE,                               (XtEventHandler)Redraw, p_plugin );            XtAddEventHandler( w, StructureNotifyMask, FALSE,                               (XtEventHandler)Resize, p_plugin );            XtAddEventHandler( w, ButtonReleaseMask, FALSE,                               (XtEventHandler)ControlHandler, p_plugin );            /* callback *//*            libvlc_media_player_t *p_md;            libvlc_exception_t ex;            libvlc_exception_init(& ex );            p_md = libvlc_playlist_get_media_player( p_plugin->getVLC(), &ex );            libvlc_exception_init( &ex );            libvlc_event_attach( libvlc_media_player_event_manager( p_md, &ex ),                                 libvlc_MediaPlayerPositionChanged, Redraw, NULL, &ex );*/            /* set/change parent window */            libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, NULL );            /* remember window */            p_plugin->setWindow( *window );            p_plugin->setVideoWindow( video );            if( controls ) { p_plugin->setControlWindow( controls ); }            Redraw( w, (XtPointer)p_plugin, NULL );            /* now display toolbar if asked through parameters */            if( p_plugin->b_toolbar )            {                p_plugin->showToolbar();            }        }    }    else if ( curwin.window )    {        /* change/set parent */        libvlc_video_set_parent(p_vlc, 0, NULL);        curwin.window = NULL;    }#endif /* XP_UNIX */    if( !p_plugin->b_stream )    {        if( p_plugin->psz_target )        {            if( libvlc_playlist_add( p_vlc, p_plugin->psz_target,                                     NULL, NULL ) != -1 )            {                if( p_plugin->b_autoplay )                {                    libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);                }            }            p_plugin->b_stream = true;        }    }    return NPERR_NO_ERROR;}NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,                       NPBool seekable, uint16 *stype ){    if( NULL == instance  )    {        return NPERR_INVALID_INSTANCE_ERROR;    }    VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);    if( NULL == p_plugin )    {        return NPERR_INVALID_INSTANCE_ERROR;    }   /*   ** Firefox/Mozilla may decide to open a stream from the URL specified   ** in the SRC parameter of the EMBED tag and pass it to us   **   ** since VLC will open the SRC URL as well, we're not interested in   ** that stream. Otherwise, we'll take it and queue it up in the playlist   */    if( !p_plugin->psz_target || strcmp(stream->url, p_plugin->psz_target) )    {        /* TODO: use pipes !!!! */        *stype = NP_ASFILEONLY;        return NPERR_NO_ERROR;    }    return NPERR_GENERIC_ERROR;}int32 NPP_WriteReady( NPP instance, NPStream *stream ){    /* TODO */    return 8*1024;}int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,                 int32 len, void *buffer ){    /* TODO */    return len;}NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason ){    if( instance == NULL )    {        return NPERR_INVALID_INSTANCE_ERROR;    }    return NPERR_NO_ERROR;}void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname ){    if( instance == NULL )    {        return;    }    VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);    if( NULL == p_plugin )    {        return;    }    if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL )        != -1 )    {        if( p_plugin->b_autoplay )        {            libvlc_playlist_play( p_plugin->getVLC(), 0, 0, NULL, NULL);        }    }}void NPP_URLNotify( NPP instance, const char* url,                    NPReason reason, void* notifyData ){    /***** Insert NPP_URLNotify code here *****\    PluginInstance* p_plugin;    if (instance != NULL)        p_plugin = (PluginInstance*) instance->pdata;    \*********************************************/}void NPP_Print( NPP instance, NPPrint* printInfo ){    if( printInfo == NULL )    {        return;

⌨️ 快捷键说明

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