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

📄 interface.cpp

📁 VLC媒体播放程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        case OpenDisc_Event:            i_id = INTF_DIALOG_DISC;            break;        case OpenNet_Event:            i_id = INTF_DIALOG_NET;            break;        case OpenSat_Event:            i_id = INTF_DIALOG_SAT;            break;        case Playlist_Event:            i_id = INTF_DIALOG_PLAYLIST;            break;        case Logs_Event:            i_id = INTF_DIALOG_MESSAGES;            break;        case FileInfo_Event:            i_id = INTF_DIALOG_FILEINFO;            break;        case Prefs_Event:            i_id = INTF_DIALOG_PREFS;            break;        case StreamWizard_Event:            i_id = INTF_DIALOG_STREAMWIZARD;            break;        default:            i_id = INTF_DIALOG_FILE;            break;        }        p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );    }}void Interface::OnExtra(wxCommandEvent& event){    if( b_extra == VLC_FALSE)    {        extra_frame->Show();        frame_sizer->Show( extra_frame );        b_extra = VLC_TRUE;    }    else    {        extra_frame->Hide();        frame_sizer->Hide( extra_frame );        b_extra = VLC_FALSE;    }    frame_sizer->Layout();    frame_sizer->Fit(this);}void Interface::OnEnableAdjust(wxCommandEvent& event){    char *psz_filters=config_GetPsz( p_intf, "filter");    char *psz_new = NULL;    if( event.IsChecked() )    {        if(psz_filters == NULL)        {            psz_new = strdup( "adjust" );        }        else        {            psz_new= (char *) malloc(strlen(psz_filters) + 8 );            sprintf( psz_new, "%s:adjust", psz_filters);        }        config_PutPsz( p_intf, "filter", psz_new );        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 )        {            val.psz_string = strdup( psz_new );            var_Set( p_vout, "filter", val);            vlc_object_release( p_vout );        }        if( val.psz_string ) free( val.psz_string );        brightness_slider->Enable();        saturation_slider->Enable();        contrast_slider->Enable();        hue_slider->Enable();        gamma_slider->Enable();    }    else    {        if( psz_filters != NULL )        {            char *psz_current;            unsigned int i=0;            for( i = 0; i< strlen(psz_filters ); i++)            {                if ( !strncasecmp( &psz_filters[i],"adjust",6 ))                {                    if(i > 0)                        if( psz_filters[i-1] == ':' ) i--;                    psz_current = strchr( &psz_filters[i+1] , ':' );                    if( !psz_current )                        psz_filters[i] = '\0';                    else                    {                       memmove( &psz_filters[i] , psz_current,                                &psz_filters[strlen(psz_filters)]-psz_current                                +1);                    }                }            }            config_PutPsz( p_intf, "filter", psz_filters);            vlc_value_t val;            val.psz_string = strdup( psz_filters );            vout_thread_t *p_vout =               (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,                                       FIND_ANYWHERE );            if( p_vout != NULL )            {                var_Set( p_vout, "filter", val);                vlc_object_release( p_vout );            }            if( val.psz_string ) free( val.psz_string );        }        brightness_slider->Disable();        saturation_slider->Disable();        contrast_slider->Disable();        hue_slider->Disable();        gamma_slider->Disable();    }    if(psz_filters) free(psz_filters);    if(psz_new) free(psz_new);}void Interface::OnHueUpdate( wxScrollEvent& event){    config_PutInt( p_intf , "hue" , event.GetPosition() );}void Interface::OnSaturationUpdate( wxScrollEvent& event){    config_PutFloat( p_intf , "saturation" , (float)event.GetPosition()/100 );}void Interface::OnBrightnessUpdate( wxScrollEvent& event){    config_PutFloat( p_intf , "brightness", (float)event.GetPosition()/100 );}void Interface::OnContrastUpdate(wxScrollEvent& event){    config_PutFloat( p_intf , "contrast" , (float)event.GetPosition()/100 );}void Interface::OnGammaUpdate(wxScrollEvent& event){    config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );}void Interface::OnRatio( wxCommandEvent& event ){   config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );}void Interface::OnEnableVisual(wxCommandEvent& event){    if( event.IsChecked() )    {        config_PutPsz( p_intf, "audio-filter", "visual" );    }    else    {        config_PutPsz( p_intf, "audio-filter", "" );    }}void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) ){    wxCommandEvent dummy;    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( dummy );    }}void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) ){    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::OnSliderUpdate( wxScrollEvent& event ){    vlc_mutex_lock( &p_intf->change_lock );#ifdef WIN32    if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE        || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )    {#endif        if( p_intf->p_sys->i_slider_pos != event.GetPosition()            && p_intf->p_sys->p_input )        {            vlc_value_t pos;            pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;            var_Set( p_intf->p_sys->p_input, "position", pos );        }#ifdef WIN32        p_intf->p_sys->b_slider_free = VLC_TRUE;    }    else    {        p_intf->p_sys->b_slider_free = VLC_FALSE;        if( p_intf->p_sys->p_input )        {            /* Update stream date */#define p_area p_intf->p_sys->p_input->stream.p_selected_area            char psz_time[ MSTRTIME_MAX_SIZE ];            slider_box->SetLabel(                wxU(input_OffsetToTime( p_intf->p_sys->p_input,                                        psz_time,                                        p_area->i_size * event.GetPosition()                                        / SLIDER_MAX_POS )) );#undef p_area        }    }#endif#undef WIN32    vlc_mutex_unlock( &p_intf->change_lock );}void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) ){    playlist_t * p_playlist =        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                       FIND_ANYWHERE );    if( p_playlist == NULL )    {        return;    }    vlc_mutex_lock( &p_playlist->object_lock );    if( p_playlist->p_input != NULL )    {        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );        if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )        {            vlc_value_t val; val.b_bool = VLC_TRUE;            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );            var_Set( p_playlist->p_input, "prev-title", val );        } else            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );    }    vlc_mutex_unlock( &p_playlist->object_lock );    playlist_Prev( p_playlist );    vlc_object_release( p_playlist );}void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) ){    playlist_t * p_playlist =        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                       FIND_ANYWHERE );    if( p_playlist == NULL )    {        return;    }    vlc_mutex_lock( &p_playlist->object_lock );    if( p_playlist->p_input != NULL )    {        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );        if( p_playlist->p_input->stream.i_area_nb > 1 &&            p_playlist->p_input->stream.p_selected_area->i_id <              p_playlist->p_input->stream.i_area_nb - 1 )        {            vlc_value_t val; val.b_bool = VLC_TRUE;            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );            var_Set( p_playlist->p_input, "next-title", val );        } else            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );    }    vlc_mutex_unlock( &p_playlist->object_lock );    playlist_Next( p_playlist );    vlc_object_release( p_playlist );}void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) ){    input_thread_t *p_input =        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,                                           FIND_ANYWHERE );    if( p_input )    {        vlc_value_t val; val.b_bool = VLC_TRUE;        var_Set( p_input, "rate-slower", val );        vlc_object_release( p_input );    }}void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) ){    input_thread_t *p_input =        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,                                           FIND_ANYWHERE );    if( p_input )    {        vlc_value_t val; val.b_bool = VLC_TRUE;        var_Set( p_input, "rate-faster", val );        vlc_object_release( p_input );    }}void Interface::TogglePlayButton( int i_playing_status ){    if( i_playing_status == i_old_playing_status )        return;    GetToolBar()->DeleteTool( PlayStream_Event );    if( i_playing_status == PLAYING_S )    {        GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Pause")),                                  wxBitmap( pause_xpm ), wxNullBitmap,                                  wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );    }    else    {        GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Play")),                                  wxBitmap( play_xpm ), wxNullBitmap,                                  wxITEM_NORMAL, wxU(_(HELP_PLAY)) );    }    GetToolBar()->Realize();    i_old_playing_status = i_playing_status;}#if !defined(__WXX11__)/***************************************************************************** * Definition of DragAndDrop class. *****************************************************************************/DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue ){    p_intf = _p_intf;    b_enqueue = _b_enqueue;}bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,                               const wxArrayString& filenames ){    /* Add dropped files to the playlist */    playlist_t *p_playlist =        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                       FIND_ANYWHERE );    if( p_playlist == NULL )    {        return FALSE;    }    for( size_t i = 0; i < filenames.GetCount(); i++ )        playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),                      (const char *)filenames[i].mb_str(),                      PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),                      PLAYLIST_END );    vlc_object_release( p_playlist );    return TRUE;}#endif/***************************************************************************** * Definition of wxVolCtrl class. *****************************************************************************/wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )  : wxGauge( parent, id, 200, wxDefaultPosition, wxSize( 20, -1 ),             wxGA_VERTICAL | wxGA_SMOOTH ){    p_intf = _p_intf;}void wxVolCtrl::OnChange( wxMouseEvent& event ){    if( !event.LeftDown() && !event.LeftIsDown() ) return;    int i_volume = (GetClientSize().GetHeight() - event.GetY()) * 200 /                    GetClientSize().GetHeight();    Change( i_volume );}void wxVolCtrl::Change( int i_volume ){    aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );    SetValue( i_volume );    SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),                i_volume ) );}

⌨️ 快捷键说明

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