Audio Services dept. first commands - add url, play. good enough for internet radio basics.
parent
73be0eecf9
commit
c0433e715a
@ -0,0 +1,4 @@
|
|||||||
|
from . import audio
|
||||||
|
|
||||||
|
def main():
|
||||||
|
audio.main()
|
@ -0,0 +1,51 @@
|
|||||||
|
import mplayer
|
||||||
|
|
||||||
|
from bureau import Bureau, add_command
|
||||||
|
|
||||||
|
|
||||||
|
class Audio(Bureau):
|
||||||
|
"""
|
||||||
|
The Audio Services department provides for playback and recording
|
||||||
|
of sound within the office environment.
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = "Audio Services Dept."
|
||||||
|
prefix = "AU"
|
||||||
|
version = 0
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
Bureau.__init__(self)
|
||||||
|
|
||||||
|
self.player = mplayer.Player()
|
||||||
|
self.urldb = self.open_db("urldb")
|
||||||
|
|
||||||
|
@add_command("p", "Play an album, track or a live stream.")
|
||||||
|
def play(self, data):
|
||||||
|
"""
|
||||||
|
Initiates playback of a media reference. This could be a song or album
|
||||||
|
stored on the local office or remote URLs for live playback. Currently,
|
||||||
|
only supports line-out signals on the default DAC.
|
||||||
|
"""
|
||||||
|
shortcode, _ = data.split(".")
|
||||||
|
url = self.urldb.get(shortcode)
|
||||||
|
|
||||||
|
if not self.player.is_alive():
|
||||||
|
self.player.spawn()
|
||||||
|
|
||||||
|
self.player.loadfile(url)
|
||||||
|
|
||||||
|
def save_url(self, url):
|
||||||
|
"""
|
||||||
|
saves an url for a local file or network audio stream.
|
||||||
|
"""
|
||||||
|
code = self.urldb.store_and_get_shortcode(url)
|
||||||
|
print("saved url with shortcode: ", code)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
au = Audio()
|
||||||
|
au.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue