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

📄 interface.cpp

📁 uclinux 下的vlc播放器源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    indicators[0] = 3 * ( rect.right - rect.left ) / 4;    indicators[1] = rect.right - rect.left;    // call functions to set style    SendMessage( hwndSB, SB_SETPARTS, (WPARAM)nopanes, (LPARAM)indicators );    return hwndSB;}/***********************************************************************FUNCTION:   WndProcPURPOSE:   Processes messages sent to the main window.***********************************************************************/LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ){    switch( msg )    {    case WM_CREATE:        hwndCB = CreateMenuBar( hwnd, hInst );        hwndTB = CreateToolBar( hwnd, hInst );        hwndSlider = CreateSliderBar( hwnd, hInst );        hwndLabel = CreateStaticText( hwnd, hInst );        hwndVol = CreateVolTrackBar( hwnd, hInst );#ifdef UNDER_CE        hwndSB = CreateStatusBar( hwnd, hInst );#endif        /* Video window */        if( config_GetInt( p_intf, "wince-embed" ) )            video = CreateVideoWindow( p_intf, hwnd );        timer = new Timer( p_intf, hwnd, this );        break;    case WM_COMMAND:        switch( GET_WM_COMMAND_ID(wp,lp) )        {        case ID_FILE_QUICKOPEN:         case ID_FILE_OPENFILE:         case ID_FILE_OPENDIR:        case ID_FILE_OPENNET:        case ID_VIEW_STREAMINFO:        case ID_VIEW_MESSAGES:        case ID_VIEW_PLAYLIST:        case ID_PREFERENCES:            OnShowDialog( GET_WM_COMMAND_ID(wp,lp) );            break;        case PlayStream_Event: OnPlayStream(); break;        case StopStream_Event: OnStopStream(); break;        case PrevStream_Event: OnPrevStream(); break;        case NextStream_Event: OnNextStream(); break;        case SlowStream_Event: OnSlowStream(); break;        case FastStream_Event: OnFastStream(); break;        case ID_FILE_ABOUT:         {            string about = (string)"VLC media player " PACKAGE_VERSION +                _("\n(WinCE interface)\n\n") +                _("(c) 1996-2006 - the VideoLAN Team\n\n") +                _("Compiled by ") + VLC_CompileBy() + "@" +                VLC_CompileHost() + "." + VLC_CompileDomain() + ".\n" +                _("Compiler: ") + VLC_Compiler() + ".\n" +#ifndef HAVE_SHARED_LIBVLC                _("Based on SVN revision: ") + VLC_Changeset() + ".\n\n" +#endif                _("The VideoLAN team <videolan@videolan.org>\n"                  "http://www.videolan.org/");            MessageBox( hwnd, _FROMMB(about.c_str()),                        _T("About VLC media player"), MB_OK );            break;        }        case ID_FILE_EXIT:            SendMessage( hwnd, WM_CLOSE, 0, 0 );            break;        default:            OnMenuEvent( p_intf, GET_WM_COMMAND_ID(wp,lp) );            // we should test if it is a menu command        }        break;      case WM_TIMER:        timer->Notify();        break;    case WM_CTLCOLORSTATIC:         if( ( (HWND)lp == hwndSlider ) || ( (HWND)lp == hwndVol ) )        {             return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );         }        if( (HWND)lp == hwndLabel )        {            SetBkColor( (HDC)wp, RGB (192, 192, 192) );             return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );         }        break;    case WM_HSCROLL:        if( (HWND)lp == hwndSlider ) OnSliderUpdate( wp );        break;    case WM_VSCROLL:        if( (HWND)lp == hwndVol ) OnChange( wp );        break;    case WM_INITMENUPOPUP:        if( (HMENU)wp == menu_settings )            RefreshSettingsMenu( p_intf, menu_settings );        if( (HMENU)wp == menu_audio )            RefreshAudioMenu( p_intf, menu_audio );        if( (HMENU)wp == menu_video )            RefreshVideoMenu( p_intf, menu_video );        if( (HMENU)wp == menu_navigation )            RefreshNavigMenu( p_intf, menu_navigation );        /* Fall through */    case WM_KILLFOCUS:        SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );    case WM_ENTERMENULOOP:        if( video && video->hWnd )            SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );        break;    case WM_SETFOCUS:        SHSipPreference( hwnd, SIP_DOWN );         SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );    case WM_EXITMENULOOP:        if( video && video->hWnd )            SendMessage( video->hWnd, WM_SETFOCUS, 0, 0 );        break;    case WM_LBUTTONDOWN:        {            SHRGINFO shrg;            shrg.cbSize = sizeof( shrg );            shrg.hwndClient = hwnd;            shrg.ptDown.x = LOWORD(lp);            shrg.ptDown.y = HIWORD(lp);            shrg.dwFlags = SHRG_RETURNCMD ;            if( SHRecognizeGesture( &shrg ) == GN_CONTEXTMENU )                PopupMenu( p_intf, hwnd, shrg.ptDown );        }        break;   case WM_RBUTTONUP:        {            POINT point;            point.x = LOWORD(lp);            point.y = HIWORD(lp);            PopupMenu( p_intf, hwnd, point );        }        break;    case WM_HELP:        MessageBox (hwnd, _T("Help"), _T("Help"), MB_OK);        break;    case WM_CLOSE:        if( hwndCB ) DestroyWindow( hwndCB );        DestroyWindow( hwnd );        break;    case WM_DESTROY:        PostQuitMessage( 0 );        break;    }    return DefWindowProc( hwnd, msg, wp, lp );}void Interface::OnShowDialog( int i_dialog_event ){    int i_id;    switch( i_dialog_event )    {    case ID_FILE_QUICKOPEN: i_id = INTF_DIALOG_FILE_SIMPLE; break;    case ID_FILE_OPENFILE: i_id = INTF_DIALOG_FILE; break;    case ID_FILE_OPENDIR: i_id = INTF_DIALOG_DIRECTORY; break;    case ID_FILE_OPENNET: i_id = INTF_DIALOG_NET; break;    case ID_VIEW_PLAYLIST: i_id = INTF_DIALOG_PLAYLIST; break;    case ID_VIEW_MESSAGES: i_id = INTF_DIALOG_MESSAGES; break;    case ID_VIEW_STREAMINFO: i_id = INTF_DIALOG_FILEINFO; break;    case ID_PREFERENCES: i_id = INTF_DIALOG_PREFS; break;    default: i_id = INTF_DIALOG_FILE; break;    }    if( p_intf->p_sys->pf_show_dialog )        p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );}void Interface::OnPlayStream( void ){    playlist_t *p_playlist = (playlist_t *)        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL ) return;    if( p_playlist->i_size && p_playlist->i_enabled )    {        vlc_value_t state;        input_thread_t *p_input = (input_thread_t *)            vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );        if( p_input == NULL )        {            /* No stream was playing, start one */            playlist_Play( p_playlist );            TogglePlayButton( PLAYING_S );            vlc_object_release( p_playlist );            return;        }        var_Get( p_input, "state", &state );        if( state.i_int != PAUSE_S )        {            /* A stream is being played, pause it */            state.i_int = PAUSE_S;        }        else        {            /* Stream is paused, resume it */            state.i_int = PLAYING_S;        }        var_Set( p_input, "state", state );        TogglePlayButton( state.i_int );        vlc_object_release( p_input );        vlc_object_release( p_playlist );    }    else    {        /* If the playlist is empty, open a file requester instead */        vlc_object_release( p_playlist );        OnShowDialog( ID_FILE_QUICKOPEN );    }}void Interface::TogglePlayButton( int i_playing_status ){    TBREPLACEBITMAP tbrb;    tbrb.hInstOld = tbrb.hInstNew = (HINSTANCE) hInst;    tbrb.nButtons = NUMIMAGES;    if( i_playing_status == i_old_playing_status ) return;    if( i_playing_status == PLAYING_S )    {        tbrb.nIDOld = IDB_BITMAP2;        tbrb.nIDNew = IDB_BITMAP1;        SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,                     (LPARAM)(LPTBREPLACEBITMAP)&tbrb );    }    else    {        tbrb.nIDOld = IDB_BITMAP1;        tbrb.nIDNew = IDB_BITMAP2;        SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,                     (LPARAM)(LPTBREPLACEBITMAP)&tbrb );    }    UpdateWindow( hwndTB );    i_old_playing_status = i_playing_status;}void Interface::OnVideoOnTop( void ){    vlc_value_t val;    vout_thread_t *p_vout = (vout_thread_t *)        vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );    if( p_vout == NULL ) return;    if( var_Get( (vlc_object_t *)p_vout, "video-on-top", &val ) < 0 )        return;    val.b_bool = !val.b_bool;    var_Set( (vlc_object_t *)p_vout, "video-on-top", val );    vlc_object_release( (vlc_object_t *)p_vout );}void Interface::OnSliderUpdate( int wp ){    vlc_mutex_lock( &p_intf->change_lock );    input_thread_t *p_input = p_intf->p_sys->p_input;    int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 );     if( (int)LOWORD(wp) == SB_THUMBPOSITION ||        (int)LOWORD(wp) == SB_ENDSCROLL )    {        if( p_intf->p_sys->i_slider_pos != dwPos && p_input )        {            vlc_value_t pos;            pos.f_float = (float)dwPos / (float)SLIDER_MAX_POS;            var_Set( p_input, "position", pos );        }        p_intf->p_sys->b_slider_free = VLC_TRUE;    }    else    {        p_intf->p_sys->b_slider_free = VLC_FALSE;        if( p_input )        {            /* Update stream date */            char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];            mtime_t i_seconds;            i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );            secstotimestr( psz_total, i_seconds );            i_seconds = var_GetTime( p_input, "time" ) / I64C(1000000 );            secstotimestr( psz_time, i_seconds );            SendMessage( hwndLabel, WM_SETTEXT, (WPARAM)1,                         (LPARAM)_FROMMB(psz_time) );        }    }    vlc_mutex_unlock( &p_intf->change_lock );}void Interface::OnChange( int wp ){    DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );    if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )    {        VolumeChange( 200 - (int)dwPos );        b_volume_hold = VLC_FALSE;    }    else    {        b_volume_hold = VLC_TRUE;    }}void Interface::VolumeChange( int i_volume ){    aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );}void Interface::VolumeUpdate(){    audio_volume_t i_volume;    if( b_volume_hold ) return;    aout_VolumeGet( p_intf, &i_volume );    int i_volume_ctrl = 200 - i_volume * 200 * 2 / AOUT_VOLUME_MAX;    DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );    if( i_volume_ctrl == (int)dwPos ) return;    SendMessage( hwndVol, TBM_SETPOS, 1, i_volume_ctrl );}void Interface::OnStopStream( void ){    playlist_t * p_playlist = (playlist_t *)        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL ) return;    playlist_Stop( p_playlist );    TogglePlayButton( PAUSE_S );    vlc_object_release( p_playlist );}void Interface::OnPrevStream( void ){    playlist_t * p_playlist = (playlist_t *)        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL ) return;    playlist_Prev( p_playlist );    vlc_object_release( p_playlist );}void Interface::OnNextStream( void ){    playlist_t * p_playlist = (playlist_t *)        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL ) return;    playlist_Next( p_playlist );    vlc_object_release( p_playlist );}void Interface::OnSlowStream( void ){    input_thread_t *p_input = (input_thread_t *)        vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );    if( p_input == NULL ) return;    vlc_value_t val; val.b_bool = VLC_TRUE;    var_Set( p_input, "rate-slower", val );    vlc_object_release( p_input );}void Interface::OnFastStream( void ){    input_thread_t *p_input = (input_thread_t *)        vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );    if( p_input == NULL ) return;    vlc_value_t val; val.b_bool = VLC_TRUE;    var_Set( p_input, "rate-faster", val );    vlc_object_release( p_input );}void Interface::Update(){    /* Misc updates */    VolumeUpdate();}

⌨️ 快捷键说明

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