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
#2
There should be a method to set start time, but I don't see it.
The docs page shows a command list https://elinux.org/Omxplayer
here they show a rewind command, but i Can't find it on wrapper docs
Perhaps look for this command.
Reply
#3
(Dec-28-2022, 05:20 PM)Larz60+ Wrote: There should be a method to set start time, but I don't see it.
The docs page shows a command list https://elinux.org/Omxplayer
here they show a rewind command, but i Can't find it on wrapper docs
Perhaps look for this command.

Thanks,

There is an option for looping...

--loop

However I am not sure how to integrate that option, or any of the other options for OMXPlayer into my code.

Regards,

Robert
Reply
#4
I found the solution using the args Parameter.

Thanks,

Robert
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SystemError: <method-wrapper '__getattribute__' of EnumMeta object sciloop 4 1,520 Jul-23-2022, 07:57 PM
Last Post: sciloop
  Using C++/CLI wrapper functions by Python Ales1000 2 1,782 Jun-21-2022, 04:50 AM
Last Post: Ales1000
  Python executable Script (Wrapper) Hwang 2 1,899 Jan-12-2022, 06:53 PM
Last Post: Hwang
  Sqla wrapper Slojure 1 1,540 Nov-01-2021, 04:36 PM
Last Post: Larz60+
  Python C++ wrapper problem JESuh 1 2,173 Mar-30-2021, 04:37 PM
Last Post: nilamo
  C++ Wrapper for python yamifm0f 6 3,126 Nov-07-2019, 06:40 PM
Last Post: Gribouillis
  generating ctypes wrapper for a c library? brighteningeyes 9 7,085 Nov-04-2018, 02:31 AM
Last Post: brighteningeyes
  how to retrieve datas with Overpass API python wrapper apollo 0 2,921 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