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

📄 rc.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 5 页
字号:
        {            if ( *newval.psz_string )            {                /* Set. */                val.i_int = atoi( newval.psz_string );                var_Set( p_input, "title", val );            }            else            {                vlc_value_t val_list;                /* Get. */                var_Get( p_input, "title", &val );                var_Change( p_input, "title", VLC_VAR_GETCHOICES,                            &val_list, NULL );                msg_rc( "Currently playing title %d/%d.",                        val.i_int, val_list.p_list->i_count );                var_Change( p_this, "title", VLC_VAR_FREELIST,                            &val_list, NULL );            }        }        else if( !strcmp( psz_cmd, "title_n" ) )        {            val.b_bool = true;            var_Set( p_input, "next-title", val );        }        else if( !strcmp( psz_cmd, "title_p" ) )        {            val.b_bool = true;            var_Set( p_input, "prev-title", val );        }        vlc_object_release( p_input );        return VLC_SUCCESS;    }    else if(    !strcmp( psz_cmd, "atrack" )             || !strcmp( psz_cmd, "vtrack" )             || !strcmp( psz_cmd, "strack" ) )    {        const char *psz_variable;        vlc_value_t val_name;        int i_error;        if( !strcmp( psz_cmd, "atrack" ) )        {            psz_variable = "audio-es";        }        else if( !strcmp( psz_cmd, "vtrack" ) )        {            psz_variable = "video-es";        }        else        {            psz_variable = "spu-es";        }        /* Get the descriptive name of the variable */        var_Change( p_input, psz_variable, VLC_VAR_GETTEXT,                     &val_name, NULL );        if( !val_name.psz_string ) val_name.psz_string = strdup(psz_variable);        if( newval.psz_string && *newval.psz_string )        {            /* set */            vlc_value_t val;            val.i_int = atoi( newval.psz_string );            i_error = var_Set( p_input, psz_variable, val );        }        else        {            /* get */            vlc_value_t val, text;            int i, i_value;            if ( var_Get( p_input, psz_variable, &val ) < 0 )            {                vlc_object_release( p_input );                return VLC_EGENERIC;            }            i_value = val.i_int;            if ( var_Change( p_input, psz_variable,                             VLC_VAR_GETLIST, &val, &text ) < 0 )            {                vlc_object_release( p_input );                return VLC_EGENERIC;            }            msg_rc( "+----[ %s ]", val_name.psz_string );            for ( i = 0; i < val.p_list->i_count; i++ )            {                if ( i_value == val.p_list->p_values[i].i_int )                    msg_rc( "| %i - %s *", val.p_list->p_values[i].i_int,                            text.p_list->p_values[i].psz_string );                else                    msg_rc( "| %i - %s", val.p_list->p_values[i].i_int,                            text.p_list->p_values[i].psz_string );            }            var_Change( p_input, psz_variable, VLC_VAR_FREELIST,                        &val, &text );            msg_rc( "+----[ end of %s ]", val_name.psz_string );            free( val_name.psz_string );            i_error = VLC_SUCCESS;        }        vlc_object_release( p_input );        return i_error;    }    /* Never reached. */    vlc_object_release( p_input );    return VLC_EGENERIC;}static void print_playlist( intf_thread_t *p_intf, playlist_item_t *p_item, int i_level ){    int i;    char psz_buffer[MSTRTIME_MAX_SIZE];    for( i = 0; i< p_item->i_children; i++ )    {        if( p_item->pp_children[i]->p_input->i_duration != -1 )        {            secstotimestr( psz_buffer, p_item->pp_children[i]->p_input->i_duration / 1000000 );            msg_rc( "|%*s- %s (%s)", 2 * i_level, "", p_item->pp_children[i]->p_input->psz_name, psz_buffer );        }        else            msg_rc( "|%*s- %s", 2 * i_level, "", p_item->pp_children[i]->p_input->psz_name );        if( p_item->pp_children[i]->i_children >= 0 )            print_playlist( p_intf, p_item->pp_children[i], i_level + 1 );    }}static int Playlist( vlc_object_t *p_this, char const *psz_cmd,                     vlc_value_t oldval, vlc_value_t newval, void *p_data ){    VLC_UNUSED(oldval); VLC_UNUSED(p_data);    vlc_value_t val;    intf_thread_t *p_intf = (intf_thread_t*)p_this;    playlist_t *p_playlist = pl_Yield( p_this );    PL_LOCK;    if( p_playlist->p_input )    {        var_Get( p_playlist->p_input, "state", &val );        if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )        {            msg_rc( _("Type 'menu select' or 'pause' to continue.") );            vlc_object_release( p_playlist );            PL_UNLOCK;            return VLC_EGENERIC;        }    }    PL_UNLOCK;    /* Parse commands that require a playlist */    if( !strcmp( psz_cmd, "prev" ) )    {        playlist_Prev( p_playlist );    }    else if( !strcmp( psz_cmd, "next" ) )    {        playlist_Next( p_playlist );    }    else if( !strcmp( psz_cmd, "play" ) )    {        msg_Warn( p_playlist, "play" );        playlist_Play( p_playlist );    }    else if( !strcmp( psz_cmd, "repeat" ) )    {        bool b_update = true;        var_Get( p_playlist, "repeat", &val );        if( strlen( newval.psz_string ) > 0 )        {            if ( ( !strncmp( newval.psz_string, "on", 2 ) && ( val.b_bool == true ) ) ||                 ( !strncmp( newval.psz_string, "off", 3 ) && ( val.b_bool == false ) ) )            {                b_update = false;            }        }        if ( b_update )        {            val.b_bool = !val.b_bool;            var_Set( p_playlist, "repeat", val );        }        msg_rc( "Setting repeat to %d", val.b_bool );    }    else if( !strcmp( psz_cmd, "loop" ) )    {        bool b_update = true;        var_Get( p_playlist, "loop", &val );        if( strlen( newval.psz_string ) > 0 )        {            if ( ( !strncmp( newval.psz_string, "on", 2 ) && ( val.b_bool == true ) ) ||                 ( !strncmp( newval.psz_string, "off", 3 ) && ( val.b_bool == false ) ) )            {                b_update = false;            }        }        if ( b_update )        {            val.b_bool = !val.b_bool;            var_Set( p_playlist, "loop", val );        }        msg_rc( "Setting loop to %d", val.b_bool );    }    else if( !strcmp( psz_cmd, "random" ) )    {        bool b_update = true;        var_Get( p_playlist, "random", &val );        if( strlen( newval.psz_string ) > 0 )        {            if ( ( !strncmp( newval.psz_string, "on", 2 ) && ( val.b_bool == true ) ) ||                 ( !strncmp( newval.psz_string, "off", 3 ) && ( val.b_bool == false ) ) )            {                b_update = false;            }        }        if ( b_update )        {            val.b_bool = !val.b_bool;            var_Set( p_playlist, "random", val );        }        msg_rc( "Setting random to %d", val.b_bool );    }    else if (!strcmp( psz_cmd, "goto" ) )    {        int i_pos = atoi( newval.psz_string );        /* The playlist stores 2 times the same item: onelevel & category */        int i_size = p_playlist->items.i_size / 2;        if( i_pos <= 0 )            msg_rc( _("Error: `goto' needs an argument greater than zero.") );        else if( i_pos <= i_size )        {            playlist_item_t *p_item, *p_parent;            p_item = p_parent = p_playlist->items.p_elems[i_pos*2-1];            while( p_parent->p_parent )                p_parent = p_parent->p_parent;            playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked,                    p_parent, p_item );        }        else            msg_rc( _("Playlist has only %d elements"), i_size );    }    else if( !strcmp( psz_cmd, "stop" ) )    {        playlist_Stop( p_playlist );    }    else if( !strcmp( psz_cmd, "clear" ) )    {        playlist_Stop( p_playlist );        playlist_Clear( p_playlist, pl_Unlocked );    }    else if( !strcmp( psz_cmd, "add" ) &&             newval.psz_string && *newval.psz_string )    {        input_item_t *p_item = parse_MRL( p_intf, newval.psz_string );        if( p_item )        {            msg_rc( "Trying to add %s to playlist.", newval.psz_string );            int i_ret =playlist_AddInput( p_playlist, p_item,                     PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, true,                     pl_Unlocked );            vlc_gc_decref( p_item );            if( i_ret != VLC_SUCCESS )            {                return VLC_EGENERIC;            }        }    }    else if( !strcmp( psz_cmd, "enqueue" ) &&             newval.psz_string && *newval.psz_string )    {        input_item_t *p_item = parse_MRL( p_intf, newval.psz_string );        if( p_item )        {            msg_rc( "trying to enqueue %s to playlist", newval.psz_string );            if( playlist_AddInput( p_playlist, p_item,                               PLAYLIST_APPEND, PLAYLIST_END, true,                               pl_Unlocked ) != VLC_SUCCESS )            {                return VLC_EGENERIC;            }        }    }    else if( !strcmp( psz_cmd, "playlist" ) )    {        msg_rc( "+----[ Playlist ]" );        print_playlist( p_intf, p_playlist->p_root_category, 0 );        msg_rc( "+----[ End of playlist ]" );    }    else if( !strcmp( psz_cmd, "sort" ))    {        playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_onelevel,                                    SORT_ARTIST, ORDER_NORMAL );    }    else if( !strcmp( psz_cmd, "status" ) )    {        if( p_playlist->p_input )        {            /* Replay the current state of the system. */            char *psz_uri =                    input_item_GetURI( input_GetItem( p_playlist->p_input ) );            msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );            free( psz_uri );            msg_rc( STATUS_CHANGE "( audio volume: %d )",                    config_GetInt( p_intf, "volume" ));            PL_LOCK;            switch( p_playlist->status.i_status )            {                case PLAYLIST_STOPPED:                    msg_rc( STATUS_CHANGE "( stop state: 5 )" );                    break;                case PLAYLIST_RUNNING:                    msg_rc( STATUS_CHANGE "( play state: 3 )" );                    break;                case PLAYLIST_PAUSED:                    msg_rc( STATUS_CHANGE "( pause state: 4 )" );                    break;                default:                    msg_rc( STATUS_CHANGE "( unknown state: -1 )" );                    break;            }            PL_UNLOCK;        }    }    /*     * sanity check     */    else    {        msg_rc( "unknown command!" );    }    vlc_object_release( p_playlist );    return VLC_SUCCESS;}static int Quit( vlc_object_t *p_this, char const *psz_cmd,                 vlc_value_t oldval, vlc_value_t newval, void *p_data ){    VLC_UNUSED(p_data); VLC_UNUSED(psz_cmd);    VLC_UNUSED(oldval); VLC_UNUSED(newval);    playlist_t *p_playlist;    p_playlist = pl_Yield( p_this );    playlist_Stop( p_playlist );    vlc_object_release( p_playlist );        vlc_object_kill( p_this->p_libvlc );    return VLC_SUCCESS;}static int Intf( vlc_object_t *p_this, char const *psz_cmd,                 vlc_value_t oldval, vlc_value_t newval, void *p_data ){    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);    intf_thread_t *p_newintf = NULL;    p_newintf = intf_Create( p_this->p_libvlc, newval.psz_string );    if( p_newintf )    {        if( intf_RunThread( p_newintf ) )        {            vlc_object_detach( p_newintf );            vlc_object_release( p_newintf );        }    }

⌨️ 快捷键说明

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