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