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

📄 hotkeys.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
            else if( i_action == ACTIONID_FASTER )            {                var_SetVoid( p_input, "rate-faster" );                vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,                                 _("Faster") );            }            else if( i_action == ACTIONID_SLOWER )            {                var_SetVoid( p_input, "rate-slower" );                vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,                                 _("Slower") );            }            else if( i_action == ACTIONID_POSITION && b_seekable )            {                DisplayPosition( p_intf, p_vout, p_input );            }            else if( i_action >= ACTIONID_PLAY_BOOKMARK1 &&                     i_action <= ACTIONID_PLAY_BOOKMARK10 )            {                PlayBookmark( p_intf, i_action - ACTIONID_PLAY_BOOKMARK1 + 1 );            }            else if( i_action >= ACTIONID_SET_BOOKMARK1 &&                     i_action <= ACTIONID_SET_BOOKMARK10 )            {                SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );            }            /* Only makes sense with DVD */            else if( i_action == ACTIONID_TITLE_PREV )                var_SetVoid( p_input, "prev-title" );            else if( i_action == ACTIONID_TITLE_NEXT )                var_SetVoid( p_input, "next-title" );            else if( i_action == ACTIONID_CHAPTER_PREV )                var_SetVoid( p_input, "prev-chapter" );            else if( i_action == ACTIONID_CHAPTER_NEXT )                var_SetVoid( p_input, "next-chapter" );            else if( i_action == ACTIONID_DISC_MENU )                var_SetInteger( p_input, "title  0", 2 );            else if( i_action == ACTIONID_SUBDELAY_DOWN )            {                int64_t i_delay = var_GetTime( p_input, "spu-delay" );                i_delay -= 50000;    /* 50 ms */                var_SetTime( p_input, "spu-delay", i_delay );                ClearChannels( p_intf, p_vout );                vout_OSDMessage( p_intf, DEFAULT_CHAN,                                 _( "Subtitle delay %i ms" ),                                 (int)(i_delay/1000) );            }            else if( i_action == ACTIONID_SUBDELAY_UP )            {                int64_t i_delay = var_GetTime( p_input, "spu-delay" );                i_delay += 50000;    /* 50 ms */                var_SetTime( p_input, "spu-delay", i_delay );                ClearChannels( p_intf, p_vout );                vout_OSDMessage( p_intf, DEFAULT_CHAN,                                _( "Subtitle delay %i ms" ),                                 (int)(i_delay/1000) );            }            else if( i_action == ACTIONID_AUDIODELAY_DOWN )            {                int64_t i_delay = var_GetTime( p_input, "audio-delay" );                i_delay -= 50000;    /* 50 ms */                var_SetTime( p_input, "audio-delay", i_delay );                ClearChannels( p_intf, p_vout );                vout_OSDMessage( p_intf, DEFAULT_CHAN,                                _( "Audio delay %i ms" ),                                 (int)(i_delay/1000) );            }            else if( i_action == ACTIONID_AUDIODELAY_UP )            {                int64_t i_delay = var_GetTime( p_input, "audio-delay" );                i_delay += 50000;    /* 50 ms */                var_SetTime( p_input, "audio-delay", i_delay );                ClearChannels( p_intf, p_vout );                vout_OSDMessage( p_intf, DEFAULT_CHAN,                                _( "Audio delay %i ms" ),                                 (int)(i_delay/1000) );            }            else if( i_action == ACTIONID_PLAY )            {                var_Get( p_input, "rate", &val );                if( val.i_int != INPUT_RATE_DEFAULT )                {                    /* Return to normal speed */                    var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );                }                else                {                    ClearChannels( p_intf, p_vout );                    vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,                                  OSD_PLAY_ICON );                    playlist_Play( p_playlist );                }            }            else if( i_action == ACTIONID_MENU_ON )            {                osd_MenuShow( VLC_OBJECT(p_intf) );            }            else if( i_action == ACTIONID_MENU_OFF )            {                osd_MenuHide( VLC_OBJECT(p_intf) );            }            else if( i_action == ACTIONID_MENU_LEFT )            {                osd_MenuPrev( VLC_OBJECT(p_intf) );            }            else if( i_action == ACTIONID_MENU_RIGHT )            {                osd_MenuNext( VLC_OBJECT(p_intf) );            }            else if( i_action == ACTIONID_MENU_UP )            {                osd_MenuUp( VLC_OBJECT(p_intf) );            }            else if( i_action == ACTIONID_MENU_DOWN )            {                osd_MenuDown( VLC_OBJECT(p_intf) );            }            else if( i_action == ACTIONID_MENU_SELECT )            {                osd_MenuActivate( VLC_OBJECT(p_intf) );            }        }        if( p_vout )            vlc_object_release( p_vout );        if( p_input )            vlc_object_release( p_input );    }    pl_Release( p_intf );}static int GetAction( intf_thread_t *p_intf ){    intf_sys_t *p_sys = p_intf->p_sys;    int i_ret = -1;    vlc_object_lock( p_intf );    while( p_sys->i_size == 0 )    {        if( !vlc_object_alive( p_intf ) )            goto out;        vlc_object_wait( p_intf );    }    i_ret = p_sys->p_actions[ 0 ];    p_sys->i_size--;    for( int i = 0; i < p_sys->i_size; i++ )        p_sys->p_actions[i] = p_sys->p_actions[i + 1];out:    vlc_object_unlock( p_intf );    return i_ret;}static int PutAction( intf_thread_t *p_intf, int i_action ){    intf_sys_t *p_sys = p_intf->p_sys;    int i_ret = VLC_EGENERIC;    vlc_object_lock( p_intf );    if ( p_sys->i_size >= BUFFER_SIZE )        msg_Warn( p_intf, "event buffer full, dropping key actions" );    else        p_sys->p_actions[p_sys->i_size++] = i_action;    vlc_object_signal_unlocked( p_intf );    vlc_object_unlock( p_intf );    return i_ret;}/***************************************************************************** * SpecialKeyEvent: callback for mouse events *****************************************************************************/static int SpecialKeyEvent( vlc_object_t *libvlc, char const *psz_var,                            vlc_value_t oldval, vlc_value_t newval,                            void *p_data ){    intf_thread_t *p_intf = (intf_thread_t *)p_data;    int i_action;    (void)libvlc;    (void)psz_var;    (void)oldval;    /* Special action for mouse event */    /* FIXME: This should probably be configurable */    /* FIXME: rework hotkeys handling to allow more than 1 event     * to trigger one same action */    switch (newval.i_int & KEY_SPECIAL)    {        case KEY_MOUSEWHEELUP:            i_action = ACTIONID_VOL_UP;            break;        case KEY_MOUSEWHEELDOWN:            i_action = ACTIONID_VOL_DOWN;            break;        case KEY_MOUSEWHEELLEFT:            i_action = ACTIONID_JUMP_BACKWARD_EXTRASHORT;            break;        case KEY_MOUSEWHEELRIGHT:            i_action = ACTIONID_JUMP_FORWARD_EXTRASHORT;            break;        default:          return VLC_SUCCESS;    }    if( i_action )        return PutAction( p_intf, i_action );    return VLC_SUCCESS;}/***************************************************************************** * ActionEvent: callback for hotkey actions *****************************************************************************/static int ActionEvent( vlc_object_t *libvlc, char const *psz_var,                        vlc_value_t oldval, vlc_value_t newval, void *p_data ){    intf_thread_t *p_intf = (intf_thread_t *)p_data;    (void)libvlc;    (void)psz_var;    (void)oldval;    return PutAction( p_intf, newval.i_int );}static void PlayBookmark( intf_thread_t *p_intf, int i_num ){    vlc_value_t val;    char psz_bookmark_name[11];    playlist_t *p_playlist = pl_Yield( p_intf );    sprintf( psz_bookmark_name, "bookmark%i", i_num );    var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT );    var_Get( p_intf, psz_bookmark_name, &val );    char *psz_bookmark = strdup( val.psz_string );    PL_LOCK;    FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )        char *psz_uri = input_item_GetURI( p_item->p_input );        if( !strcmp( psz_bookmark, psz_uri ) )        {            free( psz_uri );            playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,                              NULL, p_item );            break;        }        else            free( psz_uri );    FOREACH_END();    PL_UNLOCK;    vlc_object_release( p_playlist );}static void SetBookmark( intf_thread_t *p_intf, int i_num ){    playlist_t *p_playlist = pl_Yield( p_intf );    char psz_bookmark_name[11];    sprintf( psz_bookmark_name, "bookmark%i", i_num );    var_Create( p_intf, psz_bookmark_name,                VLC_VAR_STRING|VLC_VAR_DOINHERIT );    if( p_playlist->status.p_item )    {        char *psz_uri = input_item_GetURI( p_playlist->status.p_item->p_input );        config_PutPsz( p_intf, psz_bookmark_name, psz_uri);        msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num, psz_uri);        free( psz_uri );        config_SaveConfigFile( p_intf, "hotkeys" );    }    pl_Release( p_intf );}static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,                             input_thread_t *p_input ){    char psz_duration[MSTRTIME_MAX_SIZE];    char psz_time[MSTRTIME_MAX_SIZE];    vlc_value_t time, pos;    mtime_t i_seconds;    if( p_vout == NULL ) return;    ClearChannels( p_intf, p_vout );    var_Get( p_input, "time", &time );    i_seconds = time.i_time / 1000000;    secstotimestr ( psz_time, i_seconds );    var_Get( p_input, "length", &time );    if( time.i_time > 0 )    {        secstotimestr( psz_duration, time.i_time / 1000000 );        vout_OSDMessage( p_input, POSITION_TEXT_CHAN, (char *) "%s / %s",                         psz_time, psz_duration );    }    else if( i_seconds > 0 )    {        vout_OSDMessage( p_input, POSITION_TEXT_CHAN, psz_time );    }    if( !p_vout->p_window || p_vout->b_fullscreen )    {        var_Get( p_input, "position", &pos );        vout_OSDSlider( VLC_OBJECT( p_input ), POSITION_WIDGET_CHAN,                        pos.f_float * 100, OSD_HOR_SLIDER );    }}static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,                           audio_volume_t i_vol ){    if( p_vout == NULL )    {        return;    }    ClearChannels( p_intf, p_vout );    if( !p_vout->p_window || p_vout->b_fullscreen )    {        vout_OSDSlider( VLC_OBJECT( p_vout ), VOLUME_WIDGET_CHAN,            i_vol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );    }    else    {        vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %d%%" ),                         i_vol*400/AOUT_VOLUME_MAX );    }}static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout ){    int i;    if( p_vout )    {        spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );        for( i = 0; i < CHANNELS_NUMBER; i++ )        {            spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,                         p_intf->p_sys->p_channels[ i ] );        }    }}

⌨️ 快捷键说明

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