当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.get方法代码示例

本文整理汇总了Python中playlist.Playlist.get方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.get方法的具体用法?Python Playlist.get怎么用?Python Playlist.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playlist.Playlist的用法示例。


在下文中一共展示了Playlist.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_active_playlist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def fetch_active_playlist(self):
     try:
         playlist = Playlist.get(self.active_playlist_id)
         return playlist
     except:
         # The play list have been removed or disapperd use tmpqueue as fallback
         self.active_playlist_id = self.tmpqueue_id
         self.active_playlists_track_id = 0
         playlist = Playlist.get(self.active_playlist_id)
         return playlist
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:12,代码来源:amp.py

示例2: API_removeTrackFromPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_removeTrackFromPlaylist(self, playlist_id, track_id):
     try:
         playlist = Playlist.get(playlist_id)
         playlist.remove_track_id(int(track_id))
     except ValueError as e:
         raise
     self.needs_push_update = True
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:9,代码来源:dogvibes.py

示例3: API_addTrackToPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_addTrackToPlaylist(self, playlist_id, uri):
     track = self.create_track_from_uri(uri)
     try:
         playlist = Playlist.get(playlist_id)
     except ValueError as e:
         raise
     return playlist.add_track(track)
     self.needs_push_update = True
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:10,代码来源:dogvibes.py

示例4: API_addTracksToPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_addTracksToPlaylist(self, playlist_id, uri, request):
     tracks = self.create_tracks_from_uri(uri)
     try:
         playlist = Playlist.get(playlist_id)
     except ValueError as e:
         raise
     self.needs_push_update = True
     request.finish(playlist.add_tracks(tracks, -1))
开发者ID:popdevelop,项目名称:dogvibes_old_svn_master,代码行数:10,代码来源:dogvibes.py

示例5: get_all_tracks_in_playlist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def get_all_tracks_in_playlist(self, playlist_id):
     try:
         playlist = Playlist.get(playlist_id)
     except ValueError as e:
         raise
     tracks = playlist.get_all_tracks()
     ret = [track.__dict__ for track in tracks]
     return ret
开发者ID:popdevelop,项目名称:dogvibes_old_svn_master,代码行数:10,代码来源:dogvibes.py

示例6: API_moveTrackInPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_moveTrackInPlaylist(self, playlist_id, track_id, position):
     try:
         playlist = Playlist.get(playlist_id)
         playlist.move_track(int(track_id), int(position))
     except ValueError as e:
         raise
     return 0
     self.needs_push_update = True
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:10,代码来源:dogvibes.py

示例7: API_removeTrack

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
    def API_removeTrack(self, nbr):
        nbr = int(nbr)

        # For now if we are trying to remove the existing playing track. Do nothing.
        if (nbr == self.active_playlist_id):
            logging.warning("Not allowed to remove playing track")
            return

        playlist = Playlist.get(self.tmpqueue_id)
        playlist.remove_track_id(nbr)
        self.needs_push_update = True
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:13,代码来源:amp.py

示例8: API_removeTracksFromPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_removeTracksFromPlaylist(self, playlist_id, track_ids, request):
     try:
         playlist = Playlist.get(playlist_id)
         for track_id in track_ids.split(','):
             # don't crash on railing comma
             if track_id != '':
                 playlist.remove_playlist_tracks_id(int(track_id))
     except ValueError as e:
         raise
     self.needs_push_update = True
     request.finish()
开发者ID:popdevelop,项目名称:dogvibes_old_svn_master,代码行数:13,代码来源:dogvibes.py

示例9: fetch_active_track

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
    def fetch_active_track(self):
        # Assume that fetch active playlist alreay been run
        playlist = Playlist.get(self.active_playlist_id)
        if playlist.length() <= 0:
            return None

        if self.active_playlists_track_id != -1:
            try:
                track = playlist.get_track_id(self.active_playlists_track_id)
                return track
            except:
                logging.debug("Could not get active track")
                return None
        else:
            # Try the first active_play_list id
            track = playlist.get_track_nbr(0)
            self.active_playlists_track_id = track.ptid
            return track
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:20,代码来源:amp.py

示例10: Player

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
class Player(object):
    #attr_accessor :current_track, :history, :playlist, :current_track, :backend
    attr_accessor(current_track = None)

    def __init__(self):
        from player_backends.gstreamer import Gstreamer
        self.playlist = Playlist()
        self.backend = PlayerBackend(self, Gstreamer)

    def state(self):
        return self.backend.get_state()

    @callback_method
    def schedule_next_track(self):
        self.remove_current_track()

        if self.playlist.empty():
            #print 'nope, no new track'
            self.stop()
            return False

        return self.next_track_as_current()

    @callback_method
    def next_track_as_current(self):
        self.current_track = self.playlist.get()
        #print 'New track: ' + self.current_track.name

    def remove_current_track(self):
        self.current_track = None

    @callback_method
    def play(self):
        #if still playing, return nothing
        if (self.state() == 'playing'): return False
        if (self.state() == 'paused'): return self.resume()
        if (self.playlist.empty() and not self.current_track): return None

        if not self.current_track:
            self.next_track_as_current()

        print 'play'

        result = self.backend.play(self.current_track) #Current track is set
        return result

    def pause(self):
        if self.playing():
            return self.backend.pause()
        elif self.paused():
            return self.resume()

    def resume(self):
        return self.backend.resume()

    @callback_method
    def stop(self):
        self.backend.stop()
        result = self.remove_current_track()
        return result

    def next(self):
        self.schedule_next_track()
        return self.backend.play(self.current_track) #Current track is set

    def playing(self):
        return self.state() == 'playing'

    def paused(self):
        return self.state() == 'paused'

    def stopped(self):
        return self.state() == 'stopped'

    def register_callback(self, name, callback, permanent=False, priority=0):
        return callbacks.RegisterCallback(Player, name, callback, permanent, priority)
开发者ID:LeonB,项目名称:pmpd,代码行数:78,代码来源:player.py

示例11: API_queue

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_queue(self, uri):
     track = self.dogvibes.create_track_from_uri(uri)
     playlist = Playlist.get(self.tmpqueue_id)
     playlist.add_track(track)
     self.needs_push_update = True
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:7,代码来源:amp.py

示例12: API_getAllTracksInPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_getAllTracksInPlaylist(self, playlist_id):
     try:
         playlist = Playlist.get(playlist_id)
     except ValueError as e:
         raise
     return [track.__dict__ for track in playlist.get_all_tracks()]
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:8,代码来源:dogvibes.py

示例13: change_track

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
    def change_track(self, tracknbr, relative):
        tracknbr = int(tracknbr)

        if relative and (tracknbr > 1 or tracknbr < -1):
            raise DogError, "Relative change track greater/less than 1 not implemented"

        playlist = self.fetch_active_playlist()

        track = self.fetch_active_track()
        if track == None:
            logging.warning("Could not find any active track")
            return

        # If we are in tmpqueue either removetrack or push it to the top
        if self.is_in_tmpqueue():
            if relative and (tracknbr == 1):
                # Remove track and goto next track
                playlist.remove_track_id(self.active_playlists_track_id)
                next_position = 0
            elif relative and (tracknbr == -1):
                # Do nothing since we are always on top in playqueue
                return
            else:
                # Move requested track to top of tmpqueue and play it
                self.active_playlists_track_id = tracknbr
                playlist.move_track(self.active_playlists_track_id, 1)
                next_position = 0

            # Check if tmpqueue no longer exists (all tracks has been removed)
            if playlist.length() <= 0:
                # Check if we used to be in a playlist
                if self.fallback_playlist_id != -1:
                    # Change one track forward in the playlist we used to be in
                    self.active_playlist_id = self.fallback_playlist_id
                    self.active_playlists_track_id = self.fallback_playlists_track_id
                    playlist = Playlist.get(self.active_playlist_id)
                    next_position = playlist.get_track_id(self.active_playlists_track_id).position - 1
                    next_position = next_position + 1
                    if next_position >= playlist.length():
                        # We were the last song in the playlist we used to be in, just stop everyting
                        self.set_state(gst.STATE_NULL)
                        return
                else:
                    # We have not entered any playlist yet, just stop playback
                    self.set_state(gst.STATE_NULL)
                    return
        elif (Playlist.get(self.tmpqueue_id).length() > 0) and relative:
            # Save the playlist that we curently are playing in for later use
            self.fallback_playlist_id = self.active_playlist_id
            self.fallback_playlists_track_id = self.active_playlists_track_id
            # Switch to playqueue
            self.active_playlist_id = self.tmpqueue_id
            playlist = Playlist.get(self.active_playlist_id)
            next_position = 0
        else:
            # We are inside a playlist
            if relative:
                next_position = track.position - 1 + tracknbr
            else:
                try:
                    next_position = playlist.get_track_id(tracknbr).position - 1
                except:
                    self.set_state(gst.STATE_NULL)
                    self.active_playlists_track_id = -1
                    logging.warning("Could not find this id in the active playlist")
                    self.set_state(gst.STATE_NULL)
                    return                

        try:
            track = playlist.get_track_nbr(next_position)
        except:
            self.set_state(gst.STATE_NULL)
            self.active_playlists_track_id = -1
            logging.debug("Could not get to next posiiton in the active playlist")
            return

        self.active_playlists_track_id = track.ptid
        self.set_state(gst.STATE_NULL)
        self.play_only_if_null(playlist.get_track_id(self.active_playlists_track_id))
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:81,代码来源:amp.py

示例14: __init__

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
class Player:
	def __init__(self, name, modules, config, serverHttpRequest, serverMq):
		self.name = name
		self.serverMq = serverMq;
		self.playerModules = dict();
		for moduleClass in modules:
			print "loading player module " + moduleClass["moduleName"]
			self.playerModules[moduleClass["moduleName"]] = moduleClass["class"](config, self.next)
		self.playlist = Playlist(config.get("Server", "name"), serverHttpRequest);
		self.currentPlayer = None;
		self.job = None

	def getPlayer(self, name):
		LOGGER.info("getting player " + name)
		return self.playerModules[name]

	def switchPlayer(self, name):
		next = self.getPlayer(name)
		if self.currentPlayer is None or next != self.currentPlayer:
			if self.currentPlayer is not None:
				self.currentPlayer.pause()
			self.currentPlayer = next

	def play(self, track=None):
		track = track or self.playlist.get()
		if track is not None:
			LOGGER.info("playing (name: " + str(track.name) + ", uri: " + str(track.uri) + ") on: " + track.source)
			self.switchPlayer(track.source)
			if self.currentPlayer.play(track) is False:
				self.next();
			else:
				self.serverMq.emit("player:status", {'status':'PLAYING', "playingId": track._id, "track": track.jsonFull})
				#self.setSendProgressJob()
		else:
			if self.job is not None:
				self.job.remove()
			self.serverMq.emit("player:status", {'status':"PAUSED"})
			LOGGER.info("playlist empty")


	def resume(self):
		LOGGER.info("curent track = " + str(self.currentPlayer.currentTrack));
		if self.currentPlayer.currentTrack is None:
			self.play()
		else:
			self.currentPlayer.resume()
			LOGGER.info("emit 'player:status' => 'PLAYING'")
			self.serverMq.emit("player:status", {'status':'PLAYING'})
			self.setSendProgressJob()


	def pause(self):
		self.currentPlayer.pause()
		if self.job is not None:
			self.job.remove()
		self.serverMq.emit("player:status", {'status':"PAUSED"})


	def next(self):
		next = self.playlist.next();
		if next is None:
			LOGGER.info("Nothing after")
			self.pause()
			return None
		else:
			LOGGER.info("playing next")
			self.play(next)
			return next;


	def previous(self):
		previous = self.playlist.previous();
		if previous is not None:
			self.play(previous)
		else:
			self.pause()
开发者ID:homyPi,项目名称:homyPi_raspberryApp,代码行数:78,代码来源:player.py

示例15: API_removeTrackFromPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import get [as 别名]
 def API_removeTrackFromPlaylist(self, playlist_id, track_id):
     playlist = Playlist.get(playlist_id)
     playlist.remove_track(track_id)
开发者ID:estock,项目名称:dogvibes,代码行数:5,代码来源:dogvibes.py


注:本文中的playlist.Playlist.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。