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

📄 interfacewindow.cpp

📁 VLC媒体播放程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            /* toggle between pause and play */            if (playback_status > UNDEF_S)            {                /* pause if currently playing */                if ( playback_status == PLAYING_S )                {                    p_wrapper->PlaylistPause();                }                else                {                    p_wrapper->PlaylistPlay();                }            }            else            {                /* Play a new file */                p_wrapper->PlaylistPlay();            }                break;            case HEIGHTH_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE * 8 );            break;        case QUARTER_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE * 4 );            break;        case HALF_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE * 2 );            break;        case NORMAL_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE );            break;        case TWICE_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE / 2 );            break;        case FOUR_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE / 4 );            break;        case HEIGHT_PLAY:            p_wrapper->InputSetRate( DEFAULT_RATE / 8 );            break;        case SEEK_PLAYBACK:            /* handled by semaphores */            break;        // volume related messages        case VOLUME_CHG:            /* adjust the volume */            if (playback_status > UNDEF_S)            {                p_wrapper->SetVolume( p_mediaControl->GetVolume() );                p_mediaControl->SetMuted( p_wrapper->IsMuted() );            }            break;            case VOLUME_MUTE:            // toggle muting            if( p_wrapper->IsMuted() )                p_wrapper->VolumeRestore();            else                p_wrapper->VolumeMute();            p_mediaControl->SetMuted( p_wrapper->IsMuted() );            break;            case SELECT_CHANNEL:            if ( playback_status > UNDEF_S )            {                int32 channel;                if ( p_message->FindInt32( "channel", &channel ) == B_OK )                {                    p_wrapper->ToggleLanguage( channel );                }            }            break;            case SELECT_SUBTITLE:            if ( playback_status > UNDEF_S )            {                int32 subtitle;                if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK )                     p_wrapper->ToggleSubtitle( subtitle );            }            break;            // specific navigation messages        case PREV_TITLE:        {            p_wrapper->PrevTitle();            break;        }        case NEXT_TITLE:        {            p_wrapper->NextTitle();            break;        }        case NAVIGATE_MENU:        	p_wrapper->ToggleTitle( 0 );        	break;        case TOGGLE_TITLE:            if ( playback_status > UNDEF_S )            {                int32 index;                if( p_message->FindInt32( "index", &index ) == B_OK )                    p_wrapper->ToggleTitle( index );            }            break;        case PREV_CHAPTER:        {            p_wrapper->PrevChapter();            break;        }        case NEXT_CHAPTER:        {            p_wrapper->NextChapter();            break;        }        case TOGGLE_CHAPTER:            if ( playback_status > UNDEF_S )            {                int32 index;                if( p_message->FindInt32( "index", &index ) == B_OK )                    p_wrapper->ToggleChapter( index );            }            break;        case PREV_FILE:            p_wrapper->PlaylistPrev();            break;        case NEXT_FILE:            p_wrapper->PlaylistNext();            break;        // general next/prev functionality (skips to whatever makes most sense)        case NAVIGATE_PREV:            p_wrapper->NavigatePrev();            break;        case NAVIGATE_NEXT:            p_wrapper->NavigateNext();            break;        // drag'n'drop and system messages        case MSG_SOUNDPLAY:        	// convert soundplay drag'n'drop message (containing paths)        	// to normal message (containing refs)        	{	        	const char* path;	        	for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ )	        	{	        		entry_ref ref;	        		if ( get_ref_for_path( path, &ref ) == B_OK )		        		p_message->AddRef( "refs", &ref );	        	}        	}        	// fall through        case B_REFS_RECEIVED:        case B_SIMPLE_DATA:            {                /* file(s) opened by the File menu -> append to the playlist;                 * file(s) opened by drag & drop -> replace playlist;                 * file(s) opened by 'shift' + drag & drop -> append */                bool replace = false;                bool reverse = false;                if ( p_message->WasDropped() )                {                    replace = !( modifiers() & B_SHIFT_KEY );                    reverse = true;                }                                    // build list of files to be played from message contents                entry_ref ref;                BList files;                                // if we should parse sub-folders as well           		bool askedAlready = false;           		bool parseSubFolders = askedAlready;           		// traverse refs in reverse order           		int32 count;           		type_code dummy;           		if ( p_message->GetInfo( "refs", &dummy, &count ) == B_OK && count > 0 )           		{           			int32 i = reverse ? count - 1 : 0;           			int32 increment = reverse ? -1 : 1;	                for ( ; p_message->FindRef( "refs", i, &ref ) == B_OK; i += increment )	                {	                    BPath path( &ref );	                    if ( path.InitCheck() == B_OK )	                    {	                        bool add = true;	                        // has the user dropped a folder?	                        BDirectory dir( &ref );	                        if ( dir.InitCheck() == B_OK)	                        {		                        // has the user dropped a dvd disk icon?								if ( dir.IsRootDirectory() )								{									BVolumeRoster volRoster;									BVolume vol;									BDirectory volumeRoot;									status_t status = volRoster.GetNextVolume( &vol );									while ( status == B_NO_ERROR )									{										if ( vol.GetRootDirectory( &volumeRoot ) == B_OK											 && dir == volumeRoot )										{											BString volumeName;											BString deviceName;											bool isCDROM;											if ( get_volume_info( vol, volumeName, isCDROM, deviceName )												 && isCDROM )											{												BMessage msg( OPEN_DVD );												msg.AddString( "device", deviceName.String() );												PostMessage( &msg );												add = false;											}									 		break;										}										else										{									 		vol.Unset();											status = volRoster.GetNextVolume( &vol );										}									}								}	                        	if ( add )	                        	{	                        		add = false;	                        		dir.Rewind();	// defensive programming	                        		BEntry entry;									collect_folder_contents( dir, files,															 parseSubFolders,															 askedAlready,															 entry );	                        	}	                        }	                        if ( add )	                        {	                        	BString* string = new BString( path.Path() );	                        	if ( !files.AddItem( string, 0 ) )	                        		delete string;	// at least don't leak	                        }	                    }	                }	                // give the list to VLC	                // BString objects allocated here will be deleted there	                int32 index;	                if ( p_message->FindInt32("drop index", &index) != B_OK )	                	index = -1;	                p_wrapper->OpenFiles( &files, replace, index );	                _UpdatePlaylist();           		}            }            break;        case OPEN_PREFERENCES:        {            if( fPreferencesWindow->Lock() )            {                if (fPreferencesWindow->IsHidden())                    fPreferencesWindow->Show();                else                    fPreferencesWindow->Activate();                fPreferencesWindow->Unlock();            }            break;        }        case OPEN_MESSAGES:        {            if( fMessagesWindow->Lock() )            {                if (fMessagesWindow->IsHidden())                    fMessagesWindow->Show();                else                    fMessagesWindow->Activate();                fMessagesWindow->Unlock();            }            break;        }        case MSG_UPDATE:        	UpdateInterface();        	break;        default:            BWindow::MessageReceived( p_message );            break;    }}/***************************************************************************** * InterfaceWindow::QuitRequested *****************************************************************************/bool InterfaceWindow::QuitRequested(){    p_wrapper->PlaylistStop();    p_mediaControl->SetStatus(UNDEF_S, DEFAULT_RATE); 	_StoreSettings();       p_intf->b_die = 1;    return( true );}/***************************************************************************** * InterfaceWindow::UpdateInterface *****************************************************************************/void InterfaceWindow::UpdateInterface(){    if( p_wrapper->HasInput() )    {        if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK )        {            p_wrapper->SetTimeAsFloat( p_mediaControl->GetSeekTo() );        }        else if ( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK )        {            p_mediaControl->SetEnabled( true );            bool hasTitles = p_wrapper->HasTitles();            bool hasChapters = p_wrapper->HasChapters();            p_mediaControl->SetStatus( p_wrapper->InputStatus(),                                        p_wrapper->InputRate() );            p_mediaControl->SetProgress( p_wrapper->GetTimeAsFloat() );            _SetMenusEnabled( true, hasChapters, hasTitles );            _UpdateSpeedMenu( p_wrapper->InputRate() );            // enable/disable skip buttons            bool canSkipPrev;            bool canSkipNext;            p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );            p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );            if ( p_wrapper->HasInput() )            {                p_mediaControl->SetAudioEnabled( true );                p_mediaControl->SetMuted( p_wrapper->IsMuted() );            } else                p_mediaControl->SetAudioEnabled( false );            Unlock();        }        // update playlist as well        if ( fPlaylistWindow->LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK )        {            fPlaylistWindow->UpdatePlaylist();            fPlaylistWindow->Unlock();        }    }    else    {		if ( LockWithTimeout(INTERFACE_LOCKING_TIMEOUT) == B_OK )		{	        _SetMenusEnabled( false );	        if( !( p_wrapper->PlaylistSize() > 0 ) )	            p_mediaControl->SetEnabled( false );	        else	        {	            p_mediaControl->SetProgress( 0 );	            // enable/disable skip buttons	            bool canSkipPrev;	            bool canSkipNext;	            p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );	            p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );			}            Unlock();        }    }    fLastUpdateTime = system_time();}/***************************************************************************** * InterfaceWindow::IsStopped *****************************************************************************/boolInterfaceWindow::IsStopped() const{    return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);}/***************************************************************************** * InterfaceWindow::_UpdatePlaylist *****************************************************************************/voidInterfaceWindow::_UpdatePlaylist(){    if ( fPlaylistWindow->Lock() )    {        fPlaylistWindow->UpdatePlaylist( true );        fPlaylistWindow->Unlock();        p_mediaControl->SetEnabled( p_wrapper->PlaylistSize() );    }}/***************************************************************************** * InterfaceWindow::_SetMenusEnabled *****************************************************************************/voidInterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles){    if (!hasFile)    {        hasChapters = false;        hasTitles = false;    }    if ( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK)    {        if ( fNextChapterMI->IsEnabled() != hasChapters )             fNextChapterMI->SetEnabled( hasChapters );        if ( fPrevChapterMI->IsEnabled() != hasChapters )             fPrevChapterMI->SetEnabled( hasChapters );        if ( fChapterMenu->IsEnabled() != hasChapters )             fChapterMenu->SetEnabled( hasChapters );        if ( fNextTitleMI->IsEnabled() != hasTitles )             fNextTitleMI->SetEnabled( hasTitles );        if ( fPrevTitleMI->IsEnabled() != hasTitles )             fPrevTitleMI->SetEnabled( hasTitles );        if ( fTitleMenu->IsEnabled() != hasTitles )             fTitleMenu->SetEnabled( hasTitles );        if ( fAudioMenu->IsEnabled() != hasFile )             fAudioMenu->SetEnabled( hasFile );        if ( fNavigationMenu->IsEnabled() != hasFile )

⌨️ 快捷键说明

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