/** * Load a certain playlist file into the playlist * This file will replace the contents of the "current" view * * \param p_playlist the playlist to which the new items will be added * \param psz_filename the name of the playlistfile to import * \return VLC_SUCCESS on success */ int playlist_Load( playlist_t * p_playlist, const char *psz_filename ) { playlist_item_t *p_item; char *psz_uri; int i_id; msg_Info( p_playlist, "clearing playlist"); playlist_Clear( p_playlist ); psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 ); sprintf( psz_uri, "file/playlist://%s", psz_filename); i_id = playlist_Add( p_playlist, psz_uri, psz_uri, PLAYLIST_INSERT , PLAYLIST_END); vlc_mutex_lock( &p_playlist->object_lock ); p_item = playlist_ItemGetById( p_playlist, i_id ); p_item->b_autodeletion = VLC_TRUE; vlc_mutex_unlock( &p_playlist->object_lock ); playlist_Play(p_playlist); return VLC_SUCCESS; }
static int Playlist(vlc_object_t *obj, char const *cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data) { intf_thread_t *intf = (intf_thread_t*)obj; intf_sys_t *sys = intf->p_sys; playlist_t *playlist = sys->playlist; input_thread_t * input = playlist_CurrentInput(playlist); int state; if(input) { state = var_GetInteger(input, "state"); vlc_object_release(input); } else { return VLC_EGENERIC; } if(strcmp(cmd, "pause") == 0) { msg_Info(intf, "Pause"); if(state == PLAYING_S) playlist_Pause(sys->playlist); } else if(strcmp(cmd, "play") == 0) { msg_Info(intf, "Play"); if(state != PLAYING_S) playlist_Play(sys->playlist); } }
void CmdPlay::execute() { playlist_t *pPlaylist = getIntf()->p_sys->p_playlist; if( pPlaylist == NULL ) return; // if already playing an input, reset rate to normal speed input_thread_t *pInput = playlist_CurrentInput( pPlaylist ); if( pInput ) { var_SetFloat( pPlaylist, "rate", 1.0 ); vlc_object_release( pInput ); } playlist_Lock( pPlaylist ); const bool b_empty = playlist_IsEmpty( pPlaylist ); playlist_Unlock( pPlaylist ); if( !b_empty ) { playlist_Play( pPlaylist ); } else { // If the playlist is empty, open a file requester instead CmdDlgFile( getIntf() ).execute(); } }
/* * Known issues: since moving in the playlist using playlist_Next * or playlist_Prev implies starting to play items, the a_position * argument will be only honored for the 1st item in the list. * * XXX:FIXME split moving in the playlist and playing items two * different actions or make playlist_<Next|Prev> accept a time * value to start to play from. */ void mediacontrol_start( mediacontrol_Instance *self, const mediacontrol_Position * a_position, mediacontrol_Exception *exception ) { playlist_t * p_playlist = self->p_playlist; exception = mediacontrol_exception_init( exception ); if( ! p_playlist ) { RAISE( mediacontrol_PlaylistException, "No available playlist" ); return; } vlc_mutex_lock( &p_playlist->object_lock ); if( p_playlist->i_size ) { int i_index; int i_from; char *psz_from = NULL; psz_from = ( char * )malloc( 20 * sizeof( char ) ); if( psz_from ) { i_from = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000; i_index = p_playlist->i_index; if( i_index < 0 ) { /* We know that there is at least 1 element, since i_size != 0 */ i_index = 0; } /* Set start time */ snprintf( psz_from, 20, "start-time=%i", i_from ); playlist_ItemAddOption( p_playlist->pp_items[i_index], psz_from ); free( psz_from ); } vlc_mutex_unlock( &p_playlist->object_lock ); playlist_Play( p_playlist ); } else { RAISE( mediacontrol_PlaylistException, "Empty playlist." ); vlc_mutex_unlock( &p_playlist->object_lock ); } }
void CmdPlay::execute() { playlist_t *pPlaylist = getIntf()->p_sys->p_playlist; if( pPlaylist == NULL ) { return; } if( pPlaylist->i_size ) { playlist_Play( pPlaylist ); } else { // If the playlist is empty, open a file requester instead CmdDlgFile cmd( getIntf() ); cmd.execute(); } }
void onPlay(GtkButton *button, gpointer user_data) { intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) ); playlist_t *p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if (p_playlist) { vlc_mutex_lock( &p_playlist->object_lock ); if (p_playlist->i_size) { vlc_mutex_unlock( &p_playlist->object_lock ); playlist_Play( p_playlist ); gdk_window_lower( p_intf->p_sys->p_window->window ); } else { vlc_mutex_unlock( &p_playlist->object_lock ); } vlc_object_release( p_playlist ); } }
static void *Thread( void *obj ) { intf_thread_t *p_intf = (intf_thread_t *)obj; MainInterface *p_mi; char vlc_name[] = "vlc"; /* for WM_CLASS */ #ifdef QT5_HAS_X11 char platform_parm[] = "-platform"; char platform_value[] = "xcb"; #endif char *argv[] = { vlc_name, #ifdef QT5_HAS_X11 platform_parm, platform_value, #endif NULL, }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; Q_INIT_RESOURCE( vlc ); /* Start the QApplication here */ QVLCApp app( argc, argv ); p_intf->p_sys->p_app = &app; /* All the settings are in the .conf/.ini style */ p_intf->p_sys->mainSettings = new QSettings( #ifdef _WIN32 QSettings::IniFormat, #else QSettings::NativeFormat, #endif QSettings::UserScope, "vlc", "vlc-qt-interface" ); /* Icon setting, Mac uses icon from .icns */ #ifndef Q_OS_MAC if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) ) app.setWindowIcon( QIcon::fromTheme( "vlc-xmas", QIcon( ":/logo/vlc128-xmas.png" ) ) ); else app.setWindowIcon( QIcon::fromTheme( "vlc", QIcon( ":/logo/vlc256.png" ) ) ); #endif /* Initialize the Dialog Provider and the Main Input Manager */ DialogsProvider::getInstance( p_intf ); MainInputManager::getInstance( p_intf ); #ifdef UPDATE_CHECK /* Checking for VLC updates */ if( var_InheritBool( p_intf, "qt-updates-notif" ) && !var_InheritBool( p_intf, "qt-privacy-ask" ) ) { int interval = var_InheritInteger( p_intf, "qt-updates-days" ); if( QDate::currentDate() > getSettings()->value( "updatedate" ).toDate().addDays( interval ) ) { /* The constructor of the update Dialog will do the 1st request */ UpdateDialog::getInstance( p_intf ); getSettings()->setValue( "updatedate", QDate::currentDate() ); } } #endif /* Create the normal interface in non-DP mode */ if( !p_intf->p_sys->b_isDialogProvider ) { p_mi = new MainInterface( p_intf ); p_intf->p_sys->p_mi = p_mi; } else p_mi = NULL; /* Explain how to show a dialog :D */ p_intf->pf_show_dialog = ShowDialog; /* Check window type from the Qt platform back-end */ p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_INVALID; #if HAS_QT5 || defined (Q_WS_QPA) QString platform = app.platformName(); if( platform == qfu("xcb") ) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID; else if( platform == qfu("windows") ) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_HWND; else if( platform == qfu("cocoa" ) ) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT; else msg_Err( p_intf, "unknown Qt platform: %s", qtu(platform) ); #elif defined (Q_WS_X11) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID; #elif defined (Q_WS_WIN) || defined (Q_WS_PM) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_HWND; #elif defined (Q_WS_MAC) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT; #endif /* Tell the main LibVLC thread we are ready */ vlc_sem_post (&ready); #ifdef Q_OS_MAC /* We took over main thread, register and start here */ if( !p_intf->p_sys->b_isDialogProvider ) { RegisterIntf( p_intf ); playlist_Play( THEPL ); } #endif /* Last settings */ app.setQuitOnLastWindowClosed( false ); /* Retrieve last known path used in file browsing */ p_intf->p_sys->filepath = getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR ) ).toString(); /* Loads and tries to apply the preferred QStyle */ QString s_style = getSettings()->value( "MainWindow/QtStyle", "" ).toString(); if( s_style.compare("") != 0 ) QApplication::setStyle( s_style ); /* Launch */ app.exec(); msg_Dbg( p_intf, "QApp exec() finished" ); if (p_mi != NULL) { QMutexLocker locker (&lock); active = false; p_intf->p_sys->p_mi = NULL; /* Destroy first the main interface because it is connected to some slots in the MainInputManager */ delete p_mi; } /* */ ExtensionsManager::killInstance(); AddonsManager::killInstance(); /* Destroy all remaining windows, because some are connected to some slots in the MainInputManager Settings must be destroyed after that. */ DialogsProvider::killInstance(); /* Delete the recentsMRL object before the configuration */ RecentsMRL::killInstance(); /* Save the path or delete if recent play are disabled */ if( var_InheritBool( p_intf, "qt-recentplay" ) ) getSettings()->setValue( "filedialog-path", p_intf->p_sys->filepath ); else getSettings()->remove( "filedialog-path" ); /* */ delete p_intf->p_sys->pl_model; /* Delete the configuration. Application has to be deleted after that. */ delete p_intf->p_sys->mainSettings; /* Destroy the MainInputManager */ MainInputManager::killInstance(); /* Delete the application automatically */ return NULL; }
static int Playlist( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*)p_this; playlist_t *p_playlist; p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( !p_playlist ) { return VLC_ENOOBJ; } /* Parse commands that require a playlist */ if( !strcmp( psz_cmd, "prev" ) ) { playlist_Prev( p_playlist ); } else if( !strcmp( psz_cmd, "next" ) ) { playlist_Next( p_playlist ); } else if( !strcmp( psz_cmd, "play" ) ) { playlist_Play( p_playlist ); } else if( !strcmp( psz_cmd, "stop" ) ) { playlist_Stop( p_playlist ); } else if( !strcmp( psz_cmd, "add" ) ) { msg_rtci( "trying to add %s to playlist\n", newval.psz_string ); playlist_Add( p_playlist, newval.psz_string, newval.psz_string, PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END ); } else if( !strcmp( psz_cmd, "playlist" ) ) { int i; for ( i = 0; i < p_playlist->i_size; i++ ) { msg_rtci( "|%s%s %s|\n", i == p_playlist->i_index?"*":" ", p_playlist->pp_items[i]->input.psz_name, p_playlist->pp_items[i]->input.psz_uri ); } if ( i == 0 ) { msg_rtci( "| no entries\n" ); } } /* * sanity check */ else { msg_rtci( "unknown command!\n" ); } vlc_object_release( p_playlist ); return VLC_SUCCESS; }
static void ProcessCommand(intf_thread_t *p_intf, const char *p_string) { intf_sys_t *p_sys = p_intf->p_sys; playlist_t *p_playlist = p_sys->p_playlist; char *p_line = strdup(p_string); int i_argc; char** p_argv = NULL; i_argc = ParseLineCommand(p_line, &p_argv); if (i_argc == 0 || !p_argv) goto msg; if (i_argc == 1) { if (!strcmp(p_argv[0], "help")) { Notify(p_intf, "woshenmedoubuzhidao\n"); } else if (!strcmp(p_argv[0], "play")) { playlist_Play(p_playlist); } else if (!strcmp(p_argv[0], "pause")) { playlist_Pause(p_playlist); } else if (!strcmp(p_argv[0], "stop")) { playlist_Stop(p_playlist); } else if (!strcmp(p_argv[0], "close")) { playlist_Clear(p_playlist, pl_Unlocked); } else if (!strcmp(p_argv[0], "ff")) { } else if (!strcmp(p_argv[0], "fb")) { } else if (!strcmp(p_argv[0], "quit")) { net_Close(p_sys->i_socket); p_sys->i_socket = -1; } else if (!strcmp(p_argv[0], "shutdown")) { } else goto msg; } else if (i_argc == 2) { if (!strcmp(p_argv[0], "open")) { char *path = p_argv[1]; int len = strlen(path); char *uri = malloc(len * 3 + 1); if (!uri) { Notify(p_intf, "oops\n"); goto out; } int i, j; for (i = 0, j = 0; i < len; i++) { uint8_t ch = path[i]; if (ch < 32 || ch > 127) { uri[j] = '%'; uri[j + 1] = ch >> 4; uri[j + 1] += (uri[j + 1] > 9 ? 0x37 : 0x30); uri[j + 2] = ch & 15; uri[j + 2] += (uri[j + 2] > 9 ? 0x37 : 0x30); j += 3; } else { uri[j] = path[i]; j++; } }
/***************************************************************************** * InterfaceWindow::MessageReceived *****************************************************************************/ void InterfaceWindow::MessageReceived( BMessage * p_message ) { 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 <*****@*****.**>\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_ToggleMute( 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_TriggerCallback( p_input, "prev-title" ); } break; case NEXT_TITLE: if( p_input ) { var_TriggerCallback( 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_TriggerCallback( p_input, "prev-chapter" ); } break; case NEXT_CHAPTER: if( p_input ) { var_TriggerCallback( 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_TriggerCallback( p_input, "prev-chapter" ); break; } } /* Try to go to previous title */ if( !var_Get( p_input, "title", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( 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 ) { /* First try to go to next chapter */ if( !var_Get( p_input, "chapter", &val ) ) { int i_chapter_count = var_CountChoices( p_input, "chapter" ); if( i_chapter_count > val.i_int ) { var_TriggerCallback( p_input, "next-chapter" ); break; } } /* Try to go to next title */ if( !var_Get( p_input, "title", &val ) ) { int i_title_count = var_CountChoices( p_input, "title" ); if( i_title_count > val.i_int ) { var_TriggerCallback( p_input, "next-title" ); break; } } /* 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; } }
static int vlclua_playlist_play( lua_State * L ) { playlist_t *p_playlist = vlclua_get_playlist_internal( L ); playlist_Play( p_playlist ); return 0; }
/***************************************************************************** * Run: main loop *****************************************************************************/ static void Run( intf_thread_t *p_intf ) { char *code, *c; playlist_t *p_playlist; input_thread_t *p_input; vout_thread_t *p_vout = NULL; while( !p_intf->b_die ) { /* Sleep a bit */ msleep( INTF_IDLE_SLEEP ); /* Update the input */ if( p_intf->p_sys->p_input == NULL ) { p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); } else if( p_intf->p_sys->p_input->b_dead ) { vlc_object_release( p_intf->p_sys->p_input ); p_intf->p_sys->p_input = NULL; } p_input = p_intf->p_sys->p_input; /* Update the vout */ if( p_vout == NULL ) { p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); p_intf->p_sys->p_vout = p_vout; } else if( p_vout->b_die ) { vlc_object_release( p_vout ); p_vout = NULL; p_intf->p_sys->p_vout = NULL; } /* We poll the lircsocket */ if( lirc_nextcode(&code) != 0 ) { break; } if( code == NULL ) { continue; } while( !p_intf->b_die && lirc_code2char( p_intf->p_sys->config, code, &c ) == 0 && c != NULL ) { if( !strcmp( c, "QUIT" ) ) { p_intf->p_vlc->b_die = VLC_TRUE; vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Quit" ) ); continue; } else if( !strcmp( c, "VOL_UP" ) ) { audio_volume_t i_newvol; aout_VolumeUp( p_intf, 1, &i_newvol ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"), i_newvol * 100 / AOUT_VOLUME_MAX ); } else if( !strcmp( c, "VOL_DOWN" ) ) { audio_volume_t i_newvol; aout_VolumeDown( p_intf, 1, &i_newvol ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"), i_newvol * 100 / AOUT_VOLUME_MAX ); } else if( !strcmp( c, "MUTE" ) ) { audio_volume_t i_newvol = -1; aout_VolumeMute( p_intf, &i_newvol ); if( i_newvol == 0 ) { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Mute" ) ); } else { vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %d%%"), i_newvol * 100 / AOUT_VOLUME_MAX ); } } if( p_vout ) { if( !strcmp( c, "FULLSCREEN" ) ) { p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; continue; } if( !strcmp( c, "ACTIVATE" ) ) { vlc_value_t val; val.psz_string = "ENTER"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "LEFT" ) ) { vlc_value_t val; val.psz_string = "LEFT"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "RIGHT" ) ) { vlc_value_t val; val.psz_string = "RIGHT"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "UP" ) ) { vlc_value_t val; val.psz_string = "UP"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "DOWN" ) ) { vlc_value_t val; val.psz_string = "DOWN"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } } if( !strcmp( c, "PLAY" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } continue; } if( !strcmp( c, "PLAYPAUSE" ) ) { 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 ) { vout_OSDMessage( VLC_OBJECT(p_intf), DEFAULT_CHAN, _( "Pause" ) ); val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { vlc_mutex_lock( &p_playlist->object_lock ); if( p_playlist->i_size ) { vlc_mutex_unlock( &p_playlist->object_lock ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Play" ) ); playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } } } continue; } else if( p_input ) { if( !strcmp( c, "AUDIO_TRACK" ) ) { vlc_value_t val, list, list2; int i_count, i; var_Get( p_input, "audio-es", &val ); var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 ); i_count = list.p_list->i_count; for( i = 0; i < i_count; i++ ) { if( val.i_int == list.p_list->p_values[i].i_int ) { break; } } /* value of audio-es was not in choices list */ if( i == i_count ) { msg_Warn( p_input, "invalid current audio track, selecting 0" ); var_Set( p_input, "audio-es", list.p_list->p_values[0] ); i = 0; } else if( i == i_count - 1 ) { var_Set( p_input, "audio-es", list.p_list->p_values[0] ); i = 0; } else { var_Set( p_input, "audio-es", list.p_list->p_values[i+1] ); i++; } vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Audio track: %s"), list2.p_list->p_values[i].psz_string ); } else if( !strcmp( c, "SUBTITLE_TRACK" ) ) { vlc_value_t val, list, list2; int i_count, i; var_Get( p_input, "spu-es", &val ); var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 ); i_count = list.p_list->i_count; for( i = 0; i < i_count; i++ ) { if( val.i_int == list.p_list->p_values[i].i_int ) { break; } } /* value of audio-es was not in choices list */ if( i == i_count ) { msg_Warn( p_input, "invalid current subtitle track, selecting 0" ); var_Set( p_input, "spu-es", list.p_list->p_values[0] ); i = 0; } else if( i == i_count - 1 ) { var_Set( p_input, "spu-es", list.p_list->p_values[0] ); i = 0; } else { var_Set( p_input, "spu-es", list.p_list->p_values[i+1] ); i = i + 1; } vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Subtitle track: %s"), list2.p_list->p_values[i].psz_string ); } else if( !strcmp( c, "PAUSE" ) ) { vlc_value_t val; vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Pause" ) ); val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else if( !strcmp( c, "NEXT" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Next( p_playlist ); vlc_object_release( p_playlist ); } } else if( !strcmp( c, "PREV" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Prev( p_playlist ); vlc_object_release( p_playlist ); } } else if( !strcmp( c, "STOP" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); } } else if( !strcmp( c, "FAST" ) ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-faster", val ); } else if( !strcmp( c, "SLOW" ) ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-slower", val ); } /* beginning of modifications by stephane Thu Jun 19 15:29:49 CEST 2003 */ else if ( !strcmp(c, "CHAPTER_N" ) || !strcmp( c, "CHAPTER_P" ) ) { unsigned int i_chapter = 0; if( !strcmp( c, "CHAPTER_N" ) ) { var_SetVoid( p_input, "next-chapter" ); } else if( !strcmp( c, "CHAPTER_P" ) ) { var_SetVoid( p_input, "prev-chapter" ); } } /* end of modification by stephane Thu Jun 19 15:29:49 CEST 2003 */ } } free( code ); } }
static void MainLoop( intf_thread_t *p_intf ) { MSG msg; Interface *intf = 0; if( !hInstance ) hInstance = GetModuleHandle(NULL); // Register window class WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW ; wc.lpfnWndProc = (WNDPROC)CBaseWindow::BaseWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hIcon = NULL; wc.hInstance = hInstance; wc.hCursor = NULL; wc.hbrBackground = (HBRUSH)(COLOR_MENU+1); wc.lpszMenuName = NULL; wc.lpszClassName = _T("VLC WinCE"); RegisterClass( &wc ); #ifndef UNDER_CE /* Initialize OLE/COM */ CoInitialize( 0 ); #endif if( !p_intf->pf_show_dialog ) { /* The module is used in interface mode */ p_intf->p_sys->p_window = intf = new Interface( p_intf, 0, hInstance ); /* Create/Show the interface */ if( !intf->InitInstance() ) goto end; } /* Creates the dialogs provider */ p_intf->p_sys->p_window = CreateDialogsProvider( p_intf, p_intf->pf_show_dialog ? NULL : p_intf->p_sys->p_window, hInstance ); p_intf->p_sys->pf_show_dialog = ShowDialog; /* OK, initialization is over */ vlc_thread_ready( p_intf ); /* Check if we need to start playing */ if( !p_intf->pf_show_dialog && p_intf->b_play ) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } } // Main message loop while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } end: if( intf ) delete intf; #ifndef UNDER_CE /* Uninitialize OLE/COM */ CoUninitialize(); #endif }
static LRESULT HandleCadMessage(intf_thread_t* p_intf, HWND hwnd, WPARAM wParam, LPARAM lParam) { intf_sys_t* const p_sys = p_intf->p_sys; switch (lParam) { case IPC_PLAY: { playlist_Play(pl_Get(p_intf->p_libvlc)); return 1; } case IPC_PLAYPAUSE: { playlist_t* p_playlist = pl_Get(p_intf->p_libvlc); const bool playing = playlist_Status(p_playlist) == PLAYLIST_RUNNING; playlist_Control(p_playlist, playing ? PLAYLIST_PAUSE : PLAYLIST_PLAY, pl_Unlocked); return 1; } case IPC_PAUSE: { playlist_Pause(pl_Get(p_intf->p_libvlc)); return 1; } case IPC_STOP: { playlist_Stop(pl_Get(p_intf->p_libvlc)); return 1; } case IPC_NEXT: { playlist_Next(pl_Get(p_intf->p_libvlc)); return 1; } case IPC_PREVIOUS: { playlist_Prev(pl_Get(p_intf->p_libvlc)); return 1; } case IPC_SET_VOLUME: { playlist_VolumeSet(pl_Get(p_intf->p_libvlc), (int)wParam / 100.0f); return 1; } case IPC_GET_VOLUME: { // VLC can return a volume larger than 100% so we need to cap it to 100 here. const float volume = playlist_VolumeGet(pl_Get(p_intf->p_libvlc)) * 100.0f; return (LRESULT)min(volume, 100.0f); } case IPC_GET_DURATION: { unsigned int duration = 0; if (p_sys->p_input) { input_item_t* const p_item = input_GetItem(p_sys->p_input); duration = (unsigned int)(input_item_GetDuration(p_item) / 1000000); } return duration; } case IPC_GET_POSITION: { int pos = 0; if (p_sys->p_input) { pos = (int)(var_GetTime(p_sys->p_input, "time") / CLOCK_FREQ); } return pos; } case IPC_SET_POSITION: { if (p_sys->p_input) { var_SetTime(p_sys->p_input, "time", (int64_t)wParam * CLOCK_FREQ); } return 0; } case IPC_GET_SHUFFLE: { return (int)var_GetBool(pl_Get(p_intf->p_libvlc), "random"); } case IPC_SET_SHUFFLE: { return (int)var_SetBool(pl_Get(p_intf->p_libvlc), "random", (bool)wParam); } case IPC_GET_REPEAT: { return (int)var_GetBool(pl_Get(p_intf->p_libvlc), "repeat"); } case IPC_SET_REPEAT: { return (int)var_SetBool(pl_Get(p_intf->p_libvlc), "repeat", (bool)wParam); } case IPC_SET_RATING: { // VLC does not support ratings so send back 0. PostMessage(p_sys->cad_window, WM_USER, 0, IPC_RATING_CHANGED_NOTIFICATION); return 0; } case IPC_SET_CALLBACK_HWND: { p_sys->cad_window = (HWND)wParam; return 1; } case IPC_SHOW_WINDOW: { // TODO. return 0; } case IPC_GET_STATE: { const int status = playlist_Status(pl_Get(p_intf->p_libvlc)); return status == PLAYLIST_RUNNING ? 1 : status == PLAYLIST_PAUSED ? 2 : 0; } case IPC_SHUTDOWN_NOTIFICATION: { p_sys->cad_window = NULL; return 1; } case IPC_CLOSE: { libvlc_Quit(p_intf->p_libvlc); return 1; } case IPC_GET_CURRENT_TRACK: { if (!p_sys->p_input) return 0; input_item_t* p_item = input_GetItem(p_sys->p_input); char buffer[DATA_MAX_LENGTH]; int buffer_len = 0; // If the i sstarts with file://, we assume that it is a local file and detailed // metadata is available. Otherwise, we assume it to be a network stream (i.e. radio) // with limited info (only a title). char* const file = decode_URI(input_item_GetURI(p_item)); if (strncmp(file, "file://", 7) == 0) { char* const title = input_item_GetTitleFbName(p_item); char* const artist = input_item_GetArtist(p_item); char* const album = input_item_GetAlbum(p_item); char* const cover = decode_URI(input_item_GetArtworkURL(p_item)); const unsigned int duration = input_item_GetDuration(p_item) / 1000000U; buffer_len = _snprintf( buffer, ARRAYSIZE(buffer), "%s\t%s\t%s\t\t\t\t\t%u\t%s\t\t%s\t\t\t\t\t\t\t", title ? title : "", artist ? artist : "", album ? album : "", duration, file ? &file[8] : "", cover ? &cover[8] : ""); // Skip the "file://" part. free(title); free(artist); free(album); free(cover); } else if (char* now_playing = input_item_GetNowPlaying(p_item)) { char* artist = NULL; char* title = now_playing; char* pos = strstr(now_playing, " - "); if (pos) { pos[0] = '\0'; artist = title; title = pos + 3; // Skip the " - " } buffer_len = _snprintf( buffer, ARRAYSIZE(buffer), "%s\t%s\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", title ? title : "", artist ? artist : ""); free(now_playing); } free(file); if (buffer_len) { wchar_t buffer_w[DATA_MAX_LENGTH]; const int buffer_w_len = MultiByteToWideChar( CP_UTF8, 0, buffer, buffer_len + 1, buffer_w, ARRAYSIZE(buffer_w)); COPYDATASTRUCT cds; cds.dwData = IPC_CURRENT_TRACK_NOTIFICATION; cds.lpData = &buffer_w; cds.cbData = buffer_w_len * sizeof(buffer_w[0]); SendMessage( p_sys->cad_window, WM_COPYDATA, IPC_CURRENT_TRACK_NOTIFICATION, (LPARAM)&cds); } return 1; } } return 0; }
//--------------------------------------------------------------------------- // Run: main loop //--------------------------------------------------------------------------- static void Run( intf_thread_t *p_intf ) { // Load a theme ThemeLoader *pLoader = new ThemeLoader( p_intf ); char *skin_last = config_GetPsz( p_intf, "skins2-last" ); if( !skin_last || !*skin_last || !pLoader->load( skin_last ) ) { // Get the resource path and try to load the default skin OSFactory *pOSFactory = OSFactory::instance( p_intf ); const list<string> &resPath = pOSFactory->getResourcePath(); const string &sep = pOSFactory->getDirSeparator(); list<string>::const_iterator it; for( it = resPath.begin(); it != resPath.end(); it++ ) { string path = (*it) + sep + "default.vlt"; if( pLoader->load( path ) ) { // Theme loaded successfully break; } } if( it == resPath.end() ) { // Last chance: the user can select a new theme file if( Dialogs::instance( p_intf ) ) { CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf ); AsyncQueue *pQueue = AsyncQueue::instance( p_intf ); pQueue->push( CmdGenericPtr( pCmd ) ); } else { // No dialogs provider, just quit... CmdQuit *pCmd = new CmdQuit( p_intf ); AsyncQueue *pQueue = AsyncQueue::instance( p_intf ); pQueue->push( CmdGenericPtr( pCmd ) ); msg_Err( p_intf, "Cannot show the \"open skin\" dialog: exiting..."); } } } delete pLoader; if( skin_last ) { free( skin_last ); } // Get the instance of OSLoop OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop(); // Check if we need to start playing if( p_intf->b_play ) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } } // Enter the main event loop loop->run(); // Delete the theme and save the configuration of the windows if( p_intf->p_sys->p_theme ) { p_intf->p_sys->p_theme->saveConfig(); delete p_intf->p_sys->p_theme; p_intf->p_sys->p_theme = NULL; } }