switch from vlc to gstreamer-player for audio department

workspace
Brendan Howell 3 years ago
parent a969ced360
commit c359aa5961

@ -1,6 +1,7 @@
import kode256
import requests
import vlc
from gsp import GstreamerPlayer
from bureau import Bureau, add_command, add_webview
@ -19,7 +20,8 @@ class Audio(Bureau):
Bureau.__init__(self)
self.urldb = self.open_db("urldb")
self.player = vlc.MediaListPlayer()
self.player = GstreamerPlayer(None)
self.current_uri = None
@add_command("p", "Play an album, track or a live stream.")
def play(self, data):
@ -33,24 +35,23 @@ class Audio(Bureau):
url = self.urldb.get(shortcode)
self.log.debug(" playing url " + url)
playlist = vlc.MediaList()
playlist.add_media(url)
self.player.set_media_list(playlist)
self.player.play()
self.player.queue(url)
self.current_uri = url
@add_command("stop", "Halt audio playback.")
def stop(self):
"""
Stops all audio currently playing audio output.
"""
self.player.pause()
self.player.stop()
@add_command("resu", "Resume playback.")
def resume(self):
"""
Resume playback of paused audio.
"""
self.player.play()
if self.current_uri:
self.player.queue(self.current_uri)
@add_command("next", "Play the next song.")
def play_next(self):
@ -77,14 +78,15 @@ class Audio(Bureau):
"""
media = self.player.get_media_player().get_media()
out = "Now Playing: "
out += media.get_meta(vlc.Meta.Title) + "\n"
nowplaying = media.get_meta(vlc.Meta.NowPlaying)
if nowplaying == "":
out += "by " + media.get_meta(vlc.Meta.Artist) + "\n"
out += "from the album '" + media.get_meta(vlc.Meta.Album) \
out += self.player.title + "\n"
if self.player.artist != "":
out += "by " + self.player.artist + "\n"
if self.player.album != "":
out += "from the album '" + self.player.album \
+ "'\n"
else:
out += nowplaying + "\n"
# TODO: add fields for "organization" and "location" for gstreamer-player
# so we can get the station ID stuff
self.log.debug("info output:" + out)
self.print_small(out)

Loading…
Cancel
Save