]> git.sesse.net Git - mlt/commitdiff
add playlist-next event to mlt_playlist
authorDan Dennedy <dan@dennedy.org>
Fri, 31 Aug 2012 18:52:56 +0000 (11:52 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 31 Aug 2012 18:52:56 +0000 (11:52 -0700)
src/framework/mlt_playlist.c
src/framework/mlt_playlist.h

index 79fbd8bf65a82af2bceea710ccdd44abe0bbc7af..1d2851ec73989d94460e1a44ee503f62c1b250cb 100644 (file)
@@ -53,6 +53,7 @@ struct playlist_entry_s
 static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index );
 static int mlt_playlist_unmix( mlt_playlist self, int clip );
 static int mlt_playlist_resize_mix( mlt_playlist self, int clip, int in, int out );
+static void mlt_playlist_next( mlt_listener listener, mlt_properties owner, mlt_service self, void **args );
 
 /** Construct a playlist.
  *
@@ -99,6 +100,7 @@ mlt_playlist mlt_playlist_init( )
                self->list = calloc( self->size, sizeof( playlist_entry * ) );
                if ( self->list == NULL ) goto error2;
                
+               mlt_events_register( MLT_PLAYLIST_PROPERTIES( self ), "playlist-next", (mlt_transmitter) mlt_playlist_next );
        }
 
        return self;
@@ -394,6 +396,24 @@ static mlt_producer mlt_playlist_locate( mlt_playlist self, mlt_position *positi
        return producer;
 }
 
+/** The transmitter for the producer-next event
+ *
+ * Invokes the listener.
+ *
+ * \private \memberof mlt_playlist_s
+ * \param listener a function pointer that will be invoked
+ * \param owner the events object that will be passed to \p listener
+ * \param self a service that will be passed to \p listener
+ * \param args an array of pointers.
+ */
+
+static void mlt_playlist_next( mlt_listener listener, mlt_properties owner, mlt_service self, void **args )
+{
+       if ( listener )
+               listener( owner, self, args[ 0 ] );
+}
+
+
 /** Seek in the virtual playlist.
  *
  * This gets the producer at the current position and seeks on the producer
@@ -481,6 +501,10 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist self, int *progressiv
                producer = &self->blank;
        }
 
+       // Determine if we have moved to the next entry in the playlist.
+       if ( original == total - 2 )
+               mlt_events_fire( properties, "playlist-next", i, NULL );
+
        return MLT_PRODUCER_SERVICE( producer );
 }
 
index ee5411b579bace13ad04b941857ce4569f8fbc5f..58903823e4c593fdb0ee54b47942002dd0099465 100644 (file)
@@ -63,6 +63,8 @@ typedef struct playlist_entry_s playlist_entry;
  * which is a way to add filters as a playlist entry - useful only in a multitrack. See FxCut on the wiki.
  * \properties \em mix_in
  * \properties \em mix_out
+ * \event \em playlist-next The playlist fires this when it moves to the next item in the list.
+ * The listener receives one argument that is the index of the entry that just completed.
  */
 
 struct mlt_playlist_s