Page 1 of 1

Looping video playback

Posted: 30 Nov 2023 17:13
by bLight
I'm writing code in Delphi using the PasLibVLC library.

I got playback, seeking, volume and play/pause working, but now I'm trying to solve looping.

I am capturing the "OnMediaPlayerEndReached" event and within it I'm calling "SetVideoPosInMs" with a value of "0" to reset the position and then calling the "Resume" function. It simply does nothing and no subsequent seek/pause/resume functions do anything.

I noticed from my log files the sequence of events VLC triggers, perhaps it will help gain some insights:

Code: Select all

30-Nov-23 18:07:43 [ 12528.33360000] : VLC: MediaPlayerTimeChanged: 01:20:04.203 30-Nov-23 18:07:43 [ 12627.62540000] : VLC: MediaPlayerEndReached 30-Nov-23 18:07:43 [ 12630.63180000] : VLC: MediaPlayerTimeChanged: 00:00:00.000 30-Nov-23 18:07:43 [ 12650.15320000] : VLC: MediaPlayerVideoOutChanged: 0 30-Nov-23 18:07:43 [ 12650.48810000] : VLC: PlayerEsSelected (video), id = -1 30-Nov-23 18:07:43 [ 12658.28510000] : VLC: PlayerEsSelected (audio), id = -1 30-Nov-23 18:07:43 [ 12658.75740000] : VLC: PlayerEsSelected (text), id = -1 30-Nov-23 18:07:43 [ 12659.07060000] : VLC: PlayerEsDeleted (video), id = 0 30-Nov-23 18:07:43 [ 12659.38380000] : VLC: PlayerEsDeleted (audio), id = 1 30-Nov-23 18:07:43 [ 12661.56880000] : VLC: PlayerEsDeleted (text), id = 2 30-Nov-23 18:07:43 [ 12662.48860000] : VLC: MediaPlayerStopped
As you can see, right after MediaPlayerEndReached is triggered, the position is reset to 0 like I designed it to, but then there's a series of events I'm not familiar with and the "resume" function doesn't work.

I can probably get around this issue by re-opening the file, but it fills like overkill, what am I missing?

Re: Looping video playback

Posted: 05 Dec 2023 14:12
by bLight
If anyone is curious,
I managed to work-around this issue by attaching the player to the medialist object and setting the looping mode on the medialist object.

Re: Looping video playback

Posted: 09 Dec 2023 15:08
by wbtcpip
the soultion is simple
call libvlc_media_player_get_state
if it's libvlc_Ended call libvlc_media_player_stop and media_player_play to restart it