How to quit in Rpi CLI

This forum is about all development around libVLC.
Dinosaur1946
Blank Cone
Blank Cone
Posts: 30
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

How to quit in Rpi CLI

Postby Dinosaur1946 » 01 Dec 2024 00:56

Hi All

Originally posted here:[url][https://forum.videolan.org/viewtopic.ph ... 165660/url]
But after graduating to using the library, thought this the better place.

Using a Rpi Zero W 2 booting directly to cli as a headless system.
In other words X is not loaded.
Then in /etc/rc.local I start my app.
This app is developed in FreeBasic and uses libvlc and libvlccore
The apps purpose (which works) is to read a spreadsheet .csv file which holds
filenames and runtimes in seconds.
When the Runtime expires, the video/Picture/Music is stopped and the next File is played.
If a push button is pressed then it will use a different group of files.
Once all files are played it restarts from the beginning.

The 'Pseudo' code

Code: Select all

Dim as string qStr = "--global-key-quit " & Chr(34) & "q" '' An attempt to get q to work ?? Dim As Any Ptr vlc_args(0 To ...) = { @"--no-xlib",@"--quiet",@qStr} '' does not produce a vlc error. instance = libvlc_new (UBound(vlc_args) + 1, @vlc_args(0)) ''libvlc_new (0, NULL) 'Load the VLC engine media = libvlc_media_new_path(instance, .Next2Play) ''Load media file mediaPlayer = libvlc_media_player_new_from_media(media) ''Create a media player playing environement libvlc_media_release(media) ''No need to keep the media now libvlc_media_player_play(mediaPlayer) ''Play the media Do TimeGet #if defined(Rpi) If Times.mSec - Times.GetIO > 750 Then ''only look for PB every Sec Get_Inputs Times.GetIO = Times.mSec EndIf #endif If Next_Group > 0 Then Exit Do ''or a Button was pressed, goto List1 or 2 If Val(Entry.RunTime(Xq)) > 0 Then ''using Libvlc to detect that Video is finished If Times.Secs - Times.StartTime > Val(Entry.RunTime(Xq)) Then Exit do''Is just to time consuming and not suitable EndIf ''for showing jpeg's, so set time for each one. Sleep 1,1 Loop libvlc_media_player_stop(mediaPlayer) ''Stop playing libvlc_media_player_release(mediaPlayer) ''Free the media_player If Next_Group > 0 Then Exit For
vlc is fully installed and if this code is run from a CLI once X was started then Alt F4 will exit the video.
Attempting to use Alt F4 or 'q' without starting X is ignored.
Once installed on site, I will need to exit and Starx to make any changes.

Hoping someone can shed some light on this.

Regards

mfkl
Developer
Developer
Posts: 746
Joined: 13 Jun 2017 10:41

Re: How to quit in Rpi CLI

Postby mfkl » 02 Dec 2024 13:10

You're already listening to button events. So listen for 'q' being pressed specifically and run your exit code when that happens?
https://mfkl.github.io

Dinosaur1946
Blank Cone
Blank Cone
Posts: 30
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: How to quit in Rpi CLI

Postby Dinosaur1946 » 02 Dec 2024 21:00

Hi All

That's the problem, my app seems not to have Kbd access (for any key) when booting into cli.
If loading X then yes.
If I run ; libvlc_release(instance) then yes, but I don't want to release the instance between videos.

Regards

mfkl
Developer
Developer
Posts: 746
Joined: 13 Jun 2017 10:41

Re: How to quit in Rpi CLI

Postby mfkl » 03 Dec 2024 10:18

maybe try libvlc_video_set_key_input. Otherwise I don't know.
https://mfkl.github.io

Rémi Denis-Courmont
Developer
Developer
Posts: 15279
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How to quit in Rpi CLI

Postby Rémi Denis-Courmont » 03 Dec 2024 12:51

There are three ways to quit the CLI: send the VLC process the INT signal, end the standard input of the VLC process, or feed it the "quit" command. If you are using the dummy VLC, then INT signal is the only way.

If you are not using VLC from the CLI but another app, then you are on the wrong fora. Please refer to the app documentation.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: Google [Bot] and 49 guests