| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
from fenrirscreenreader.core import debug |
| 8 |
|
| 9 |
|
| 10 |
class sound_driver: |
| 11 |
def __init__(self): |
| 12 |
self.volume = None |
| 13 |
self._initialized = False |
| 14 |
|
| 15 |
def initialize(self, environment): |
| 16 |
self.env = environment |
| 17 |
self._initialized = True |
| 18 |
|
| 19 |
def shutdown(self): |
| 20 |
if not self._initialized: |
| 21 |
return |
| 22 |
self.cancel() |
| 23 |
self._initialized = False |
| 24 |
|
| 25 |
def play_frequence( |
| 26 |
self, frequence, duration, adjust_volume=0.0, interrupt=True |
| 27 |
): |
| 28 |
if not self._initialized: |
| 29 |
return |
| 30 |
if interrupt: |
| 31 |
self.cancel() |
| 32 |
|
| 33 |
def play_sound_file(self, file_path, interrupt=True): |
| 34 |
if not self._initialized: |
| 35 |
return |
| 36 |
if interrupt: |
| 37 |
self.cancel() |
| 38 |
|
| 39 |
def cancel(self): |
| 40 |
if not self._initialized: |
| 41 |
return |
| 42 |
|
| 43 |
def set_callback(self, callback): |
| 44 |
if not self._initialized: |
| 45 |
return |
| 46 |
|
| 47 |
def set_volume(self, volume): |
| 48 |
if not self._initialized: |
| 49 |
return |
| 50 |
self.volume = volume |