Example #1
0
    def delete(self):
        from txplaya.playlistregistry import playlistRegistry
        playlistName = url_unquote(self.playlistNameArg)
        playlistRegistry.deletePlaylist(playlistName)

        event = {'event': 'PlaylistRegistryUpdated',
                 'data': {'list': playlistRegistry.list_()}}
        self.mainController.announce(event)

        return {'msg': 'Playlist deleted'}
Example #2
0
    def __init__(self, request):
        from playlistregistry import playlistRegistry

        BaseStream.__init__(self, request)

        self.request.setHeader('Content-Type', 'text/plain')
        self.mainController.infoListenerRegistry.add(self)

        playlist = self.mainController.playlist

        # push current song
        if playlist.currentPosition is None:
            event = {'event': 'PlaybackFinished',
                     'data': {}}
            self.writeJsonLine(event)

        else:
            event = {'event': 'TrackStarted',
                     'data': {'position': playlist.currentPosition,
                              'track': playlist.currentTrack.meta}}
            self.writeJsonLine(event)
            event = {'event': 'PlaybackPaused',
                     'data': {'paused': self.mainController.player.paused}}
            self.writeJsonLine(event)

        # push playlist data
        playlistData = [track.meta
                        for track in playlist.iterTrack()]
        event = {'event': 'PlaylistChanged',
                 'data': {'playlist': playlistData,
                          'position': playlist.currentPosition,
                          'hasUndo': playlist.hasUndo,
                          'hasRedo': playlist.hasRedo}}
        self.writeJsonLine(event)

        # push list of playlists
        event = {'event': 'PlaylistRegistryUpdated',
                 'data': {'list': playlistRegistry.list_()}}
        self.writeJsonLine(event)