def add(uri): dev = devices.currentDevice() if uri.startswith('http://'): uri = uri.replace('http://', 'x-rincon-mp3radio://') if uri.find('#') >= 0: uri = uri[:uri.find('#')] dev.add_uri_to_queue(uri)
def add(uri): dev = devices.currentDevice() if uri.startswith('http://'): uri = uri.replace('http://', 'x-rincon-mp3radio://') if uri.find('#') >= 0: uri = uri[:uri.find('#')] dev.add_uri_to_queue(uri)
def stats(): dev = devices.currentDevice() result = "" result += "artists: %d\n" % len( dev.music_library.get_artists(max_items=9999)) result += "albums: %d\n" % len( dev.music_library.get_albums(max_items=9999)) result += "songs: %d\n" % len(dev.music_library.get_tracks(max_items=9999)) result += "uptime: -1\n" result += "playtime: 100\n" result += "db_playtime: -1\n" result += "db_update: -1\n" return result
def currentSong(): dev = devices.currentDevice() current_song = dev.get_current_track_info() result = "" result = result + "file: " + current_song.get('uri') + '\n' result = result + "Id: " + str( int(current_song.get('playlist_position')) - 1) + '\n' result = result + "Position: " + str( int(current_song.get('playlist_position')) - 1) + '\n' result = result + "Artist: " + current_song.get('artist') + '\n' result = result + "Album: " + current_song.get('album') + '\n' result = result + "Title: " + current_song.get('title') + '\n' result = result + "Name: " + current_song.get('title') + '\n' return result
def status(): dev = devices.currentDevice() result = '' state = devices.event_state.transport_state if state == 'PAUSED_PLAYBACK': result += 'state: pause\n' elif state == 'STOPPED': result += 'state: stop\n' elif state == 'PLAYING': result += 'state: play\n' result += 'volume: ' + str(devices.event_state.volume) + '\n' track = dev.get_current_track_info() result += "song: " + str(int(track.get('playlist_position')) - 1) + "\n" result += "songid: " + str(int(track.get('playlist_position')) - 1) + "\n" ( hours, mins, seconds, ) = track.get('position').split(':') position_seconds = int(mins) * 60 + int(seconds) ( hours, mins, seconds, ) = track.get('duration').split(':') duration_seconds = int(mins) * 60 + int(seconds) result += 'time: ' + str(position_seconds) + ':' + str( duration_seconds) + '\n' result += 'elapsed: ' + str(position_seconds) + '.000\n' result += "bitrate: 128\n" result += "xfade: 0\n" result += "playlistlength: " + str(len( playlist_store.getCurrentPlaylist())) + "\n" result += "playlist: " + str(playlist_store.version) + "\n" return result
def getCurrentPlaylist(self): dev = devices.currentDevice() if self.playlist and self.version == devices.event_state.playlist_version: return self.playlist else: self.playlist = [] for i, element in enumerate(dev.get_queue(max_items=9999)): song = { 'file': element.title, 'id': i, 'title': element.title, 'album': hasattr(element, 'album') and element.album or '', 'artist': hasattr(element, 'creator') and element.creator or '' } self.playlist.append(song) self.version = devices.event_state.playlist_version return self.playlist
def getCurrentPlaylist(self): dev = devices.currentDevice() if self.playlist and self.version == devices.event_state.playlist_version: return self.playlist else: self.playlist = [] for i, element in enumerate(dev.get_queue(max_items=9999)): song = { 'file': element.title, 'id': i, 'title': element.title, 'album': hasattr(element, 'album') and element.album or '', 'artist': hasattr(element, 'creator') and element.creator or '' } self.playlist.append(song) self.version = devices.event_state.playlist_version return self.playlist
def deleteId(id): dev = devices.currentDevice() pos = int(id) dev.remove_from_queue(pos)
def clear(): dev = devices.currentDevice() dev.clear_queue()
def deleteId(id): dev = devices.currentDevice() pos = int(id) dev.remove_from_queue(pos)
def clear(): dev = devices.currentDevice() dev.clear_queue()