Page 1 of 1

video stops when setting position or time

Posted: 08 Apr 2019 12:29
by daSpud99
I have a very simple player written in WinDev using the API calls. It works just fine until I try to setPosition or setTime. The video just stops and will not resume.

I can pause and resume the playing. Say I have a 10 minute video and I set position to .5. The getTime will return 300000 (or 5 minutes), but the video does not move. I can set the position to .25 and the getTime will return 150000 and the video will not move.

The IsPlaying indicator is always returning 0 even if the video is playing on the screen. also I did libvlc_video_set_key_input but the keys do not work to change the position being played. Also libvlc_media_player_is_seekable=1

I appreciate any suggestions as to what might be wrong or if there is another approach to being able to control the video. Thank you.

Re: video stops when setting position or time

Posted: 08 Apr 2019 15:05
by mfkl
Are you calling libvlc in a libvlc callback?

Re: video stops when setting position or time

Posted: 08 Apr 2019 18:24
by fossette
Are you calling libvlc in a libvlc callback?
Important question indeed!

Personally I try to avoid any processing in calback functions and threads, just set binary variables picked up by the main process.

From my experience, the libvlc_media_player_get_position() didn't give good results, always 0 too, but that's probably just me where I was familiarizing myself with the LibVLC library. Now, I only use libvlc_media_player_get_time() because it's more precise, and works beautifully.

All that being said, perhaps you fell into an undocumented/unhighlighted fact that when you call libvlc_media_player_play() for the first time, the video may not play or even exist when the play function returns. Results to call to libvlc_media_player_get_position() are irrelevant at that precise moment, and to the moment that the video actually plays. My work arround is to call sleep(1), that's a 1 second pause to enable the LibVLC thread to begin its work.

Food for thoughts! :D

Re: video stops when setting position or time

Posted: 09 Apr 2019 00:39
by daSpud99
Thank you for the replies. I don't know what "callback" is so I doubt I am using it. I was just following the sample

I was using both gettime and getposition to see what's what. Settime will move the time to the specified value (and gettime shows that), but the video will not play.

Re: video stops when setting position or time

Posted: 09 Apr 2019 08:30
by mfkl
Have no idea what sample you're referring to (there are quite a few on the internetz). Please share full code.

Re: video stops when setting position or time

Posted: 11 Apr 2019 07:34
by daSpud99
The sample code is found here. https://wiki.videolan.org/LibVLC_Tutorial I am using WinDev and API calls modeled after that sample and that works OK.

Now I want to do a bit more like be able to navigate with the keyboard and influence the position in the playing according to my own logic, but that does not seem to be working as the video just stops playing when I use settime or setposition.