Skip to content

Commit

Permalink
bump OPM
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Feb 8, 2024
1 parent 5fc613d commit 6ec06ff
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- 'LICENSE'
- 'CHANGELOG.md'
- 'MANIFEST.in'
- 'readme.md'
- 'README.md'
- 'scripts/**'
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- 'LICENSE'
- 'CHANGELOG.md'
- 'MANIFEST.in'
- 'readme.md'
- 'README.md'
- 'scripts/**'
workflow_dispatch:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- 'LICENSE'
- 'CHANGELOG.md'
- 'MANIFEST.in'
- 'readme.md'
- 'README.md'
- 'scripts/**'
push:
branches:
Expand All @@ -26,7 +26,7 @@ on:
- 'LICENSE'
- 'CHANGELOG.md'
- 'MANIFEST.in'
- 'readme.md'
- 'README.md'
- 'scripts/**'
workflow_dispatch:

Expand Down
44 changes: 6 additions & 38 deletions ovos_audio_plugin_simple/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
from distutils.spawn import find_executable
from time import sleep

from ovos_plugin_common_play.ocp.base import OCPAudioPlayerBackend
from ovos_plugin_common_play.ocp.status import TrackState, MediaState, PlayerState
from ovos_plugin_manager.templates.audio import AudioBackend
from ovos_bus_client import Message
from ovos_utils.log import LOG
from requests import Session

from ovos_plugin_manager.templates.media import AudioPlayerBackend
from ovos_utils.log import LOG


def find_mime(path):
mime = None
Expand Down Expand Up @@ -46,24 +45,14 @@ def play_audio(uri, play_cmd="play"):
return None


SimpleAudioPluginConfig = {
"simple": {
"type": "ovos_simple",
"active": True
}
}


class OVOSSimpleService(OCPAudioPlayerBackend):
class CLIOCPAudioService(AudioPlayerBackend):
sox_play = find_executable("play")
pulse_play = find_executable("paplay")
alsa_play = find_executable("aplay")
mpg123_play = find_executable("mpg123")

def __init__(self, config, bus=None, name='ovos_simple'):
super(OVOSSimpleService, self).__init__(config, bus)
self.name = name

def __init__(self, config, bus=None):
super().__init__(config, bus)
self.process = None
self._stop_signal = False
self._is_playing = False
Expand Down Expand Up @@ -187,7 +176,6 @@ def supported_uris(self):

def play(self, repeat=False):
""" Play playlist using simple. """
self.ocp_start()
self.bus.emit(Message('ovos.common_play.simple.play',
{'repeat': repeat}))

Expand All @@ -199,7 +187,6 @@ def stop(self):
while self._is_playing:
sleep(0.1)
self._stop_signal = False
self.ocp_stop()
return True
return False

Expand All @@ -209,33 +196,14 @@ def pause(self):
# Suspend the playback process
self.process.send_signal(signal.SIGSTOP)
self._paused = True
self.ocp_pause()

def resume(self):
""" Resume paused playback. """
if self.process and self._paused:
# Resume the playback process
self.process.send_signal(signal.SIGCONT)
self._paused = False
self.ocp_resume()

def track_info(self):
""" Extract info of current track. """
return {"track": self._now_playing}


def load_service(base_config, bus):
backends = base_config.get('backends', [])
services = [(b, backends[b]) for b in backends
if backends[b]['type'] in ["simple", 'ovos_simple'] and
backends[b].get('active', False)]

if not any([OVOSSimpleService.sox_play,
OVOSSimpleService.pulse_play,
OVOSSimpleService.alsa_play,
OVOSSimpleService.mpg123_play]):
LOG.error("No basic playback functionality detected!!")
return []

instances = [OVOSSimpleService(s[1], bus, s[0]) for s in services]
return instances
3 changes: 1 addition & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ovos-plugin-manager
ovos_plugin_common_play
ovos-plugin-manager>=0.0.26a5
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ def required(requirements_file):
entry_points={'mycroft.plugin.audioservice': PLUGIN_ENTRY_POINT,
'mycroft.plugin.audioservice.config': PLUGIN_CONFIG_ENTRY_POINT}
)

PLUGIN_ENTRY_POINT = 'ovos-media-audio-plugin-cli=ovos_audio_plugin_simple.CLIOCPAudioService'

setup(
name='ovos-media-plugin-cli',
version=get_version(),
description='mplayer plugin for ovos',
url='https://github.com/OpenVoiceOS/ovos-media-plugin-cli',
author='JarbasAi',
author_email='[email protected]',
license='Apache-2.0',
packages=['ovos_audio_plugin_simple'],
install_requires=required("requirements/requirements.txt"),
package_data={'': package_files('ovos_audio_plugin_simple')},
keywords='ovos audio video OCP plugin',
entry_points={'opm.media.audio': PLUGIN_ENTRY_POINT}
)

0 comments on commit 6ec06ff

Please sign in to comment.