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

📄 playlist.cpp

📁 video linux conference
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );        var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );        var_DelCallback( p_playlist, "item-append", ItemAppended, this );        var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );        /* ...and rebuild it */        LockPlaylist( p_intf->p_sys, p_playlist );    }    i_saved_id = -1;    p_view = playlist_ViewFind( p_playlist, i_current_view ); /* FIXME */    /* HACK we should really get new*/    treectrl->DeleteAllItems();    treectrl->AddRoot( wxU(_("root" )), -1, -1,                         new PlaylistItem( p_view->p_root) );    wxTreeItemId root = treectrl->GetRootItem();    UpdateNode( p_view->p_root, root );    int i_count = CountItems( treectrl->GetRootItem() );    if( i_count < p_playlist->i_size && !b_changed_view )    {        i_current_view = VIEW_CATEGORY;        b_changed_view = VLC_TRUE;        Rebuild( VLC_FALSE );    }    else if( i_count != p_playlist->i_size )    {        statusbar->SetStatusText( wxString::Format( wxU(_(                                  "%i items in playlist (%i not shown)")),                                  p_playlist->i_size,                                  p_playlist->i_size - i_count ) );    }    else    {        statusbar->SetStatusText( wxString::Format( wxU(_(                                  "%i items in playlist")),                                  p_playlist->i_size ), 0 );    }    if( b_root )    {        /* Put callbacks back online */        var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );        var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );        var_AddCallback( p_playlist, "item-change", ItemChanged, this );        var_AddCallback( p_playlist, "item-append", ItemAppended, this );        var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );        UnlockPlaylist( p_intf->p_sys, p_playlist );    }}void Playlist::ShowPlaylist( bool show ){    if( show ) Rebuild( VLC_TRUE );    Show( show );}/* This function is called on a regular basis */void Playlist::UpdatePlaylist(){    i_update_counter++;    /* If the playlist isn't show there's no need to update it */    if( !IsShown() ) return;    if( this->b_need_update )    {        this->b_need_update = VLC_FALSE;        Rebuild( VLC_TRUE );    }    /* Updating the playing status every 0.5s is enough */    if( i_update_counter % 5 ) return;}/***************************************************************************** * Private methods. *****************************************************************************/void Playlist::DeleteTreeItem( wxTreeItemId item ){   PlaylistItem *p_wxitem;   playlist_item_t *p_item;   p_wxitem = (PlaylistItem *)treectrl->GetItemData( item );   LockPlaylist( p_intf->p_sys, p_playlist );   p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );   if( !p_item )   {       UnlockPlaylist( p_intf->p_sys, p_playlist );       return;   }   if( p_item->i_children == -1 )   {       UnlockPlaylist( p_intf->p_sys, p_playlist );       DeleteItem( p_item->input.i_id );   }   else   {       UnlockPlaylist( p_intf->p_sys, p_playlist );       DeleteNode( p_item );   }   RemoveItem( item );}void Playlist::DeleteItem( int item_id ){    playlist_LockDelete( p_playlist, item_id );}void Playlist::DeleteNode( playlist_item_t *p_item ){    playlist_NodeDelete( p_playlist, p_item, VLC_TRUE , VLC_FALSE );}void Playlist::OnMenuClose( wxCommandEvent& event ){    wxCloseEvent cevent;    OnClose(cevent);}void Playlist::OnClose( wxCloseEvent& WXUNUSED(event) ){    Hide();}void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ){    struct {        char *psz_desc;        char *psz_filter;        char *psz_module;    } formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" }};    wxString filter = wxT("");    if( p_playlist->i_size == 0 )    {        wxMessageBox( wxU(_("Playlist is empty") ), wxU(_("Can't save")),                      wxICON_WARNING | wxOK, this );        return;    }    for( unsigned int i = 0; i < sizeof(formats)/sizeof(formats[0]); i++)    {        filter.Append( wxU(formats[i].psz_desc) );        filter.Append( wxT("|") );        filter.Append( wxU(formats[i].psz_filter) );        filter.Append( wxT("|") );    }    wxFileDialog dialog( this, wxU(_("Save playlist")),                         wxT(""), wxT(""), filter, wxSAVE );    if( dialog.ShowModal() == wxID_OK )    {        if( dialog.GetPath().mb_str() )        {            playlist_Export( p_playlist, dialog.GetPath().mb_str(),                             formats[dialog.GetFilterIndex()].psz_module );        }    }}void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) ){    wxFileDialog dialog( this, wxU(_("Open playlist")), wxT(""), wxT(""),        wxT("All playlists|*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u"), wxOPEN );    if( dialog.ShowModal() == wxID_OK )    {        playlist_Import( p_playlist, dialog.GetPath().mb_str() );    }}void Playlist::OnAddFile( wxCommandEvent& WXUNUSED(event) ){    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_SIMPLE, 0, 0 );}void Playlist::OnAddDir( wxCommandEvent& WXUNUSED(event) ){    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_DIRECTORY, 0, 0 );}void Playlist::OnAddMRL( wxCommandEvent& WXUNUSED(event) ){    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE, 0, 0 );}/******************************************************************** * Sorting functions ********************************************************************/void Playlist::OnSort( wxCommandEvent& event ){    PlaylistItem *p_wxitem;    p_wxitem = (PlaylistItem *)treectrl->GetItemData( treectrl->GetRootItem() );    LockPlaylist( p_intf->p_sys, p_playlist );    switch( event.GetId() )    {        case SortTitle_Event:            playlist_RecursiveNodeSort( p_playlist, playlist_ItemGetById( p_playlist, p_wxitem->i_id ),                                        SORT_TITLE_NODES_FIRST, ORDER_NORMAL );            break;        case RSortTitle_Event:            playlist_RecursiveNodeSort( p_playlist, playlist_ItemGetById( p_playlist, p_wxitem->i_id ),                                        SORT_TITLE_NODES_FIRST, ORDER_REVERSE );    }    UnlockPlaylist( p_intf->p_sys, p_playlist );    Rebuild( VLC_TRUE );}/********************************************************************** * Search functions (user) **********************************************************************//*void Playlist::OnSearchTextChange( wxCommandEvent& WXUNUSED(event) ){   search_button->SetDefault();}*/void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ){    wxString search_string = search_text->GetValue();    vlc_bool_t pb_found = VLC_FALSE;    wxTreeItemId found =     FindItemByName( treectrl->GetRootItem(), search_string,                     search_current, &pb_found );    if( !found.IsOk() )    {        wxTreeItemId dummy;        search_current = dummy;        found =  FindItemByName( treectrl->GetRootItem(), search_string,                                 search_current, &pb_found );    }    if( found.IsOk() )    {        search_current = found;        treectrl->EnsureVisible( found );        treectrl->SelectItem( found, true );    }}/********************************************************************** * Selection functions **********************************************************************/void Playlist::RecursiveDeleteSelection(  wxTreeItemId root ){    wxTreeItemIdValue cookie;    wxTreeItemId child = treectrl->GetFirstChild( root, cookie );    while( child.IsOk() )    {        if( treectrl->ItemHasChildren( child ) )        {            RecursiveDeleteSelection( child );            if( treectrl->IsSelected(child ) ) DeleteTreeItem( child );        }        else if( treectrl->IsSelected( child ) )            DeleteTreeItem( child );        child = treectrl->GetNextChild( root, cookie );    }}void Playlist::OnDeleteSelection( wxCommandEvent& WXUNUSED(event) ){    RecursiveDeleteSelection( treectrl->GetRootItem() );}/********************************************************************** * Playlist mode functions **********************************************************************/void Playlist::OnRandom( wxCommandEvent& event ){    vlc_value_t val;    val.b_bool = event.IsChecked();    var_Set( p_playlist, "random", val);}void Playlist::OnLoop( wxCommandEvent& event ){    vlc_value_t val;    val.b_bool = event.IsChecked();    var_Set( p_playlist, "loop", val);}void Playlist::OnRepeat( wxCommandEvent& event ){    vlc_value_t val;    val.b_bool = event.IsChecked();    var_Set( p_playlist, "repeat", val);}/******************************************************************** * Event ********************************************************************/void Playlist::OnActivateItem( wxTreeEvent& event ){    playlist_item_t *p_item,*p_node,*p_item2,*p_node2;    PlaylistItem *p_wxitem = (PlaylistItem *)treectrl->GetItemData(                                                            event.GetItem() );    wxTreeItemId parent = treectrl->GetItemParent( event.GetItem() );    PlaylistItem *p_wxparent = (PlaylistItem *)treectrl->GetItemData( parent );    LockPlaylist( p_intf->p_sys, p_playlist );    if( !( p_wxitem && p_wxparent ) ) return;    p_item2 = playlist_ItemGetById(p_playlist, p_wxitem->i_id);    p_node2 = playlist_ItemGetById(p_playlist, p_wxparent->i_id);    if( p_item2 && p_item2->i_children == -1 )    {        p_node = p_node2;        p_item = p_item2;    }    else    {        p_node = p_item2;        if( p_node && p_node->i_children > 0 &&            p_node->pp_children[0]->i_children == -1)        {            p_item = p_node->pp_children[0];        }        else        {            p_item = NULL;        }    }    playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, i_current_view,                      p_node, p_item );    UnlockPlaylist( p_intf->p_sys, p_playlist );}void Playlist::OnKeyDown( wxTreeEvent& event ){    long keycode = event.GetKeyCode();    /* Delete selected items */    if( keycode == WXK_BACK || keycode == WXK_DELETE )    {        /* We send a dummy event */        OnDeleteSelection( event );    }    else    {        event.Skip();    }}void Playlist::OnEnDis( wxCommandEvent& event ){    msg_Warn( p_intf, "not implemented" );}/********************************************************************** * Menu **********************************************************************/void Playlist::OnMenuOpen( wxMenuEvent& event){#if defined( __WXMSW__ )#   define GetEventObject GetMenu

⌨️ 快捷键说明

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