for a project on a Rpi I need a video to be played fullscreen. I was used to work with Omxplayer but as being deprecated I need now to use VLC. Sadly the video randomly start in a separate windows instead of starting fullscreen. Here is a part os the code. Any ideas how I should solve this?
from gpiozero import Button, LED
import vlc
import time
# Define GPIO pins for buttons and LEDs
GPI_1_PIN = 2
GPI_4_PIN = 4
GPO_2_PIN = 17
GPO_3_PIN = 27
GPO_5_PIN = 22
GPO_6_PIN = 23
# Set up Buttons and LEDs
button_1 = Button(GPI_1_PIN)
button_4 = Button(GPI_4_PIN)
led_2 = LED(GPO_2_PIN)
led_3 = LED(GPO_3_PIN)
led_5 = LED(GPO_5_PIN)
led_6 = LED(GPO_6_PIN)
# Variable to track button states
button_1_pressed = False
button_4_pressed = False
vlc_instance = vlc.Instance("--no-xlib")
player = vlc_instance.media_player_new()
# Function to play video
def play_video(video_path):
# Stop the currently playing video
player.stop()
media = vlc_instance.media_new(video_path)
media.get_mrl() # To get rid of VLC warnings
player.set_media(media)
time.sleep(1.1)
player.set_fullscreen(True)
player.play()
def display_photo(photo_path):
player.stop()
media = vlc_instance.media_new(photo_path)
media.get_mrl() # To get rid of VLC warnings
player.set_media(media)
time.sleep(1)
player.set_fullscreen(True)
player.play()
# Display the photo before entering the main loop
display_photo("video1.mp4")
# Main loop
try:
while True:
# Check if GPI_1 button is pressed
if button_1.is_pressed and not button_1_pressed:
button_1_pressed = True
player.stop()
time.sleep(0.5)
vlc_instance.release()
vlc_instance = vlc.Instance("--no-xlib")
player = vlc_instance.media_player_new()
play_video("video1.mp4")
led_2.on()
led_3.on()
time.sleep(0.1)
led_2.off()
led_3.off()
# Check if GPI_1 button is released
elif not button_1.is_pressed and button_1_pressed:
button_1_pressed = False
# Check if GPI_4 button is pressed
if button_4.is_pressed and not button_4_pressed:
button_4_pressed = True
led_5.on()
led_6.on()
time.sleep(0.1)
led_5.off()
led_6.off()
player.stop()
time.sleep(0.5)
vlc_instance.release()
vlc_instance = vlc.Instance("--no-xlib")
time.sleep(0.5)
player = vlc_instance.media_player_new()
play_video("video2.mov")
# Check if GPI_4 button is released
elif not button_4.is_pressed and button_4_pressed:
button_4_pressed = False
if player.get_state() == vlc.State.Ended:
player.stop()
player.set_position(0)
player.play()
except KeyboardInterrupt:
pass
finally:
player.release()
vlc_instance.release()
Is there a way to make the video ALWAYS start fullscreen?