Python Forum
Loop Video with OMXPlayer and omxplayer-wrapper
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop Video with OMXPlayer and omxplayer-wrapper
#1
Hello,

I am using the following code to play a video using a button press. It is set up so that the video starts playing when the button is pressed, and is stops playing when the button is released.

Currently everything is working as expected.

Right now, the video will play till the end and then stop, assuming you keep the button pressed.

What I am looking for is a way to loop the video back to the beginning if you keep the button pressed instead of stopping when the video is finished.

Regards,

Robert

App Versions:
os - Linux 10 Buster
script - Python3
player - OMXPlayer 08/01/2019
wrapper - omxplayer-wrapper 0.3.2

playvid.py file code:

#!/usr/bin/env python3
from omxplayer.player import OMXPlayer
from time import sleep
from signal import pause
from gpiozero import Button

buttonState = False
player = None

def playerExit(exit_code):
    global buttonState
    
    buttonState = False

def videoStart():
    global buttonState
    global player
    
    buttonState = True
    player = OMXPlayer(videoFile)
    player.set_volume(1)
    player.exitEvent += lambda _, exit_code: playerExit(exit_code)

def videoStop():
    global buttonState
    global player

    if player != None:
        if buttonState:
            player.stop()

try:
    videoFile = "/home/pi/Videos/chase.mp4"

    buttonPlay = Button(21)
    
    buttonPlay.when_pressed = videoStart
    buttonPlay.when_released = videoStop
    
    pause()

finally:
    pass
    
Reply


Messages In This Thread
Loop Video with OMXPlayer and omxplayer-wrapper - by uh60pin - Dec-28-2022, 04:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  SystemError: <method-wrapper '__getattribute__' of EnumMeta object sciloop 4 2,670 Jul-23-2022, 07:57 PM
Last Post: sciloop
  Using C++/CLI wrapper functions by Python Ales1000 2 2,938 Jun-21-2022, 04:50 AM
Last Post: Ales1000
  Python executable Script (Wrapper) Hwang 2 2,601 Jan-12-2022, 06:53 PM
Last Post: Hwang
  Sqla wrapper Slojure 1 2,109 Nov-01-2021, 04:36 PM
Last Post: Larz60+
  Python C++ wrapper problem JESuh 1 2,767 Mar-30-2021, 04:37 PM
Last Post: nilamo
  C++ Wrapper for python yamifm0f 6 4,787 Nov-07-2019, 06:40 PM
Last Post: Gribouillis
  generating ctypes wrapper for a c library? brighteningeyes 9 9,352 Nov-04-2018, 02:31 AM
Last Post: brighteningeyes
  how to retrieve datas with Overpass API python wrapper apollo 0 3,405 Oct-15-2017, 02:27 PM
Last Post: apollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020