vlcproc.cpp

来自「VLC媒体播放程序」· C++ 代码 · 共 636 行 · 第 1/2 页

CPP
636
字号
/***************************************************************************** * vlcproc.cpp: VlcProc class ***************************************************************************** * Copyright (C) 2003 VideoLAN * $Id: vlcproc.cpp,v 1.54 2004/02/15 18:58:38 ipkiss Exp $ * * Authors: Olivier Teuli鑢e <ipkiss@via.ecp.fr> *          Emmanuel Puig    <karibu@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, * USA. *****************************************************************************///--- VLC -------------------------------------------------------------------#include <vlc/vlc.h>#include <vlc/intf.h>#include <vlc/aout.h>#include <vlc/vout.h>//--- SKIN ------------------------------------------------------------------#include "../os_api.h"#include "event.h"#include "banks.h"#include "theme.h"#include "../os_theme.h"#include "themeloader.h"#include "window.h"#include "vlcproc.h"#include "skin_common.h"#include "dialogs.h"//---------------------------------------------------------------------------// VlcProc//---------------------------------------------------------------------------VlcProc::VlcProc( intf_thread_t *_p_intf ){    p_intf = _p_intf;    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist != NULL )    {        // We want to be notified of playlist changes        var_AddCallback( p_playlist, "intf-change", RefreshCallback, this );        // Raise/lower interface with middle click on vout        var_AddCallback( p_playlist, "intf-show", IntfShowCallback, this );        vlc_object_release( p_playlist );    }}//---------------------------------------------------------------------------VlcProc::~VlcProc(){    // Remove the refresh callback    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist != NULL )    {        var_DelCallback( p_playlist, "intf-change", RefreshCallback, this );        var_DelCallback( p_playlist, "intf-show", IntfShowCallback, this );        vlc_object_release( p_playlist );    }}//---------------------------------------------------------------------------bool VlcProc::EventProc( Event *evt ){    switch( evt->GetMessage() )    {        case VLC_STREAMPOS:            MoveStream( evt->GetParam2() );            return true;        case VLC_VOLUME_CHANGE:            ChangeVolume( evt->GetParam1(), evt->GetParam2() );            return true;        case VLC_FULLSCREEN:            FullScreen();            return true;        case VLC_HIDE:            for( list<SkinWindow *>::const_iterator win =                    p_intf->p_sys->p_theme->WindowList.begin();                 win != p_intf->p_sys->p_theme->WindowList.end(); win++ )            {                (*win)->OnStartThemeVisible = !(*win)->IsHidden();            }            p_intf->p_sys->i_close_status = (int)evt->GetParam1();            OSAPI_PostMessage( NULL, WINDOW_CLOSE, 1, 0 );            return true;        case VLC_SHOW:            for( list<SkinWindow *>::const_iterator win =                    p_intf->p_sys->p_theme->WindowList.begin();                 win != p_intf->p_sys->p_theme->WindowList.end(); win++ )            {                if( (*win)->OnStartThemeVisible )                    OSAPI_PostMessage( (*win), WINDOW_OPEN, 1, 0 );            }            p_intf->p_sys->b_all_win_closed = false;            return true;        case VLC_OPEN:            p_intf->p_sys->p_dialogs->ShowOpen( true );            InterfaceRefresh();            return true;        case VLC_NET:            p_intf->p_sys->p_dialogs->ShowNet();            InterfaceRefresh();            return true;        case VLC_LOAD_SKIN:            LoadSkin();            return true;        case VLC_ON_TOP:            for( list<SkinWindow *>::const_iterator win =                    p_intf->p_sys->p_theme->WindowList.begin();                win != p_intf->p_sys->p_theme->WindowList.end(); win++ )            {                (*win)->ToggleOnTop();            }            // Set the indicator to the new state            p_intf->p_sys->b_on_top = !p_intf->p_sys->b_on_top;            return true;        case VLC_DROP:            DropFile( evt->GetParam1(), evt->GetParam2() );            return true;        case VLC_PLAY:            PlayStream();            return true;        case VLC_PAUSE:            PauseStream();            return true;        case VLC_STOP:            StopStream();            return true;        case VLC_NEXT:            NextStream();            return true;        case VLC_PREV:            PrevStream();            return true;        case VLC_SLOWER:            SlowStream();            return true;        case VLC_FASTER:            FastStream();            return true;        case VLC_PLAYLIST_ADD_FILE:            p_intf->p_sys->p_dialogs->ShowOpen( false );            InterfaceRefresh();            return true;        case VLC_LOG_SHOW:            p_intf->p_sys->p_dialogs->ShowMessages();            return true;        case VLC_PREFS_SHOW:            p_intf->p_sys->p_dialogs->ShowPrefs();            return true;        case VLC_INFO_SHOW:            p_intf->p_sys->p_dialogs->ShowFileInfo();            return true;        case VLC_INTF_REFRESH:            InterfaceRefresh();            return true;        case VLC_TEST_ALL_CLOSED:            return EventProcEnd();        case VLC_QUIT:            return false;        case VLC_CHANGE_TRAY:            p_intf->p_sys->p_theme->ChangeTray();            return true;        case VLC_CHANGE_TASKBAR:            p_intf->p_sys->p_theme->ChangeTaskbar();            return true;        default:            return true;    }}//---------------------------------------------------------------------------bool VlcProc::EventProcEnd(){    if( p_intf->p_sys->b_all_win_closed )        return true;    list<SkinWindow *>::const_iterator win;    // If a window has been closed, test if all are closed !    for( win = p_intf->p_sys->p_theme->WindowList.begin();         win != p_intf->p_sys->p_theme->WindowList.end(); win++ )    {        if( !(*win)->IsHidden() )   // Not all windows closed        {            return true;        }    }    // All window are closed    switch( p_intf->p_sys->i_close_status )    {        case VLC_QUIT:            // Save config before exiting            p_intf->p_sys->p_theme->SaveConfig();            break;    }    // Send specified event    OSAPI_PostMessage( NULL, p_intf->p_sys->i_close_status, 0, 0 );    // Reset values    p_intf->p_sys->i_close_status = VLC_NOTHING;    p_intf->p_sys->b_all_win_closed = true;    // Return true    return true;}//---------------------------------------------------------------------------bool VlcProc::IsClosing(){    if( p_intf->b_die && p_intf->p_sys->i_close_status != VLC_QUIT )    {        p_intf->p_sys->i_close_status = VLC_QUIT;        OSAPI_PostMessage( NULL, VLC_HIDE, VLC_QUIT, 0 );    }    return true;}//---------------------------------------------------------------------------//---------------------------------------------------------------------------// Private methods//---------------------------------------------------------------------------// Refresh callbackint VlcProc::RefreshCallback( vlc_object_t *p_this, const char *psz_variable,        vlc_value_t old_val, vlc_value_t new_val, void *param ){    ( (VlcProc*)param )->InterfaceRefresh();    return VLC_SUCCESS;}// Interface show/hide callbackint VlcProc::IntfShowCallback( vlc_object_t *p_this, const char *psz_variable,        vlc_value_t old_val, vlc_value_t new_val, void *param ){    if( new_val.b_bool == VLC_TRUE )    {        OSAPI_PostMessage( NULL, VLC_SHOW, 1, 0 );    }    else    {        OSAPI_PostMessage( NULL, VLC_HIDE, 1, 0 );    }    return VLC_SUCCESS;}void VlcProc::InterfaceRefresh(){    // Shortcut pointers    intf_sys_t  *Sys      = p_intf->p_sys;    Theme       *Thema    = Sys->p_theme;    playlist_t  *PlayList = Sys->p_playlist;    // Refresh    if( PlayList != NULL )    {        vlc_mutex_lock( &PlayList->object_lock );        // Refresh stream control controls ! :)        switch( PlayList->i_status )        {            case PLAYLIST_STOPPED:                EnabledEvent( "time", false );                EnabledEvent( "stop", false );                EnabledEvent( "play", true );                EnabledEvent( "pause", false );                break;            case PLAYLIST_RUNNING:                EnabledEvent( "time", true );                EnabledEvent( "stop", true );                EnabledEvent( "play", false );                EnabledEvent( "pause", true );                break;            case PLAYLIST_PAUSED:

⌨️ 快捷键说明

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