- int playback_status; // remember playback state
- playback_status = p_wrapper->InputStatus();
-
- switch( p_message->what )
- {
- case B_ABOUT_REQUESTED:
- {
- BAlert* alert = new BAlert( VOUT_TITLE,
- "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
- alert->Go();
- break;
- }
- case TOGGLE_ON_TOP:
- break;
-
- case OPEN_FILE:
- if( fFilePanel )
- {
- fFilePanel->Show();
- break;
- }
- fFilePanel = new BFilePanel();
- fFilePanel->SetTarget( this );
- fFilePanel->Show();
- break;
-
- case OPEN_PLAYLIST:
- if (fPlaylistWindow->Lock())
- {
- if (fPlaylistWindow->IsHidden())
- fPlaylistWindow->Show();
- else
- fPlaylistWindow->Activate();
- fPlaylistWindow->Unlock();
- }
- break;
- case OPEN_DVD:
- {
- const char *psz_device;
- BString type( "dvd" );
- if( p_message->FindString( "device", &psz_device ) == B_OK )
- {
- BString device( psz_device );
- p_wrapper->openDisc( type, device, 0, 0 );
- }
- _UpdatePlaylist();
- }
- break;
-
- case STOP_PLAYBACK:
- // this currently stops playback not nicely
- if (playback_status > UNDEF_S)
- {
- p_wrapper->volume_mute();
- snooze( 400000 );
- p_wrapper->PlaylistStop();
- p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
- }
- break;
-
- case START_PLAYBACK:
- /* starts playing in normal mode */
-
- case PAUSE_PLAYBACK:
- /* toggle between pause and play */
- if (playback_status > UNDEF_S)
- {
- /* pause if currently playing */
- if ( playback_status == PLAYING_S )
- {
- p_wrapper->volume_mute();
- snooze( 400000 );
- p_wrapper->PlaylistPause();
- }
- else
- {
- p_wrapper->volume_restore();
- p_wrapper->PlaylistPlay();
- }
- }
- else
- {
- /* Play a new file */
- p_wrapper->PlaylistPlay();
- }
- break;
-
- case FASTER_PLAY:
- /* cycle the fast playback modes */
- if (playback_status > UNDEF_S)
- {
- p_wrapper->volume_mute();
- snooze( 400000 );
- p_wrapper->InputFaster();
- }
- break;
-
- case SLOWER_PLAY:
- /* cycle the slow playback modes */
- if (playback_status > UNDEF_S)
- {
- p_wrapper->volume_mute();
- snooze( 400000 );
- p_wrapper->InputSlower();
- }
- break;
-
- case NORMAL_PLAY:
- /* restore speed to normal if already playing */
- if (playback_status > UNDEF_S)
- {
- p_wrapper->volume_restore();
- p_wrapper->PlaylistPlay();
- }
- break;
-
- case SEEK_PLAYBACK:
- /* handled by semaphores */
- break;
- // volume related messages
- case VOLUME_CHG:
- /* adjust the volume */
- if (playback_status > UNDEF_S)
- {
- p_wrapper->set_volume( p_mediaControl->GetVolume() );
- p_mediaControl->SetMuted( p_wrapper->is_muted() );
- }
- break;
-
- case VOLUME_MUTE:
- // toggle muting
- p_wrapper->toggle_mute();
- p_mediaControl->SetMuted( p_wrapper->is_muted() );
- break;
-
- case SELECT_CHANNEL:
- if ( playback_status > UNDEF_S )
- {
- int32 channel;
- if ( p_message->FindInt32( "channel", &channel ) == B_OK )
- {
- p_wrapper->toggleLanguage( channel );
- // vlc seems to remember the volume for every channel,
- // but I would assume that to be somewhat annoying to the user
- // the next call will also unmute the volume, which is probably
- // desired as well, because if the user selects another language,
- // he probably wants to hear the change as well
- snooze( 400000 ); // we have to wait a bit, or the change will be reverted
- p_wrapper->set_volume( p_mediaControl->GetVolume() );
- }
- }
- 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 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 B_REFS_RECEIVED:
- case B_SIMPLE_DATA:
- {
- // figure out if user wants files replaced or added
- bool replace = false;
- if ( p_message->WasDropped() )
- replace = !( modifiers() & B_SHIFT_KEY );
- // build list of files to be played from message contents
- entry_ref ref;
- BList files;
- for ( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
- {
- BPath path( &ref );
- if ( path.InitCheck() == B_OK )
- // the BString objects will be deleted
- // by the wrapper function further down
- files.AddItem( new BString( (char*)path.Path() ) );
- }
- // give the list to VLC
- p_wrapper->openFiles(&files, replace);
- _UpdatePlaylist();
- }
- break;
-
- case OPEN_PREFERENCES:
- if( fPreferencesWindow->Lock() )
- {
- if (fPreferencesWindow->IsHidden())
- fPreferencesWindow->Show();
- else
- fPreferencesWindow->Activate();
- fPreferencesWindow->Unlock();
- }
- break;
-
- default:
- BWindow::MessageReceived( p_message );
- break;
- }
-
+ switch( p_message->what )
+ {
+ case B_ABOUT_REQUESTED:
+ {
+ BAlert * alert;
+
+ alert = new BAlert( "VLC media player" VERSION,
+ "VLC media player" VERSION " (BeOS interface)\n\n"
+ "The VideoLAN team <videolan@videolan.org>\n"
+ "http://www.videolan.org/", _("OK") );
+ alert->Go();
+ break;
+ }
+ case TOGGLE_ON_TOP:
+ break;
+
+ case OPEN_FILE:
+ _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") );
+ break;
+
+ case LOAD_SUBFILE:
+ _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") );
+ break;
+#if 0
+ case OPEN_PLAYLIST:
+ if (fPlaylistWindow->Lock())
+ {
+ if (fPlaylistWindow->IsHidden())
+ fPlaylistWindow->Show();
+ else
+ fPlaylistWindow->Activate();
+ fPlaylistWindow->Unlock();
+ }
+ break;
+#endif
+ case OPEN_DVD:
+ {
+ const char * psz_device;
+ if( p_playlist &&
+ p_message->FindString( "device", &psz_device ) == B_OK )
+ {
+ char psz_uri[1024];
+ memset( psz_uri, 0, 1024 );
+ snprintf( psz_uri, 1024, "dvdnav:%s", psz_device );
+ playlist_Add( p_playlist, psz_uri, psz_device,
+ PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true );
+ }
+ UpdatePlaylist();
+ }
+ break;
+
+ case SUBFILE_RECEIVED:
+ {
+ entry_ref ref;
+ if( p_message->FindRef( "refs", 0, &ref ) == B_OK )
+ {
+ BPath path( &ref );
+ if ( path.InitCheck() == B_OK )
+ config_PutPsz( p_intf, "sub-file", path.Path() );
+ }
+ break;
+ }
+
+ case STOP_PLAYBACK:
+ if( p_playlist )
+ {
+ playlist_Stop( p_playlist );
+ }
+ p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT);
+ break;
+
+ case START_PLAYBACK:
+ case PAUSE_PLAYBACK:
+ {
+ vlc_value_t val;
+ val.i_int = PLAYING_S;
+ if( p_input )
+ {
+ var_Get( p_input, "state", &val );
+ }
+ if( p_input && val.i_int != PAUSE_S )
+ {
+ val.i_int = PAUSE_S;
+ var_Set( p_input, "state", val );
+ }
+ else
+ {
+ playlist_Play( p_playlist );
+ }
+ break;
+ }
+ case HEIGHTH_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 );
+ }
+ break;
+
+ case QUARTER_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 );
+ }
+ break;
+
+ case HALF_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 );
+ }
+ break;
+
+ case NORMAL_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
+ }
+ break;
+
+ case TWICE_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 );
+ }
+ break;
+
+ case FOUR_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 );
+ }
+ break;
+
+ case HEIGHT_PLAY:
+ if( p_input )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 );
+ }
+ break;
+
+ case SEEK_PLAYBACK:
+ /* handled by semaphores */
+ break;
+
+ case VOLUME_CHG:
+ aout_VolumeSet( p_intf, p_mediaControl->GetVolume() );
+ break;
+
+ case VOLUME_MUTE:
+ aout_VolumeMute( p_intf, NULL );
+ break;
+
+ case SELECT_CHANNEL:
+ {
+ int32 channel;
+ if( p_input )
+ {
+ if( p_message->FindInt32( "audio-es", &channel ) == B_OK )
+ {
+ var_SetInteger( p_input, "audio-es", channel );
+ }
+ else if( p_message->FindInt32( "spu-es", &channel ) == B_OK )
+ {
+ var_SetInteger( p_input, "spu-es", channel );
+ }
+ }
+ break;
+ }
+
+ case PREV_TITLE:
+ if( p_input )
+ {
+ var_SetVoid( p_input, "prev-title" );
+ }
+ break;
+
+ case NEXT_TITLE:
+ if( p_input )
+ {
+ var_SetVoid( p_input, "next-title" );
+ }
+ break;
+
+ case TOGGLE_TITLE:
+ {
+ int32 index;
+ if( p_input &&
+ p_message->FindInt32( "index", &index ) == B_OK )
+ {
+ var_SetInteger( p_input, "title", index );
+ }
+ break;
+ }
+
+ case PREV_CHAPTER:
+ if( p_input )
+ {
+ var_SetVoid( p_input, "prev-chapter" );
+ }
+ break;
+
+ case NEXT_CHAPTER:
+ if( p_input )
+ {
+ var_SetVoid( p_input, "next-chapter" );
+ }
+ break;
+
+ case TOGGLE_CHAPTER:
+ {
+ int32 index;
+ if( p_input &&
+ p_message->FindInt32( "index", &index ) == B_OK )
+ {
+ var_SetInteger( p_input, "chapter", index );
+ }
+ break;
+ }
+
+ case PREV_FILE:
+ if( p_playlist )
+ {
+ playlist_Prev( p_playlist );
+ }
+ break;
+
+ case NEXT_FILE:
+ if( p_playlist )
+ {
+ playlist_Next( p_playlist );
+ }
+ break;
+
+ case NAVIGATE_PREV:
+ if( p_input )
+ {
+ vlc_value_t val;
+
+ /* First try to go to previous chapter */
+ if( !var_Get( p_input, "chapter", &val ) )
+ {
+ if( val.i_int > 1 )
+ {
+ var_SetVoid( p_input, "prev-chapter" );
+ break;
+ }
+ }
+
+ /* Try to go to previous title */
+ if( !var_Get( p_input, "title", &val ) )
+ {
+ if( val.i_int > 1 )
+ {
+ var_SetVoid( p_input, "prev-title" );
+ break;
+ }
+ }
+
+ /* Try to go to previous file */
+ if( p_playlist )
+ {
+ playlist_Prev( p_playlist );
+ }
+ }
+ break;
+
+ case NAVIGATE_NEXT:
+ if( p_input )
+ {
+ vlc_value_t val, val_list;
+
+ /* First try to go to next chapter */
+ if( !var_Get( p_input, "chapter", &val ) )
+ {
+ var_Change( p_input, "chapter", VLC_VAR_GETCHOICES,
+ &val_list, NULL );
+ if( val_list.p_list->i_count > val.i_int )
+ {
+ var_Change( p_input, "chapter", VLC_VAR_FREELIST,
+ &val_list, NULL );
+ var_SetVoid( p_input, "next-chapter" );
+ break;
+ }
+ var_Change( p_input, "chapter", VLC_VAR_FREELIST,
+ &val_list, NULL );
+ }
+
+ /* Try to go to next title */
+ if( !var_Get( p_input, "title", &val ) )
+ {
+ var_Change( p_input, "title", VLC_VAR_GETCHOICES,
+ &val_list, NULL );
+ if( val_list.p_list->i_count > val.i_int )
+ {
+ var_Change( p_input, "title", VLC_VAR_FREELIST,
+ &val_list, NULL );
+ var_SetVoid( p_input, "next-title" );
+ break;
+ }
+ var_Change( p_input, "title", VLC_VAR_FREELIST,
+ &val_list, NULL );
+ }
+
+ /* Try to go to next file */
+ if( p_playlist )
+ {
+ playlist_Next( p_playlist );
+ }
+ }
+ 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 */
+
+ int32 count;
+ type_code dummy;
+ if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK ||
+ count < 1 )
+ {
+ break;
+ }
+
+ bool b_remove = ( p_message->WasDropped() &&
+ !( modifiers() & B_SHIFT_KEY ) );
+
+ if( b_remove && p_playlist )
+ {
+ playlist_Clear( p_playlist, true );
+ }
+
+ entry_ref ref;
+ for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
+ {
+ BPath path( &ref );
+
+ /* TODO: find out if this is a DVD icon */
+
+ if( p_playlist )
+ {
+ playlist_Add( p_playlist, path.Path(), NULL,
+ PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true );
+ }
+ }
+
+ 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;
+ }