[vlc-devel] commit: libvlc: add libvlc_MediaInstanceStopped (Tanguy Krotoff )

git version control git at videolan.org
Mon Mar 31 12:18:49 CEST 2008


vlc | branch: master | Tanguy Krotoff <tkrotoff at gmail.com> | Mon Mar 31 06:35:07 2008 +0200| [ee1330c497b5c78f5fcfd0145391f219e489e13a]

libvlc: add libvlc_MediaInstanceStopped

Signed-off-by: Pierre d'Herbemont <pdherbemont at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ee1330c497b5c78f5fcfd0145391f219e489e13a
---

 .../videolan/jvlc/event/MediaInstanceCallback.java |    2 +-
 .../videolan/jvlc/internal/LibVlcEventType.java    |    3 ++-
 .../org/videolan/jvlc/internal/LibVlcImpl.java     |    4 ++--
 include/vlc/libvlc_events.h                        |    3 ++-
 projects/macosx/framework/Sources/VLCMediaPlayer.m |    6 +++---
 src/control/event.c                                |    3 ++-
 src/control/media_list_player.c                    |    6 +++---
 src/control/media_player.c                         |   14 +++++++++++---
 src/control/testapi.c                              |    3 ++-
 9 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaInstanceCallback.java b/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaInstanceCallback.java
index ab1aa0e..8c36e68 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaInstanceCallback.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaInstanceCallback.java
@@ -60,7 +60,7 @@ public class MediaInstanceCallback implements LibVlcCallback
         {
             listener.paused(mediaInstance);
         }
-        else if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstanceReachedEnd.ordinal())
+        else if (libvlc_event.type == LibVlcEventType.libvlc_MediaInstanceEndReached.ordinal())
         {
             listener.endReached(mediaInstance);
         }
diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcEventType.java b/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcEventType.java
index 776c84b..32615d0 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcEventType.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcEventType.java
@@ -36,7 +36,8 @@ public enum LibVlcEventType {
     libvlc_MediaDescriptorStateChanged,
     libvlc_MediaInstancePlayed,
     libvlc_MediaInstancePaused,
-    libvlc_MediaInstanceReachedEnd,
+    libvlc_MediaInstanceEndReached,
+    libvlc_MediaInstanceStopped,
     libvlc_MediaInstanceEncounteredError,
     libvlc_MediaInstanceTimeChanged,
     libvlc_MediaInstancePositionChanged;
diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcImpl.java b/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcImpl.java
index ae97655..d9467c7 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcImpl.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlcImpl.java
@@ -98,11 +98,11 @@ public class LibVlcImpl
 
         libVlc.libvlc_event_attach(
             mediaInstanceEventManager,
-            LibVlcEventType.libvlc_MediaInstanceReachedEnd.ordinal(),
+            LibVlcEventType.libvlc_MediaInstanceEndReached.ordinal(),
             endReached,
             null,
             exception);
-        
+
         JFrame frame = new JFrame("title");
         frame.setVisible(true);
         frame.setLocation(100, 100);
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index fe7f2e0..cba64a3 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -49,7 +49,8 @@ typedef enum libvlc_event_type_t {
 
     libvlc_MediaInstancePlayed,
     libvlc_MediaInstancePaused,
-    libvlc_MediaInstanceReachedEnd,
+    libvlc_MediaInstanceEndReached,
+    libvlc_MediaInstanceStopped,
     libvlc_MediaInstanceEncounteredError,
     libvlc_MediaInstanceTimeChanged,
     libvlc_MediaInstancePositionChanged,
diff --git a/projects/macosx/framework/Sources/VLCMediaPlayer.m b/projects/macosx/framework/Sources/VLCMediaPlayer.m
index ba8d797..fd5111c 100644
--- a/projects/macosx/framework/Sources/VLCMediaPlayer.m
+++ b/projects/macosx/framework/Sources/VLCMediaPlayer.m
@@ -92,7 +92,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
         newState = VLCMediaPlayerStatePlaying;
     else if( event->type == libvlc_MediaInstancePaused )
         newState = VLCMediaPlayerStatePaused;
-    else if( event->type == libvlc_MediaInstanceReachedEnd )
+    else if( event->type == libvlc_MediaInstanceEndReached )
         newState = VLCMediaPlayerStateStopped;
     else if( event->type == libvlc_MediaInstanceEncounteredError )
         newState = VLCMediaPlayerStateError;
@@ -642,7 +642,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     libvlc_event_manager_t * p_em = libvlc_media_player_event_manager( instance, &ex );
     libvlc_event_attach( p_em, libvlc_MediaInstancePlayed,          HandleMediaInstanceStateChanged, self, &ex );
     libvlc_event_attach( p_em, libvlc_MediaInstancePaused,          HandleMediaInstanceStateChanged, self, &ex );
-    libvlc_event_attach( p_em, libvlc_MediaInstanceReachedEnd,      HandleMediaInstanceStateChanged, self, &ex );
+    libvlc_event_attach( p_em, libvlc_MediaInstanceEndReached,      HandleMediaInstanceStateChanged, self, &ex );
     /* FIXME: We may want to turn that off when none is interested by that */
     libvlc_event_attach( p_em, libvlc_MediaInstancePositionChanged, HandleMediaPositionChanged,      self, &ex );
     libvlc_event_attach( p_em, libvlc_MediaInstanceTimeChanged,     HandleMediaTimeChanged,          self, &ex );
@@ -654,7 +654,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     libvlc_event_manager_t * p_em = libvlc_media_player_event_manager( instance, NULL );
     libvlc_event_detach( p_em, libvlc_MediaInstancePlayed,          HandleMediaInstanceStateChanged, self, NULL );
     libvlc_event_detach( p_em, libvlc_MediaInstancePaused,          HandleMediaInstanceStateChanged, self, NULL );
-    libvlc_event_detach( p_em, libvlc_MediaInstanceReachedEnd,      HandleMediaInstanceStateChanged, self, NULL );
+    libvlc_event_detach( p_em, libvlc_MediaInstanceEndReached,      HandleMediaInstanceStateChanged, self, NULL );
     libvlc_event_detach( p_em, libvlc_MediaInstancePositionChanged, HandleMediaPositionChanged,      self, NULL );
     libvlc_event_detach( p_em, libvlc_MediaInstanceTimeChanged,     HandleMediaTimeChanged,          self, NULL );
 }
diff --git a/src/control/event.c b/src/control/event.c
index cf5999c..b98f14c 100644
--- a/src/control/event.c
+++ b/src/control/event.c
@@ -263,7 +263,8 @@ static const char * event_type_to_name[] =
 
     EVENT(libvlc_MediaInstancePlayed),
     EVENT(libvlc_MediaInstancePaused),
-    EVENT(libvlc_MediaInstanceReachedEnd),
+    EVENT(libvlc_MediaInstanceEndReached),
+    EVENT(libvlc_MediaInstanceStopped),
     EVENT(libvlc_MediaInstanceTimeChanged),
     EVENT(libvlc_MediaInstancePositionChanged),
 
diff --git a/src/control/media_list_player.c b/src/control/media_list_player.c
index 4db4c86..89f1155 100644
--- a/src/control/media_list_player.c
+++ b/src/control/media_list_player.c
@@ -170,7 +170,7 @@ static void
 install_media_player_observer( libvlc_media_list_player_t * p_mlp )
 {
     libvlc_event_attach( libvlc_media_player_event_manager( p_mlp->p_mi, NULL ),
-                         libvlc_MediaInstanceReachedEnd,
+                         libvlc_MediaInstanceEndReached,
                           media_player_reached_end, p_mlp, NULL );
 }
 
@@ -185,9 +185,9 @@ uninstall_media_player_observer( libvlc_media_list_player_t * p_mlp )
     {
         return;
     }
-        
+
     libvlc_event_detach( libvlc_media_player_event_manager( p_mlp->p_mi, NULL ),
-                         libvlc_MediaInstanceReachedEnd,
+                         libvlc_MediaInstanceEndReached,
                          media_player_reached_end, p_mlp, NULL );
 }
 
diff --git a/src/control/media_player.c b/src/control/media_player.c
index f8968a5..bc026a9 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -149,7 +149,7 @@ input_state_changed( vlc_object_t * p_this, char const * psz_cmd,
     {
         case END_S:
             libvlc_media_set_state( p_mi->p_md, libvlc_NothingSpecial, NULL);
-            event.type = libvlc_MediaInstanceReachedEnd;
+            event.type = libvlc_MediaInstanceEndReached;
             break;
         case PAUSE_S:
             libvlc_media_set_state( p_mi->p_md, libvlc_Playing, NULL);
@@ -314,9 +314,11 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance,
         free( p_mi );
         return NULL;
     }
- 
+
+    libvlc_event_manager_register_event_type( p_mi->p_event_manager,
+            libvlc_MediaInstanceEndReached, p_e );
     libvlc_event_manager_register_event_type( p_mi->p_event_manager,
-            libvlc_MediaInstanceReachedEnd, p_e );
+            libvlc_MediaInstanceStopped, p_e );
     libvlc_event_manager_register_event_type( p_mi->p_event_manager,
             libvlc_MediaInstanceEncounteredError, p_e );
     libvlc_event_manager_register_event_type( p_mi->p_event_manager,
@@ -641,6 +643,12 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
         input_StopThread( p_input_thread );
         vlc_object_release( p_input_thread );
     }
+
+    /* Send a stop notification event */
+    libvlc_event_t event;
+    libvlc_media_set_state( p_mi->p_md, libvlc_Stopped, NULL);
+    event.type = libvlc_MediaInstanceStopped;
+    libvlc_event_send( p_mi->p_event_manager, &event );
 }
 
 /**************************************************************************
diff --git a/src/control/testapi.c b/src/control/testapi.c
index bb61fd4..c779fff 100644
--- a/src/control/testapi.c
+++ b/src/control/testapi.c
@@ -247,7 +247,8 @@ static void test_events (const char ** argv, int argc)
     libvlc_event_type_t mi_events[] = {
         libvlc_MediaInstancePlayed,
         libvlc_MediaInstancePaused,
-        libvlc_MediaInstanceReachedEnd,
+        libvlc_MediaInstanceEndReached,
+        libvlc_MediaInstanceStopped,
         libvlc_MediaInstanceEncounteredError,
         libvlc_MediaInstanceTimeChanged,
         libvlc_MediaInstancePositionChanged,




More information about the vlc-devel mailing list