platypush/platypush/plugins/sound/_streams/_player/_resource.py
Fabio Manganiello f960ec4bf4 [sound] Plugin refactor.
- Added `input_format`/`output_format` options to both input and output
  audio streams.

- Replaced the previous (confusing) occurrences of `ffmpeg_format` and
  `format`.

- Added custom `dtype` option for `sound.play`.

- Added `join` flag (default: false) to `sound.play` to wait for the
  playback to finish.
2023-10-31 00:44:05 +00:00

35 lines
938 B
Python

from typing import Optional, Type
from platypush.message.event.sound import SoundEvent
from ..._converters import RawOutputAudioFromFileConverter
from ._base import AudioPlayer
class AudioResourcePlayer(AudioPlayer):
"""
A ``AudioResourcePlayer`` thread is responsible for playing an audio
resource - either a file or a URL.
"""
@property
def _audio_converter_type(self) -> Type[RawOutputAudioFromFileConverter]:
return RawOutputAudioFromFileConverter
@property
def _converter_args(self) -> dict:
return {
'infile': self.infile,
'output_format': self.output_format,
**super()._converter_args,
}
@property
def _converter_stdin(self) -> Optional[int]:
return None
def _notify(self, event_type: Type[SoundEvent], **kwargs):
return super()._notify(event_type, resource=self.infile, **kwargs)
# vim:sw=4:ts=4:et: