rewrite audio playback to use vlc instead of moc

workspace
Brendan Howell 5 years ago
parent b1b42d921b
commit ae47f81638

@ -1,4 +1,4 @@
import subprocess
import vlc
from bureau import Bureau, add_command
@ -17,7 +17,7 @@ class Audio(Bureau):
Bureau.__init__(self)
self.urldb = self.open_db("urldb")
subprocess.call(["mocp", "-S"])
self.player = vlc.MediaPlayer()
@add_command("p", "Play an album, track or a live stream.")
def play(self, data):
@ -31,44 +31,52 @@ class Audio(Bureau):
url = self.urldb.get(shortcode)
self.log.debug(" playing url " + url)
subprocess.call(["mocp", "-c"])
subprocess.call(["mocp", "-a", url])
subprocess.call(["mocp", "-p"])
self.player.set_mrl(url)
self.player.play()
@add_command("stop", "Halt audio playback.")
def stop(self):
"""
Stops all audio currently playing audio output.
"""
subprocess.call(["mocp", "-P"])
self.player.pause()
@add_command("resu", "Resume playback.")
def resume(self):
"""
Resume playback of paused audio.
"""
subprocess.call(["mocp", "-U"])
self.player.play()
@add_command("next", "Play the next song.")
def play_next(self):
"""
Skip to the next song in the playlist or album.
"""
subprocess.call(["mocp", "-f"])
#subprocess.call(["mocp", "-f"])
# TODO
pass
@add_command("prev", "Play the previous song.")
def play_prev(self):
"""
Skip to the previous song in the playlist or album.
"""
subprocess.call(["mocp", "-r"])
#subprocess.call(["mocp", "-r"])
# TODO
pass
@add_command("nowp", "Now Playing")
def now_playing(self):
"""
Prints the currently playing song or stream on the small printer.
"""
out = subprocess.check_output(["mocp", "-i"]).decode("utf-8")
#out = subprocess.check_output(["mocp", "-i"]).decode("utf-8")
# TODO: sort out how to do this with
out = "Now Playing: "
out += self.player.get_media().get_meta(0) + "\n"
out += "by " + self.player.get_media().get_meta(1) + "\n"
self.log.debug("info output:" + out)
self.print_small(out)

Loading…
Cancel
Save