Reputation: 5620
I am currently on a java project that uses a vlc socket remote control interface to play audiovisual content (e.g. vlc -I rc --rc-host=localhost:[portnumber]
). The interface leads to some particular cases that seem complex to deal with:
According to the vlc remote control help, the pause command is a toggle function so you have to keep trace of the current state of the player.
The add
command will start the video only if the current video isn't paused.
The is_playing
command always outputs 1, whenever it is paused or not and the
status
command doesn't say if it is paused or not.
A constraint of the client is that videos need to be paused on the last frame. Fortunately, there is a parameter to deal with it : --play-and-pause
.
The problem is as following. If vlc gets to the last frame and pause the video by itself, how can I know about it ? For now, I use get_time
in hope of simply considering the video paused if the countdown is equal to 0. However, it occurs that vlc pauses the video itself at 0:01, forcing me to also consier 0:01 as a finishing value. This results in a glitch when the user starts another video while there really is one second remaining before the last frame, since the 0:01 check is considering it as paused while it's not. Here's a summary of what happens:
0:20 (not paused) + play button : send("add [filepath]");
Fine
0:00 (paused) + play button : send("pause"); send("add [filepath]");
Fine
0:01 (paused) + play button : send("pause"); send("add [filepath]");
Fine
0:01 (not paused) + play button : send("pause"); send("add [filepath]");
Unexpected behavior: it won't play, because it is paused and we don't know about it
Is there a safe approach to deal with the player state so there is no undefined behavior? I noticed that the remote control console sometime outputs something when vlc pauses by itself. However, it seems unsafe since it may output some events that are fired before of after this event.
Thank you.
Upvotes: 1
Views: 1618
Reputation: 1
Why don´t you prevent the player from reaching 00:01? E.g. if countdown = 00:02 start next.
Upvotes: 0
Reputation: 23263
What is the granularity of the countdown timer? Could you sample the time remaining twice with a gap equal to the smallest supported time unit? For example, if it's seconds, you check the time, wait a second and then check it again. If the time has changed, it's still playing, if it hasn't it's paused. Only downside is that it will introduces a one second delay to the responsiveness of your application.
Upvotes: 1