Exemple #1
0
/* libnotify callback, called when the "Previous" button is pressed */
static void Prev( NotifyNotification *notification, gchar *psz, gpointer p )
{
    vlc_object_t *p_object = (vlc_object_t*)p;

    VLC_UNUSED(psz);
    notify_notification_close( notification, NULL );
    playlist_Prev( pl_Get( p_object ) );
}
Exemple #2
0
static void Prev( NotifyNotification *notification, gchar *psz, gpointer p )
{   /* libnotify callback, called when the "Previous" button is pressed */
    vlc_object_t *p_object = (vlc_object_t*)p;

    VLC_UNUSED(psz);
    notify_notification_close( notification, NULL );
    playlist_t *p_playlist = pl_Hold( p_object );
    playlist_Prev( p_playlist );
    pl_Release( p_object );
}
Exemple #3
0
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;
}
Exemple #4
0
static void ProcessGesture( intf_thread_t *p_intf )
{
    intf_sys_t *p_sys = p_intf->p_sys;
    playlist_t *p_playlist = pl_Get( p_intf );

    /* Do something */
    /* If you modify this, please try to follow this convention:
       Start with LEFT, RIGHT for playback related commands
       and UP, DOWN, for other commands */
    switch( p_sys->i_pattern )
    {
        case LEFT:
        {
            msg_Dbg( p_intf, "Go backward in the movie!" );

            input_thread_t *p_input = playlist_CurrentInput( p_playlist );
            if( p_input == NULL )
                break;

            int it = var_InheritInteger( p_intf , "short-jump-size" );
            if( it > 0 )
                var_SetTime( p_input, "time-offset", -CLOCK_FREQ * it );
            vlc_object_release( p_input );
            break;
        }

        case RIGHT:
        {
            msg_Dbg( p_intf, "Go forward in the movie!" );

            input_thread_t *p_input = playlist_CurrentInput( p_playlist );
            if( p_input == NULL )
                break;

            int it = var_InheritInteger( p_intf , "short-jump-size" );
            if( it > 0 )
                var_SetTime( p_input, "time-offset", CLOCK_FREQ * it );
            vlc_object_release( p_input );
            break;
        }

        case GESTURE(LEFT,UP,NONE,NONE):
            msg_Dbg( p_intf, "Going slower." );
            var_TriggerCallback( p_playlist, "rate-slower" );
            break;

        case GESTURE(RIGHT,UP,NONE,NONE):
            msg_Dbg( p_intf, "Going faster." );
            var_TriggerCallback( p_playlist, "rate-faster" );
            break;

        case GESTURE(LEFT,RIGHT,NONE,NONE):
        case GESTURE(RIGHT,LEFT,NONE,NONE):
        {
            msg_Dbg( p_intf, "Play/Pause" );

            input_thread_t *p_input = playlist_CurrentInput( p_playlist );
            if( p_input == NULL )
                break;

            int i_state = var_GetInteger( p_input, "state" );
            i_state = (i_state == PLAYING_S) ? PAUSE_S : PLAYING_S;
            var_SetInteger( p_input, "state", i_state );
            vlc_object_release( p_input );
            break;
        }

        case GESTURE(LEFT,DOWN,NONE,NONE):
            playlist_Prev( p_playlist );
            break;

        case GESTURE(RIGHT,DOWN,NONE,NONE):
            playlist_Next( p_playlist );
            break;

        case UP:
            msg_Dbg(p_intf, "Louder");
            playlist_VolumeUp( p_playlist, 1, NULL );
            break;

        case DOWN:
            msg_Dbg(p_intf, "Quieter");
            playlist_VolumeDown( p_playlist, 1, NULL );
            break;

        case GESTURE(UP,DOWN,NONE,NONE):
        case GESTURE(DOWN,UP,NONE,NONE):
            msg_Dbg( p_intf, "Mute sound" );
            playlist_MuteToggle( p_playlist );
            break;

        case GESTURE(UP,RIGHT,NONE,NONE):
        {
            input_thread_t *p_input = playlist_CurrentInput( p_playlist );
            if( p_input == NULL )
                break;

            vlc_value_t list, list2;
            var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
                        &list, &list2 );

            if( list.p_list->i_count > 1 )
            {
                int i_audio_es = var_GetInteger( p_input, "audio-es" );
                int i;

                for( i = 0; i < list.p_list->i_count; i++ )
                     if( i_audio_es == list.p_list->p_values[i].i_int )
                         break;
                /* value of audio-es was not in choices list */
                if( i == list.p_list->i_count )
                {
                    msg_Warn( p_input,
                              "invalid current audio track, selecting 0" );
                    i = 0;
                }
                else if( i == list.p_list->i_count - 1 )
                    i = 1;
                else
                    i++;
                var_SetInteger( p_input, "audio-es",
                                list.p_list->p_values[i].i_int );
            }
            var_FreeList( &list, &list2 );
            vlc_object_release( p_input );
            break;
        }

        case GESTURE(DOWN,RIGHT,NONE,NONE):
        {
            input_thread_t *p_input = playlist_CurrentInput( p_playlist );
            if( p_input == NULL )
                break;

            vlc_value_t list, list2;
            var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
                        &list, &list2 );

            if( list.p_list->i_count > 1 )
            {
                int i_audio_es = var_GetInteger( p_input, "spu-es" );
                int i;

                for( i = 0; i < list.p_list->i_count; i++ )
                     if( i_audio_es == list.p_list->p_values[i].i_int )
                         break;
                /* value of audio-es was not in choices list */
                if( i == list.p_list->i_count )
                {
                    msg_Warn( p_input,
                              "invalid current subtitle track, selecting 0" );
                    i = 0;
                }
                else if( i == list.p_list->i_count - 1 )
                    i = 1;
                else
                    i++;
                var_SetInteger( p_input, "audio-es",
                                list.p_list->p_values[i].i_int );
            }
            var_FreeList( &list, &list2 );
            vlc_object_release( p_input );
            break;
        }

        case GESTURE(UP,LEFT,NONE,NONE):
        {
            bool val = var_ToggleBool( pl_Get( p_intf ), "fullscreen" );
            if( p_sys->p_vout )
                var_SetBool( p_sys->p_vout, "fullscreen", val );
            break;
        }

        case GESTURE(DOWN,LEFT,NONE,NONE):
            /* FIXME: Should close the vout!"*/
            libvlc_Quit( p_intf->p_libvlc );
            break;

        case GESTURE(DOWN,LEFT,UP,RIGHT):
        case GESTURE(UP,RIGHT,DOWN,LEFT):
            msg_Dbg( p_intf, "a square was drawn!" );
            break;
    }

    p_sys->i_num_gestures = 0;
    p_sys->i_pattern = 0;
}
Exemple #5
0
/*****************************************************************************
 * 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_prev( lua_State * L )
{
    playlist_t *p_playlist = vlclua_get_playlist_internal( L );
    playlist_Prev( p_playlist );
    return 0;
}
Exemple #7
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 );
    }
}
Exemple #8
0
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;
}
Exemple #9
0
void CmdPlaylistPrevious::execute()
{
    playlist_Prev( getPL() );
}
Exemple #10
0
/*****************************************************************************
 * RunIntf: main loop
 *****************************************************************************/
static void RunIntf( intf_thread_t *p_intf )
{
    intf_sys_t *p_sys = p_intf->p_sys;
    int canc = vlc_savecancel();
    input_thread_t *p_input;

    /* Main loop */
    while( vlc_object_alive( p_intf ) )
    {
        vlc_mutex_lock( &p_sys->lock );

        /*
         * mouse cursor
         */
        if( p_sys->b_got_gesture )
        {
            int i_interval = 0;
            /* Do something */
            /* If you modify this, please try to follow this convention:
               Start with LEFT, RIGHT for playback related commands
               and UP, DOWN, for other commands */
            playlist_t * p_playlist = pl_Get( p_intf );
            switch( p_sys->i_pattern )
            {
            case LEFT:
                msg_Dbg( p_intf, "Go backward in the movie!" );
                p_input = playlist_CurrentInput( p_playlist );
                if( p_input )
                {
                    i_interval = var_InheritInteger( p_intf , "short-jump-size" );
                    if ( i_interval > 0 )
                    {
                        mtime_t i_time = ( (mtime_t)( -i_interval ) * 1000000L);
                        var_SetTime( p_input, "time-offset", i_time );
                    }
                    vlc_object_release( p_input );
                }
                break;

            case RIGHT:
                msg_Dbg( p_intf, "Go forward in the movie!" );
                p_input = playlist_CurrentInput( p_playlist );
                if( p_input )
                {
                    i_interval = var_InheritInteger( p_intf , "short-jump-size" );
                    if ( i_interval > 0 )
                    {
                        mtime_t i_time = ( (mtime_t)( i_interval ) * 1000000L);
                        var_SetTime( p_input, "time-offset", i_time );
                    }
                    vlc_object_release( p_input );
                }
                break;

            case GESTURE(LEFT,UP,NONE,NONE):
                msg_Dbg( p_intf, "Going slower." );
                p_input = playlist_CurrentInput( p_playlist );
                if( p_input )
                {
                    var_TriggerCallback( p_input, "rate-slower" );
                    vlc_object_release( p_input );
                }
                break;

            case GESTURE(RIGHT,UP,NONE,NONE):
                msg_Dbg( p_intf, "Going faster." );
                p_input = playlist_CurrentInput( p_playlist );
                if( p_input )
                {
                    var_TriggerCallback( p_input, "rate-faster" );
                    vlc_object_release( p_input );
                }
                break;

            case GESTURE(LEFT,RIGHT,NONE,NONE):
            case GESTURE(RIGHT,LEFT,NONE,NONE):
                msg_Dbg( p_intf, "Play/Pause" );
                p_input = playlist_CurrentInput( p_playlist );
 
                if( p_input )
                {
                    int i_state = var_GetInteger( p_input, "state" );
                    var_SetInteger( p_input, "state", ( i_state != PLAYING_S )
                                                      ? PLAYING_S : PAUSE_S );
                    vlc_object_release( p_input );
                }
                break;

            case GESTURE(LEFT,DOWN,NONE,NONE):
                playlist_Prev( p_playlist );
                break;

            case GESTURE(RIGHT,DOWN,NONE,NONE):
                playlist_Next( p_playlist );
                break;

            case UP:
                msg_Dbg(p_intf, "Louder");
                aout_VolumeUp( p_playlist, 1, NULL );
                break;

            case DOWN:
                msg_Dbg(p_intf, "Quieter");
                aout_VolumeDown( p_playlist, 1, NULL );
                break;

            case GESTURE(UP,DOWN,NONE,NONE):
            case GESTURE(DOWN,UP,NONE,NONE):
                msg_Dbg( p_intf, "Mute sound" );
                aout_ToggleMute( p_playlist, NULL );
                break;

            case GESTURE(UP,RIGHT,NONE,NONE):
                {
                    vlc_value_t list, list2;
                    int i_count, i, i_audio_es;

                    p_input = playlist_CurrentInput( p_playlist );
                    if( !p_input )
                        break;

                    i_audio_es = var_GetInteger( p_input, "audio-es" );
                    var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
                                &list, &list2 );
                    i_count = list.p_list->i_count;
                    if( i_count <= 1 )
                    {
                        var_FreeList( &list, &list2 );
                        vlc_object_release( p_input );
                        break;
                    }
                    for( i = 0; i < i_count; i++ )
                    {
                        if( i_audio_es == 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" );
                        i = 0;
                    }
                    else if( i == i_count - 1 )
                        i = 1;
                    else
                        i++;
                    var_SetInteger( p_input, "audio-es", list.p_list->p_values[i].i_int );
                    var_FreeList( &list, &list2 );
                    vlc_object_release( p_input );
                }
                break;
            case GESTURE(DOWN,RIGHT,NONE,NONE):
                {
                    vlc_value_t list, list2;
                    int i_count, i, i_spu_es;

                    p_input = playlist_CurrentInput( p_playlist );
                    if( !p_input )
                        break;

                    i_spu_es = var_GetInteger( p_input, "spu-es" );

                    var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
                            &list, &list2 );
                    i_count = list.p_list->i_count;
                    if( i_count <= 1 )
                    {
                        vlc_object_release( p_input );
                        var_FreeList( &list, &list2 );
                        break;
                    }
                    for( i = 0; i < i_count; i++ )
                    {
                        if( i_spu_es == list.p_list->p_values[i].i_int )
                        {
                            break;
                        }
                    }
                    /* value of spu-es was not in choices list */
                    if( i == i_count )
                    {
                        msg_Warn( p_input,
                                "invalid current subtitle track, selecting 0" );
                        i = 0;
                    }
                    else if( i == i_count - 1 )
                        i = 0;
                    else
                        i++;
                    var_SetInteger( p_input, "spu-es", list.p_list->p_values[i].i_int);
                    var_FreeList( &list, &list2 );
                    vlc_object_release( p_input );
                }
                break;

            case GESTURE(UP,LEFT,NONE,NONE):
            {
                bool val = var_ToggleBool( pl_Get( p_intf ), "fullscreen" );
                if( p_sys->p_vout )
                    var_SetBool( p_sys->p_vout, "fullscreen", val );
                break;
           }

            case GESTURE(DOWN,LEFT,NONE,NONE):
                /* FIXME: Should close the vout!"*/
                libvlc_Quit( p_intf->p_libvlc );
                break;
            case GESTURE(DOWN,LEFT,UP,RIGHT):
            case GESTURE(UP,RIGHT,DOWN,LEFT):
                msg_Dbg( p_intf, "a square was drawn!" );
                break;
            default:
                break;
            }
            p_sys->i_num_gestures = 0;
            p_sys->i_pattern = 0;
            p_sys->b_got_gesture = false;
        }

        /*
         * video output
         */
        if( p_sys->p_vout && !vlc_object_alive( p_sys->p_vout ) )
        {
            var_DelCallback( p_sys->p_vout, "mouse-moved",
                             MouseEvent, p_intf );
            var_DelCallback( p_sys->p_vout, "mouse-button-down",
                             MouseEvent, p_intf );
            vlc_object_release( p_sys->p_vout );
            p_sys->p_vout = NULL;
        }

        if( p_sys->p_vout == NULL )
        {
            p_input = playlist_CurrentInput( pl_Get( p_intf ) );
            if( p_input )
            {
                p_sys->p_vout = input_GetVout( p_input );
                vlc_object_release( p_input );
            }
            if( p_sys->p_vout )
            {
                var_AddCallback( p_sys->p_vout, "mouse-moved",
                                 MouseEvent, p_intf );
                var_AddCallback( p_sys->p_vout, "mouse-button-down",
                                 MouseEvent, p_intf );
            }
        }

        vlc_mutex_unlock( &p_sys->lock );

        /* Wait a bit */
        msleep( INTF_IDLE_SLEEP );
    }

    vlc_restorecancel( canc );
}