vlcproc.cpp
来自「VLC媒体播放程序」· C++ 代码 · 共 636 行 · 第 1/2 页
CPP
636 行
EnabledEvent( "time", true ); EnabledEvent( "stop", true ); EnabledEvent( "play", true ); EnabledEvent( "pause", false ); break; } // Refresh next and prev buttons if( PlayList->i_index == 0 || PlayList->i_size == 1 ) EnabledEvent( "prev", false ); else EnabledEvent( "prev", true ); if( PlayList->i_index == PlayList->i_size - 1 || PlayList->i_size == 1 ) EnabledEvent( "next", false ); else EnabledEvent( "next", true ); // Update file name if( PlayList->i_index >= 0 && PlayList->i_index != Sys->i_index ) { string long_name = PlayList->pp_items[PlayList->i_index]->psz_name; int pos = long_name.rfind( DIRECTORY_SEPARATOR, long_name.size() ); // Complete file name Thema->EvtBank->Get( "file_name" )->PostTextMessage( PlayList->pp_items[PlayList->i_index]->psz_name ); // File name without path Thema->EvtBank->Get( "title" )->PostTextMessage( PlayList->pp_items[PlayList->i_index]->psz_name + pos + 1 ); } // Update playlists if( PlayList->i_index != Sys->i_index || PlayList->i_size != Sys->i_size ) { Thema->EvtBank->Get( "playlist_refresh" )->PostSynchroMessage(); Sys->i_size = PlayList->i_size; Sys->i_index = PlayList->i_index; } vlc_mutex_unlock( &PlayList->object_lock ); } else { EnabledEvent( "time", false ); EnabledEvent( "stop", false ); EnabledEvent( "play", false ); EnabledEvent( "pause", false ); EnabledEvent( "prev", false ); EnabledEvent( "next", false ); // Update playlists if( Sys->i_size > 0 ) { Thema->EvtBank->Get( "playlist_refresh" )->PostSynchroMessage(); Sys->i_size = 0; } }}//---------------------------------------------------------------------------void VlcProc::EnabledEvent( string type, bool state ){ OSAPI_PostMessage( NULL, CTRL_ENABLED, (unsigned int) p_intf->p_sys->p_theme->EvtBank->Get( type ), (int)state ); if( !state ) { OSAPI_PostMessage( NULL, CTRL_SYNCHRO, (unsigned int) p_intf->p_sys->p_theme->EvtBank->Get( type ), (int)false ); }}//---------------------------------------------------------------------------//---------------------------------------------------------------------------// Common VLC procedures//---------------------------------------------------------------------------void VlcProc::LoadSkin(){ if( p_intf->p_sys->p_new_theme_file == NULL ) { p_intf->p_sys->p_dialogs->ShowOpenSkin( 0 /*none blocking*/ ); } else { // Place a new theme in the global structure, because it will // be filled by the parser // We save the old one to restore it in case of problem Theme *oldTheme = p_intf->p_sys->p_theme; p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf ); // Run the XML parser ThemeLoader *Loader = new ThemeLoader( p_intf ); if( Loader->Load( p_intf->p_sys->p_new_theme_file ) ) { // Everything went well msg_Dbg( p_intf, "New theme successfully loaded" ); delete (OSTheme *)oldTheme; // Show the theme p_intf->p_sys->p_theme->InitTheme(); p_intf->p_sys->p_theme->ShowTheme(); } else { msg_Warn( p_intf, "A problem occurred when loading the new theme," " restoring the previous one" ); delete (OSTheme *)p_intf->p_sys->p_theme; p_intf->p_sys->p_theme = oldTheme; // Show the theme p_intf->p_sys->p_theme->ShowTheme(); } delete Loader; // Uninitialize new theme free( p_intf->p_sys->p_new_theme_file ); p_intf->p_sys->p_new_theme_file = NULL; OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)true ); }}//---------------------------------------------------------------------------void VlcProc::DropFile( unsigned int param1, long param2 ){ // Get pointer to file char *FileName = (char *)param1; // Add the new file to the playlist if( p_intf->p_sys->p_playlist != NULL ) { if( param2 == 0 ) { // Enqueue the item playlist_Add( p_intf->p_sys->p_playlist, FileName, FileName, PLAYLIST_APPEND, PLAYLIST_END ); } else { // Enqueue and play the item playlist_Add( p_intf->p_sys->p_playlist, FileName, FileName, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); } } // VLC_DROP must be called with a pointer to a char else it will // ******** SEGFAULT ******** // The delete is here because the processus in asynchronous delete[] FileName; // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------//---------------------------------------------------------------------------// Stream Control//---------------------------------------------------------------------------void VlcProc::PauseStream(){ if( p_intf->p_sys->p_playlist == NULL ) return; playlist_Command( p_intf->p_sys->p_playlist, PLAYLIST_PAUSE, 0 ); // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------void VlcProc::PlayStream(){ if( p_intf->p_sys->p_playlist == NULL ) return; if( !p_intf->p_sys->p_playlist->i_size ) { p_intf->p_sys->p_dialogs->ShowOpen( true ); InterfaceRefresh(); return; } playlist_Play( p_intf->p_sys->p_playlist ); // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------void VlcProc::StopStream(){ if( p_intf->p_sys->p_playlist == NULL ) return; playlist_Stop( p_intf->p_sys->p_playlist ); // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------void VlcProc::NextStream(){ if( p_intf->p_sys->p_playlist == NULL ) return; playlist_Next( p_intf->p_sys->p_playlist ); // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------void VlcProc::PrevStream(){ if( p_intf->p_sys->p_playlist == NULL ) return; playlist_Prev( p_intf->p_sys->p_playlist ); // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------void VlcProc::SlowStream(){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-slower", val ); vlc_object_release( p_input ); }}//---------------------------------------------------------------------------void VlcProc::FastStream(){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-faster", val ); vlc_object_release( p_input ); }}//---------------------------------------------------------------------------void VlcProc::MoveStream( long Pos ){ if( p_intf->p_sys->p_input == NULL ) return; off_t i_seek = (off_t)(Pos * p_intf->p_sys->p_input->stream.p_selected_area->i_size / SLIDER_RANGE); input_Seek( p_intf->p_sys->p_input, i_seek, INPUT_SEEK_SET ); // Refresh interface InterfaceRefresh();}//---------------------------------------------------------------------------//---------------------------------------------------------------------------// Fullscreen//---------------------------------------------------------------------------void VlcProc::FullScreen(){ vout_thread_t *p_vout; if( p_intf->p_sys->p_input == NULL ) return; p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input, VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout == NULL ) return; p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; vlc_object_release( p_vout );}//---------------------------------------------------------------------------//---------------------------------------------------------------------------// Volume Control//---------------------------------------------------------------------------void VlcProc::ChangeVolume( unsigned int msg, long param ){ audio_volume_t volume; switch( msg ) { case VLC_VOLUME_MUTE: aout_VolumeMute( p_intf, NULL ); break; case VLC_VOLUME_UP: aout_VolumeUp( p_intf, 1, NULL ); break; case VLC_VOLUME_DOWN: aout_VolumeDown( p_intf, 1, NULL ); break; case VLC_VOLUME_SET: aout_VolumeSet( p_intf, param * (AOUT_VOLUME_DEFAULT * 2) / SLIDER_RANGE ); break; } aout_VolumeGet( p_intf, &volume );}//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?