willprice / python-omxplayer-wrapper

:tv: Control OMXPlayer, the Raspberry Pi media player, from Python
http://python-omxplayer-wrapper.readthedocs.io
GNU Lesser General Public License v3.0
253 stars 72 forks source link

playEvent triggered twice and request for a loadEvent #207

Open SebDominguez opened 3 years ago

SebDominguez commented 3 years ago

Issue Report

Description

playEvent is triggered twice and load() doesn't trigger playEvent.

I'm trying to keep track of the state of the player. But since when the video end I can't call any is_playing() nor playback_status() because I got an OMXPlayerDeadError.

So basically what I want is to use those callback to keep the state of the player so I don't stop the player when it's already dead for instance...

I'm using the load() function to play video instead of creating a new play(). Seems more convenient to me. So I guess it would be nice to fire an event with the load() function (could be a playEvent or a loadEvent) or maybe this behavior is by design and I'm missing the point of the load() function.

Still I can't find out why my playEvent is triggered twice...

Problem reproduction

Code


def player_stop(player):
    logger.debug("stop callback")

def player_play(player):
    logger.debug("play callback")

def player_exit(player, exit_status):
    logger.debug("exit callback")

logger.debug("Playing intro")
omxplayer = OMXPlayer(SUCCESS, dbus_name='org.mpris.MediaPlayer1.omxplayer1', args=['--no-osd', '--no-keys', '--adev', 'local', '--display', '2', '--layer', '1'], pause=True)
omxplayer.stopEvent += player_stop
omxplayer.playEvent += player_play
omxplayer.exitEvent += player_exit
omxplayer.play()
time.sleep(omxplayer.duration())
omxplayer.load(DIRECTORY_1[PLAYER_CURRENT_INDEX_1])
logger.debug("Intro finished")

Output

2020-11-05 19:39:24,724 - pi - DEBUG - Playing intro
2020-11-05 19:39:25,626 - pi - DEBUG - play callback
2020-11-05 19:39:25,627 - pi - DEBUG - play callback
2020-11-05 19:39:31,545 - pi - DEBUG - exit callback
2020-11-05 19:39:32,087 - pi - DEBUG - Intro finished

Environment details

No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
Software Version
python-omxplayer-wrapper 0.1.0
python (python --version) 3.7.3
omxplayer (omxplayer --version) f543a0d