platypush/plugins/media/omxplayer/__init__.py
def status(self):
        """
        Get the current player state.

        :returns: A dictionary containing the current state.

        Format::

            output = {
                "duration": Duration in seconds,
                "filename": Media filename,
                "fullscreen": true or false,
                "mute": true or false,
                "path": Media path
                "pause": true or false,
                "position": Position in seconds
                "seekable": true or false
                "state": play, pause or stop
                "title": Media title
                "url": Media url
                "volume": Volume between 0 and 100
                "volume_max": 100,
            }
        """

        from omxplayer.player import OMXPlayerDeadError
        from dbus import DBusException

        if not self._player:
            return {
                'state': PlayerState.STOP.value
            }

        try:
            state = self._player.playback_status().lower()
        except (OMXPlayerDeadError, DBusException) as e:
            self.logger.warning(f'Could not retrieve player status: {e}')
            if isinstance(e, OMXPlayerDeadError):
                self._player = None

            return {
                'state': PlayerState.STOP.value
            }

        if state == 'playing':
            state = PlayerState.PLAY.value
        elif state == 'stopped':
            state = PlayerState.STOP.value
        elif state == 'paused':
            state = PlayerState.PAUSE.value

        return {
            'duration': self._player.duration(),
            'filename': urllib.parse.unquote(self._player.get_source()).split('/')[-1] if self._player.get_source().startswith('file://') else None,
            'fullscreen': self._player.fullscreen(),
            'mute': self._player._is_muted,
            'path': self._player.get_source(),
            'pause': state == PlayerState.PAUSE.value,
            'position': max(0, self._player.position()),
            'seekable': self._player.can_seek(),
            'state': state,
            'title': urllib.parse.unquote(self._player.get_source()).split('/')[-1] if self._player.get_source().startswith('file://') else None,
            'url': self._player.get_source(),
            'volume': self.get_volume(),
            'volume_max': 100,
        }

        Get the current player state.

        :returns: A dictionary containing the current state.

        Format::

            output = {
                "duration": Duration in seconds,
                "filename": Media filename,
                "fullscreen": true or false,
                "mute": true or false,
                "path": Media path
                "pause": true or false,
                "position": Position in seconds
                "seekable": true or false
                "state": play, pause or stop
                "title": Media title
                "url": Media url
                "volume": Volume between 0 and 100
                "volume_max": 100,
            }
        
Get the current player state.
Get the current player state .
def status(self):
        from omxplayer.player import OMXPlayerDeadError
        from dbus import DBusException
        if not self._player:
            return {
                'state': PlayerState.STOP.value
            }
        try:
            state = self._player.playback_status().lower()
        except (OMXPlayerDeadError, DBusException) as e:
            self.logger.warning(f'Could not retrieve player status: {e}')
            if isinstance(e, OMXPlayerDeadError):
                self._player = None
            return {
                'state': PlayerState.STOP.value
            }
        if state == 'playing':
            state = PlayerState.PLAY.value
        elif state == 'stopped':
            state = PlayerState.STOP.value
        elif state == 'paused':
            state = PlayerState.PAUSE.value
        return {
            'duration': self._player.duration(),
            'filename': urllib.parse.unquote(self._player.get_source()).split('/')[-1] if self._player.get_source().startswith('file://') else None,
            'fullscreen': self._player.fullscreen(),
            'mute': self._player._is_muted,
            'path': self._player.get_source(),
            'pause': state == PlayerState.PAUSE.value,
            'position': max(0, self._player.position()),
            'seekable': self._player.can_seek(),
            'state': state,
            'title': urllib.parse.unquote(self._player.get_source()).split('/')[-1] if self._player.get_source().startswith('file://') else None,
            'url': self._player.get_source(),
            'volume': self.get_volume(),
            'volume_max': 100,
        }
def status ( self ) : from omxplayer . player import OMXPlayerDeadError from dbus import DBusException if not self . _player : return { 'state' : PlayerState . STOP . value } try : state = self . _player . playback_status ( ) . lower ( ) except ( OMXPlayerDeadError , DBusException ) as e : self . logger . warning ( f'Could not retrieve player status: {e}' ) if isinstance ( e , OMXPlayerDeadError ) : self . _player = None return { 'state' : PlayerState . STOP . value } if state == 'playing' : state = PlayerState . PLAY . value elif state == 'stopped' : state = PlayerState . STOP . value elif state == 'paused' : state = PlayerState . PAUSE . value return { 'duration' : self . _player . duration ( ) , 'filename' : urllib . parse . unquote ( self . _player . get_source ( ) ) . split ( '/' ) [ - 1 ] if self . _player . get_source ( ) . startswith ( 'file://' ) else None , 'fullscreen' : self . _player . fullscreen ( ) , 'mute' : self . _player . _is_muted , 'path' : self . _player . get_source ( ) , 'pause' : state == PlayerState . PAUSE . value , 'position' : max ( 0 , self . _player . position ( ) ) , 'seekable' : self . _player . can_seek ( ) , 'state' : state , 'title' : urllib . parse . unquote ( self . _player . get_source ( ) ) . split ( '/' ) [ - 1 ] if self . _player . get_source ( ) . startswith ( 'file://' ) else None , 'url' : self . _player . get_source ( ) , 'volume' : self . get_volume ( ) , 'volume_max' : 100 , }
Get the current player state.
Get the current player state .
"""
        Get the current player state.

        :returns: A dictionary containing the current state.

        Format::

            output = {
                "duration": Duration in seconds,
                "filename": Media filename,
                "fullscreen": true or false,
                "mute": true or false,
                "path": Media path
                "pause": true or false,
                "position": Position in seconds
                "seekable": true or false
                "state": play, pause or stop
                "title": Media title
                "url": Media url
                "volume": Volume between 0 and 100
                "volume_max": 100,
            }
        """
A dictionary containing the current state.
Format:.

output = {
"duration": Duration in seconds,
"filename": Media filename,
"fullscreen": true or false,
"mute": true or false,
"path": Media path
"pause": true or false,
"position": Position in seconds
"seekable": true or false
"state": play, pause or stop
"title": Media title
"url": Media url
"volume": Volume between 0 and 100
"volume_max": 100,
}
A dictionary containing the current state . Format : . output = { " duration " : Duration in seconds " filename " : Media filename " fullscreen " : true or false " mute " : true or false " path " : Media path " pause " : true or false " position " : Position in seconds " seekable " : true or false " state " : play pause or stop " title " : Media title " url " : Media url " volume " : Volume between 0 and 100 " volume_max " : 100 }
self