📄 bookmarks.cpp
字号:
}BookmarksDialog::~BookmarksDialog(){ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { var_DelCallback( p_playlist, "playlist-current", PlaylistChanged, this ); vlc_object_release( p_playlist ); }}/***************************************************************************** * Private methods. *****************************************************************************/wxWindow *BookmarksDialog( intf_thread_t *p_intf, wxWindow *p_parent ){ return new class BookmarksDialog( p_intf, p_parent );}void BookmarksDialog::Update(){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) return; seekpoint_t **pp_bookmarks; int i_bookmarks; list_ctrl->DeleteAllItems(); if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks ) != VLC_SUCCESS ) { vlc_object_release( p_input ); return; } for( int i = 0; i < i_bookmarks; i++ ) { list_ctrl->InsertItem( i, wxL2U( pp_bookmarks[i]->psz_name ) ); /* FIXME: see if we can use the 64 bits integer format string */ list_ctrl->SetItem( i, 1, wxString::Format(wxT("%d"), (int)(pp_bookmarks[i]->i_byte_offset) ) ); list_ctrl->SetItem( i, 2, wxString::Format(wxT("%d"), (int)(pp_bookmarks[i]->i_time_offset / 1000000) ) ); } vlc_object_release( p_input );}bool BookmarksDialog::Show( bool show ){ Update(); return wxFrame::Show( show );}void BookmarksDialog::OnClose( wxCloseEvent& event ){ Hide();}void BookmarksDialog::OnAdd( wxCommandEvent& event ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) return; seekpoint_t bookmark; vlc_value_t pos; bookmark.psz_name = NULL; bookmark.i_byte_offset = 0; bookmark.i_time_offset = 0; var_Get( p_input, "position", &pos ); bookmark.psz_name = NULL; input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset ); var_Get( p_input, "time", &pos ); bookmark.i_time_offset = pos.i_time; input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark ); vlc_object_release( p_input ); Update();}void BookmarksDialog::OnDel( wxCommandEvent& event ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) return; int i_focused = list_ctrl->GetFocusedItem(); if( i_focused >= 0 ) { input_Control( p_input, INPUT_DEL_BOOKMARK, i_focused ); } vlc_object_release( p_input ); Update();}void BookmarksDialog::OnClear( wxCommandEvent& event ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) return; input_Control( p_input, INPUT_CLEAR_BOOKMARKS ); vlc_object_release( p_input ); Update();}void BookmarksDialog::OnExtract( wxCommandEvent& event ){ long i_first = list_ctrl->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); long i_second = list_ctrl->GetNextItem( i_first, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); if( i_first == -1 || i_second == -1 ) { wxMessageBox( wxU(_("You must select two bookmarks") ), wxU(_("Invalid selection") ), wxICON_WARNING | wxOK, this ); return; } input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) { wxMessageBox( wxU(_("The stream must be playing or paused for " "bookmarks to work" ) ), wxU(_("No input found")), wxICON_WARNING | wxOK, this ); return; } seekpoint_t **pp_bookmarks; int i_bookmarks ; if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks ) != VLC_SUCCESS ) { vlc_object_release( p_input ); return; } if( i_first < i_bookmarks && i_second <= i_bookmarks ) { WizardDialog *p_wizard_dialog = new WizardDialog( p_intf, this, p_input->input.p_item->psz_uri, pp_bookmarks[i_first]->i_time_offset/1000000, pp_bookmarks[i_second]->i_time_offset/1000000 ); vlc_object_release( p_input ); if( p_wizard_dialog ) { p_wizard_dialog->Run(); delete p_wizard_dialog; } } else { vlc_object_release( p_input ); }}void BookmarksDialog::OnActivateItem( wxListEvent& event ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) return; input_Control( p_input, INPUT_SET_BOOKMARK, event.GetIndex() ); vlc_object_release( p_input );}void BookmarksDialog::OnEdit( wxCommandEvent& event ){ input_thread_t *p_old_input; input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) return; seekpoint_t **pp_bookmarks; int i_bookmarks; if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks ) != VLC_SUCCESS ) { vlc_object_release( p_input ); return; } p_old_input = p_input; vlc_object_release( p_input ); long i_first = list_ctrl->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); if( i_first > -1 && i_first <= i_bookmarks ) { BookmarkEditDialog *p_bmk_edit; p_bmk_edit = new BookmarkEditDialog( p_intf, this, pp_bookmarks[i_first]); if( p_bmk_edit->ShowModal() == wxID_OK ) { p_input =(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) { wxMessageBox( wxU( _("No input found. The stream must be " "playing or paused for bookmarks to work.") ), wxU( _("No input") ), wxICON_WARNING | wxOK, this ); return; } if( p_old_input != p_input ) { wxMessageBox( wxU( _("Input has changed, unable to save " "bookmark. Use \"pause\" while editing " "bookmarks to keep the same input.") ), wxU( _("Input has changed ") ), wxICON_WARNING | wxOK, this ); vlc_object_release( p_input ); return; } fprintf(stderr,"Changing %i\n",i_first ); if( input_Control( p_input, INPUT_CHANGE_BOOKMARK, p_bmk_edit->p_seekpoint, i_first ) != VLC_SUCCESS ) { vlc_object_release( p_input ); return; } Update(); vlc_object_release( p_input ); } }}void BookmarksDialog::OnUpdate( wxCommandEvent &event ){ Update();}/***************************************************************************** * PlaylistChanged: callback triggered by the intf-change playlist variable * We don't rebuild the playlist directly here because we don't want the * caller to block for a too long time. *****************************************************************************/static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable, vlc_value_t oval, vlc_value_t nval, void *param ){ class BookmarksDialog *p_dialog = (class BookmarksDialog *)param; wxCommandEvent bookmarks_event( wxEVT_BOOKMARKS, 0 ); p_dialog->AddPendingEvent( bookmarks_event ); return VLC_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -