-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio recording for macOS #428
Conversation
plyer/platforms/macosx/audio.py
Outdated
|
||
class OSXAudio(Audio): | ||
def __init__(self, file_path=None): | ||
default_path = join(expanduser('~'), 'Desktop', 'audio.wav') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not pass a default value that point on nothing :) Should be None by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried without passing a value of None
, but I started getting the following error:
`>>> from plyer import audio
audio.start()
Traceback (most recent call last):
File "/Users/maroskovac/Dev/plyer/plyer/utils.py", line 96, in _ensure_obj
obj = mod.instance()
File "/Users/maroskovac/Dev/plyer/plyer/platforms/macosx/audio.py", line 82, in instance
return OSXAudio()
TypeError: init() takes exactly 2 arguments (1 given)
Traceback (most recent call last):
File "", line 1, in
File "/Users/maroskovac/Dev/plyer/plyer/facades/audio.py", line 65, in start
self._start()
File "/Users/maroskovac/Dev/plyer/plyer/facades/audio.py", line 98, in _start
raise NotImplementedError()
NotImplementedError`
plyer/platforms/macosx/audio.py
Outdated
# of the last recorded audio file | ||
self._player = AVAudioPlayer.alloc() | ||
self._player = self._player.initWithContentsOfURL_error_( | ||
self._current_file, None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to catch the error and raise an exception if something failed, rather than completely ignore.
@tito here's a quick summary of my commits addressing your changes request:
|
Thanks you! |
Added audio recording and playback for macOS using Apple's Objective-C API via pyobjus.
Audio files are recorded with 44.1 kHz sample rate in WAV format.
Closes issue #282.