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

📄 hotkeys.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
            {                p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                              FIND_ANYWHERE );                if( p_playlist )                {                    playlist_Stop( p_playlist );                    vlc_object_release( p_playlist );                }            }            else if( i_action == ACTIONID_FASTER )            {                vlc_value_t val;                val.b_bool = VLC_TRUE;                var_Set( p_input, "rate-faster", val );                vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,                                 _("Faster") );            }            else if( i_action == ACTIONID_SLOWER )            {                vlc_value_t val;                val.b_bool = VLC_TRUE;                var_Set( p_input, "rate-slower", val );                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 )            {                val.b_bool = VLC_TRUE;                var_Set( p_input, "prev-title", val );            }            else if( i_action == ACTIONID_TITLE_NEXT )            {                val.b_bool = VLC_TRUE;                var_Set( p_input, "next-title", val );            }            else if( i_action == ACTIONID_CHAPTER_PREV )            {                val.b_bool = VLC_TRUE;                var_Set( p_input, "prev-chapter", val );            }            else if( i_action == ACTIONID_CHAPTER_NEXT )            {                val.b_bool = VLC_TRUE;                var_Set( p_input, "next-chapter", val );            }            else if( i_action == ACTIONID_DISC_MENU )            {                vlc_value_t val; val.i_int = 2;                var_Set( p_input, "title  0", val);            }            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 )            {                p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                              FIND_ANYWHERE );                if( p_playlist )                {                    var_Get( p_input, "rate", &val );                    msg_Dbg( p_input, "rate %d", val.i_int );                    if( val.i_int != INPUT_RATE_DEFAULT )                    {                        /* Return to normal speed */                        val.i_int = INPUT_RATE_DEFAULT;                        var_Set( p_input, "rate", val );                    }                    else                    {                        ClearChannels( p_intf, p_vout );                        vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,                                      OSD_PLAY_ICON );                        playlist_Play( p_playlist );                    }                    vlc_object_release( p_playlist );                }            }        }    }}static int GetKey( intf_thread_t *p_intf){    vlc_mutex_lock( &p_intf->p_sys->change_lock );    if ( p_intf->p_sys->i_size == 0 )    {        vlc_mutex_unlock( &p_intf->p_sys->change_lock );        return -1;    }    else    {        int i_return = p_intf->p_sys->p_keys[ 0 ];        int i;        p_intf->p_sys->i_size--;        for ( i = 0; i < BUFFER_SIZE - 1; i++)        {            p_intf->p_sys->p_keys[ i ] = p_intf->p_sys->p_keys[ i + 1 ];        }        vlc_mutex_unlock( &p_intf->p_sys->change_lock );        return i_return;    }}/***************************************************************************** * KeyEvent: callback for keyboard events *****************************************************************************/static int KeyEvent( vlc_object_t *p_this, 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;    vlc_mutex_lock( &p_intf->p_sys->change_lock );    if ( p_intf->p_sys->i_size == BUFFER_SIZE )    {        msg_Warn( p_intf, "event buffer full, dropping keypress" );        vlc_mutex_unlock( &p_intf->p_sys->change_lock );        return VLC_EGENERIC;    }    else    {        p_intf->p_sys->p_keys[ p_intf->p_sys->i_size ] = newval.i_int;        p_intf->p_sys->i_size++;    }    vlc_mutex_unlock( &p_intf->p_sys->change_lock );    return VLC_SUCCESS;}static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,                        vlc_value_t oldval, vlc_value_t newval, void *p_data ){    vlc_t *p_vlc = (vlc_t *)p_this;    struct hotkey *p_hotkeys = p_vlc->p_hotkeys;    mtime_t i_date;    int i;    for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )    {        if( !strcmp( p_hotkeys[i].psz_action, psz_var ) )        {            p_hotkeys[i].i_key = newval.i_int;            /* do hotkey accounting */            i_date = mdate();            if( (p_hotkeys[i].i_delta_date > 0) &&                (p_hotkeys[i].i_delta_date <= (i_date - p_hotkeys[i].i_last_date) ) )                p_hotkeys[i].i_times = 0;            else                p_hotkeys[i].i_times++;            p_hotkeys[i].i_last_date = i_date;        }    }    return VLC_SUCCESS;}static void PlayBookmark( intf_thread_t *p_intf, int i_num ){    vlc_value_t val;    int i_position;    char psz_bookmark_name[11];    playlist_t *p_playlist =        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    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 );    if( p_playlist )    {        char *psz_bookmark = strdup( val.psz_string );        for( i_position = 0; i_position < p_playlist->i_size; i_position++)        {            if( !strcmp( psz_bookmark,                         p_playlist->pp_items[i_position]->input.psz_uri ) )            {                playlist_Goto( p_playlist, i_position );                break;            }        }        vlc_object_release( p_playlist );    }}static void SetBookmark( intf_thread_t *p_intf, int i_num ){    playlist_t *p_playlist =        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist )    {        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 )        {            config_PutPsz( p_intf, psz_bookmark_name,                           p_playlist->status.p_item->input.psz_uri);            msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,                           p_playlist->status.p_item->input.psz_uri);            config_SaveConfigFile( p_intf, "hotkeys" );        }        vlc_object_release( p_playlist );    }}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, "%s / %s",                         psz_time, psz_duration );    }    else if( i_seconds > 0 )    {        vout_OSDMessage( p_input, POSITION_TEXT_CHAN, psz_time );    }    if( !p_vout->p_parent_intf || 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_parent_intf || 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 + -