]> git.sesse.net Git - vlc/blobdiff - src/control/media_player.c
Extend libvlc Media Player API for DVD menu navigation
[vlc] / src / control / media_player.c
index 328a7e40cf2534da066223cb502fc53767742146..3789ddf90a03eda5d89525329010f704a6908c77 100644 (file)
@@ -34,6 +34,7 @@
 #include <vlc_demux.h>
 #include <vlc_input.h>
 #include <vlc_vout.h>
+#include <vlc_keys.h>
 
 #include "libvlc.h"
 
 #include "media_internal.h" // libvlc_media_set_state()
 #include "media_player_internal.h"
 
+/*
+ * mapping of libvlc_navigate_mode_t to vlc_key_t
+ */
+static const vlc_key_t libvlc_navigate_to_action[] =
+  {
+    ACTIONID_NAV_ACTIVATE,
+    ACTIONID_NAV_UP,
+    ACTIONID_NAV_DOWN,
+    ACTIONID_NAV_LEFT,
+    ACTIONID_NAV_RIGHT
+  };
+
+static const uint32_t libvlc_navigate_to_action_size =                 \
+  sizeof( libvlc_navigate_to_action ) / sizeof( libvlc_navigate_to_action[0] );
+
+
 static int
 input_seekable_changed( vlc_object_t * p_this, char const * psz_cmd,
                         vlc_value_t oldval, vlc_value_t newval,
@@ -1200,6 +1217,24 @@ int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi )
     return b_seekable;
 }
 
+void libvlc_media_player_navigate( libvlc_media_player_t* p_mi,
+                                  unsigned navigate )
+{
+    input_thread_t *p_input_thread;
+
+    if ( navigate > libvlc_navigate_to_action_size)
+      return;
+
+    p_input_thread = libvlc_get_input_thread ( p_mi );
+    if ( !p_input_thread )
+      return;
+
+    var_SetInteger( p_mi->p_libvlc_instance->p_libvlc_int,
+                   "key-action", libvlc_navigate_to_action[navigate] );
+
+    vlc_object_release( p_input_thread );
+}
+
 /* internal function, used by audio, video */
 libvlc_track_description_t *
         libvlc_get_track_description( libvlc_media_player_t *p_mi,