[vlc-commits] [Git][videolan/vlc][master] 5 commits: doc: examples: use the Stopped event

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sat Mar 12 09:54:25 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
6d3b8ada by Thomas Guillem at 2022-03-12T09:41:12+00:00
doc: examples: use the Stopped event

>From VLC 4.0, Ended or EndReached are sent when the player is stopping,
so listen to the stopped event instead.

- - - - -
5c1387c3 by Thomas Guillem at 2022-03-12T09:41:12+00:00
lib: media_list: use the Stopped event

EndReached is sent when the player is stopping, so listen to the stopped
event instead.

- - - - -
c338de7b by Thomas Guillem at 2022-03-12T09:41:12+00:00
lib: media_player: rename EndReached to Stopping

Since it's sent when the player begins to stop (on VLC 3.0 and 4.0).

- - - - -
c2c5341f by Thomas Guillem at 2022-03-12T09:41:12+00:00
lib: media: remove deprecated comment

- - - - -
be78a1ac by Thomas Guillem at 2022-03-12T09:41:12+00:00
lib: media: rename Ended to Stopped

In VLC 3.0, this event was sent for END_S (input_thread_t is stopping)
and INPUT_DEAD_EVENT (input_thread_t is stopped).

In VLC 4.0, this event is sent when the player is stopping.

The renaming reflect the actual state.

- - - - -


6 changed files:

- doc/libvlc/QtPlayer/player.cpp
- doc/libvlc/wx_player.cpp
- include/vlc/libvlc_events.h
- include/vlc/libvlc_media.h
- lib/media_list_player.c
- lib/media_player.c


Changes:

=====================================
doc/libvlc/QtPlayer/player.cpp
=====================================
@@ -200,7 +200,7 @@ void Mwindow::updateInterface() { //Update interface and check if song is finish
     slider->setValue((int)(pos*1000.0));
 
     /* Stop the media */
-    if (libvlc_media_player_get_state(vlcPlayer) == libvlc_Ended)
+    if (libvlc_media_player_get_state(vlcPlayer) == libvlc_Stopped)
         this->stop();
 }
 


=====================================
doc/libvlc/wx_player.cpp
=====================================
@@ -122,7 +122,7 @@ MainWindow::MainWindow(const wxString& title) : wxFrame(NULL, wxID_ANY, title, w
     vlc_inst = libvlc_new(0, NULL);
     media_player = libvlc_media_player_new(vlc_inst);
     vlc_evt_man = libvlc_media_player_event_manager(media_player);
-    libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerEndReached, ::OnEndReached_VLC, NULL);
+    libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerStopped, ::OnEndReached_VLC, NULL);
     libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPositionChanged, ::OnPositionChanged_VLC, NULL);
     Connect(wxID_ANY, vlcEVT_END, wxCommandEventHandler(MainWindow::OnEndReached_VLC));
     Connect(wxID_ANY, vlcEVT_POS, wxCommandEventHandler(MainWindow::OnPositionChanged_VLC));


=====================================
include/vlc/libvlc_events.h
=====================================
@@ -105,7 +105,7 @@ enum libvlc_event_e {
     libvlc_MediaPlayerStopped,
     libvlc_MediaPlayerForward,
     libvlc_MediaPlayerBackward,
-    libvlc_MediaPlayerEndReached,
+    libvlc_MediaPlayerStopping,
     libvlc_MediaPlayerEncounteredError,
     libvlc_MediaPlayerTimeChanged,
     libvlc_MediaPlayerPositionChanged,


=====================================
include/vlc/libvlc_media.h
=====================================
@@ -77,13 +77,7 @@ typedef enum libvlc_meta_t {
 } libvlc_meta_t;
 
 /**
- * Note the order of libvlc_state_t enum must match exactly the order of
- * \see mediacontrol_PlayerStatus, \see input_state_e enums,
- * and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs).
- *
- * Expected states by web plugins are:
- * IDLE/CLOSE=0, OPENING=1, PLAYING=3, PAUSED=4,
- * STOPPING=5, ENDED=6, ERROR=7
+ * libvlc media or media_player state
  */
 typedef enum libvlc_state_t
 {
@@ -95,7 +89,7 @@ typedef enum libvlc_state_t
     libvlc_Playing,
     libvlc_Paused,
     libvlc_Stopped,
-    libvlc_Ended,
+    libvlc_Stopping,
     libvlc_Error
 } libvlc_state_t;
 
@@ -506,7 +500,7 @@ LIBVLC_API int libvlc_media_save_meta( libvlc_media_t *p_md );
 /**
  * Get current state of media descriptor object. Possible media states are
  * libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused,
- * libvlc_Stopped, libvlc_Ended, libvlc_Error.
+ * libvlc_Stopped, libvlc_Stopping, libvlc_Error.
  *
  * \see libvlc_state_t
  * \param p_md a media descriptor object


=====================================
lib/media_list_player.c
=====================================
@@ -400,7 +400,7 @@ uninstall_playlist_observer(libvlc_media_list_player_t * p_mlp)
 static void
 install_media_player_observer(libvlc_media_list_player_t * p_mlp)
 {
-    libvlc_event_attach(mplayer_em(p_mlp), libvlc_MediaPlayerEndReached, media_player_reached_end, p_mlp);
+    libvlc_event_attach(mplayer_em(p_mlp), libvlc_MediaPlayerStopped, media_player_reached_end, p_mlp);
 }
 
 
@@ -415,7 +415,7 @@ uninstall_media_player_observer(libvlc_media_list_player_t * p_mlp)
     // Allow callbacks to run, because detach() will wait until all callbacks are processed.
     // This is safe because only callbacks are allowed, and there execution will be cancelled.
     vlc_mutex_unlock(&p_mlp->mp_callback_lock);
-    libvlc_event_detach(mplayer_em(p_mlp), libvlc_MediaPlayerEndReached, media_player_reached_end, p_mlp);
+    libvlc_event_detach(mplayer_em(p_mlp), libvlc_MediaPlayerStopped, media_player_reached_end, p_mlp);
 
     // Now, lock back the callback lock. No more callback will be present from this point.
     vlc_mutex_lock(&p_mlp->mp_callback_lock);


=====================================
lib/media_player.c
=====================================
@@ -92,7 +92,7 @@ on_state_changed(vlc_player_t *player, enum vlc_player_state new_state,
             event.type = libvlc_MediaPlayerStopped;
             break;
         case VLC_PLAYER_STATE_STOPPING:
-            event.type = libvlc_MediaPlayerEndReached;
+            event.type = libvlc_MediaPlayerStopping;
             break;
         case VLC_PLAYER_STATE_STARTED:
             event.type = libvlc_MediaPlayerOpening;
@@ -1602,7 +1602,7 @@ libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi )
         case VLC_PLAYER_STATE_STOPPED:
             return libvlc_Stopped;
         case VLC_PLAYER_STATE_STOPPING:
-            return libvlc_Ended;
+            return libvlc_Stopping;
         case VLC_PLAYER_STATE_STARTED:
             return libvlc_Opening;
         case VLC_PLAYER_STATE_PLAYING:



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4c73518d6efce66c2d05e94dd6f517f68a506d2e...be78a1ac3d46b47d35c0e2ad5f30f3b023b85d9b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4c73518d6efce66c2d05e94dd6f517f68a506d2e...be78a1ac3d46b47d35c0e2ad5f30f3b023b85d9b
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list