]> git.sesse.net Git - vlc/commitdiff
* get/set/toggle fullscreen
authorClément Stenac <zorglub@videolan.org>
Tue, 7 Feb 2006 21:08:32 +0000 (21:08 +0000)
committerClément Stenac <zorglub@videolan.org>
Tue, 7 Feb 2006 21:08:32 +0000 (21:08 +0000)
* Fix a bug in playlist_play

(Refs:#457)

Makefile.am
include/vlc/libvlc.h
src/control/playlist.c
src/control/video.c [new file with mode: 0644]
test/libvlc_sample.c

index 139dba4f9c0e0d2d0abad6033ca1d73f9433194d..5d3ae03b86ebe1bd47a7b881f6a13acd9af29ff3 100644 (file)
@@ -476,6 +476,7 @@ SOURCES_libvlc_common = \
        src/control/core.c \
        src/control/playlist.c \
        src/control/input.c \
+       src/control/video.c \
        src/control/mediacontrol_core.c \
        src/control/mediacontrol_util.c \
        src/control/mediacontrol_audio_video.c \
index 6127c3e6340dbec74a2b7b469b8ab979ea747a01..14d4e6b7f3b8c06ca25938ccb26510f33ac85e42 100644 (file)
@@ -229,6 +229,10 @@ vlc_int64_t libvlc_input_get_length( libvlc_input_t *, libvlc_exception_t *);
 vlc_int64_t libvlc_input_get_time( libvlc_input_t *, libvlc_exception_t *);
 float libvlc_input_get_position( libvlc_input_t *, libvlc_exception_t *);
 
+
+void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
+
+
 /** @} */
 
 
index 12e1ebca2a891df5e53d746defc6aed9d0567072..7070307c269c06a21d89b6674be4c1a039599922 100644 (file)
@@ -37,7 +37,7 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
         libvlc_exception_raise( p_exception, "Empty playlist" );
         return;
     }
-    if( i_id >= 0 )
+    if( i_id > 0 )
     {
         /* Always use the current view when using libvlc */
         playlist_view_t *p_view;
diff --git a/src/control/video.c b/src/control/video.c
new file mode 100644 (file)
index 0000000..8605b9c
--- /dev/null
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * video.c: ibvlc new API video functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id: core.c 14187 2006-02-07 16:37:40Z courmisch $
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <vlc/vout.h>
+#include <vlc/intf.h>
+
+static vout_thread_t *GetVout( libvlc_input_t *p_input,
+                               libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vout_thread_t *p_vout;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return NULL;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                                 p_input->p_instance->p_vlc,
+                                 p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return NULL;
+    }
+
+    p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_CHILD );
+    if( !p_vout )
+    {
+        libvlc_exception_raise( p_exception, "No active video output" );
+        return NULL;
+    }
+    return p_vout;
+}
+/**********************************************************************
+ * Exported functions
+ **********************************************************************/
+
+void libvlc_set_fullscreen( libvlc_input_t *p_input, int b_fullscreen,
+                            libvlc_exception_t *p_e )
+{
+    /* We only work on the first vout */
+    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vlc_value_t val; int i_ret;
+
+    /* GetVout will raise the exception for us */
+    if( !p_vout1 )
+    {
+        fprintf( stderr, "No vout\n");
+        return;
+    }
+
+    if( b_fullscreen ) val.b_bool = VLC_TRUE;
+    else               val.b_bool = VLC_FALSE;
+
+    var_Set( p_vout1, "fullscreen", val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while setting fullscreen value" );
+}
+
+int libvlc_get_fullscreen( libvlc_input_t *p_input,
+                            libvlc_exception_t *p_e )
+{
+    /* We only work on the first vout */
+    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vlc_value_t val; int i_ret;
+
+    /* GetVout will raise the exception for us */
+    if( !p_vout1 )
+        return 0;
+
+    i_ret = var_Get( p_vout1, "fullscreen", &val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while looking up fullscreen value" );
+
+    return val.b_bool == VLC_TRUE ? 1 : 0;
+}
+
+void libvlc_toggle_fullscreen( libvlc_input_t *p_input,
+                               libvlc_exception_t *p_e )
+{
+    /* We only work on the first vout */
+    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vlc_value_t val; int i_ret;
+
+    /* GetVout will raise the exception for us */
+    if( !p_vout1 )
+        return;
+
+    i_ret = var_Get( p_vout1, "fullscreen", &val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while looking up fullscreen value" );
+
+    val.b_bool = !val.b_bool;
+    i_ret = var_Set( p_vout1, "fullscreen", val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while setting fullscreen value" );
+}
index 4455c2125a5c48127fe494e3d791ab724ab0ae65..aa59fee8ec0509dfce6e7a213c76323804224ea0 100644 (file)
@@ -20,7 +20,9 @@ int main(int argc, char **argv)
         return 0; 
     }
 
-    libvlc_playlist_play( p_instance1, 0,NULL, NULL );
+    fprintf (stderr, "Playing\n");
+    libvlc_playlist_play( p_instance1, 0, 0,NULL, NULL );
+    fprintf (stderr, "Playback started\n");
 
     while( 1 )
     {
@@ -39,10 +41,16 @@ int main(int argc, char **argv)
         {
             b_started = 1;
         }
-        
-        fprintf( stderr, "Length %lli - Time %lli\n", 
+
+        libvlc_toggle_fullscreen( p_input, &exception );
+        if( libvlc_exception_raised( &exception ) )
+        {
+            fprintf( stderr, "EX : %s\n", libvlc_exception_get_message( &exception ) );
+        }
+        fprintf( stderr, "Length %lli - Time %lli - Full screen %i\n", 
                               libvlc_input_get_length( p_input, NULL ),
-                              libvlc_input_get_time( p_input, NULL ) );
+                              libvlc_input_get_time( p_input, NULL ), 
+                              libvlc_get_fullscreen( p_input, NULL ) );
         libvlc_input_free( p_input );
     }