當前位置: 首頁>>代碼示例>>Python>>正文


Python Playlist.Playlist類代碼示例

本文整理匯總了Python中Playlist.Playlist的典型用法代碼示例。如果您正苦於以下問題:Python Playlist類的具體用法?Python Playlist怎麽用?Python Playlist使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Playlist類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

class AmarokEventHandler:

    def __init__(self, state):
        self.__running = True;
        self.__playlist = Playlist()
        self.__state = state
        dcop = Dcop.init()
        dcop.player.enableRandomMode("false")

    def start(self):
        while self.__running:
            delay = 1
            fd = sys.stdin.fileno()
            (r,w,e) = select.select( [fd], [], [], delay)
            for File in r:
                if File == fd:
                    line = os.read(fd, 1024)
                    self.__dispatch(line)

    def stop(self):
        self.__running = False

    def __dispatch(self, s):
        Debug.log("Event received: " + s)
        if s.find("engineStateChange: empty" ) >= 0:
            Debug.log("Playlist is empty!")
            if self.__state.isRunning():
                Debug.log("Queuing random song")
                self.__playlist.playRandom()
            else:
                Debug.log("Not running")
        elif s.find("trackChange" ) >= 0:
            if not self.__playlist.isPlaying():
                Debug.log("Queuing random song")
                self.__playlist.playRandom()
開發者ID:BackupTheBerlios,項目名稱:amarok-jukebox-svn,代碼行數:35,代碼來源:AmarokEventHandler.py

示例2: run

def run():
	'''
	Starts the app
	'''
	global CONF, PL

	if len(argv) > 1:
		if argv[1] == '-h' or argv[1] == '--help':
			showHelp()
		elif argv[1] == '-v' or argv[1] == '--version':
			printexit(VERSION)
		else:
			showHelp()


	if os.path.isfile('config.json'):
		readConfig()
		if os.path.isfile('playlist.json'):
			PL = Playlist('playlist.json')
		else:
			PL = Playlist(CONF['url'])
	else:
		url = getin('You are creating a new project. Give URL of the playlist')
		PL = Playlist(url)
		CONF = {
			'output_format': '',
			'start': 1,
			'end': len(PL.res),
			'download': {
				'resolution': 720,
				'video_format': '',
				'bitrate': 0,
				'audio_format': '',
				'more_options': '-o "%(title)s.%(ext)s"'
			},
			'url': url
		}
		saveConfig()
		print()
		confirm = input('Config saved as config.json. Edit it if you please. Then press ENTER ')
		readConfig()

	# CONFIG read/create done. Now downloading

	while CONF['start'] <= CONF['end']:
		retcode = PL.download( CONF['start'],
			**{
				'res': CONF['download']['resolution'],
				'bitrate': CONF['download']['bitrate'], 
				'vext': CONF['download']['video_format'],
				'aext': CONF['download']['audio_format'], 
				'oext': CONF['output_format'],
				'more': CONF['download']['more_options']
			}
		)
		if retcode != 0: # if failed, try again
			continue
		CONF['start']+=1
		saveConfig()
開發者ID:aviaryan,項目名稱:playlist-dl,代碼行數:59,代碼來源:playlist_dl.py

示例3: generate_playlist

 def generate_playlist(self):
     returnPl = Playlist()
     for file in os.listdir(self._dirpath):
         if file.endswith(".mp3"):
             song = MP3(file, ID3=EasyID3)
             #print(song["title"][0].decode("utf-8"))
             returnPl.add_song(Song(song["title"][0], song["artist"][0], song["album"][0], str(datetime.timedelta(seconds=int(song.info.length)))))
     return returnPl
開發者ID:gbalabanov,項目名稱:Hack_BG_101,代碼行數:8,代碼來源:MusicCrawler.py

示例4: add

	def add(self, ref, extra=None, isBatch=False):
		data = extra
		if extra is None or extra.get(eMediaDatabase.FIELD_FILE_ID, 0) <= 0:
			data = self.getDetailsByRef(ref) or data
		if data is None:
			path, filename = os_path.split(ref.getPath())
			data = { "file_uri" : ref.getPath(), "title" : filename, }
		Playlist.add(self, ref, data, isBatch)
開發者ID:OpenDMM,項目名稱:enigma2,代碼行數:8,代碼來源:DatabasePlaylist.py

示例5: generate_playlist

 def generate_playlist(self, name):
     output_playlist = Playlist(name)
     files = self._get_mp3_files(self.__crawlDir)
     for filename in files:
         filename = self.__crawlDir + filename
         audio_obj = MP3(filename)
         song = self._create_song(audio_obj)
         output_playlist.add_song(song)
     return output_playlist
開發者ID:VasilVasilev93,項目名稱:HackBulgaria,代碼行數:9,代碼來源:MusicCrawler.py

示例6: __dispatch

 def __dispatch(self, s):
     if s.find("engineStateChange: empty" ) >= 0:
         if self.__state.isRunning():
             sys.stderr.write("Unknown notification: " + s + " -> ignoring\n")
             self.__player.playRandom()
     elif s.find("trackChange" ) >= 0:
         pl = Playlist()
         if not pl.isPlaying():
             self.__player.playRandom()                
     else:
         sys.stderr.write("Unknown notification: " + s + " -> ignoring\n")
開發者ID:BackupTheBerlios,項目名稱:amarok-jukebox-svn,代碼行數:11,代碼來源:AmarokEventHandler.py

示例7: main

def main():
    stdin = os.popen("kdialog --getsaveurl %s"%(user.home))
    dest = stdin.readline().strip()[5:]
    plist = Playlist()
    print dest
    try:
        f = open(dest, "w")
        f.write(plist.toHtml())
        f.close()
        os.system("kdialog --msgbox 'Pana-playlist saved to %s'"%(dest))
    except IOError:
        os.system('kdialog --error "Sorry, could not save the playlist to %s"'%(dest))
開發者ID:delight,項目名稱:Pana,代碼行數:12,代碼來源:playlist2html.py

示例8: __init__

    def __init__(self, parent):

        super(SystemTray, self).__init__(parent)
        self.sc = QtGui.QFileDialog()
        self.nowPlayingLabel = parent.nowPlayingLabel
        self.programLabel = parent.programLabel
        self.logoLabel = parent.logoLabel
        self.coverWebView = parent.coverWebView
        self.programWebView = parent.programWebView

        self.tray_menu = parent.tray_menu
        self.tray_icon = parent.tray_icon
        self.hide_ui = parent.hide_ui
        self.show_ui = parent.show_ui
        self.central_widget = parent.central_widget
        self.timer_show = parent.timer_show

        self.setup_menu()

        self.playlist = Playlist(self)

        self.instance = vlc.Instance()  # create a vlc instance
        self.player = self.instance.media_player_new()  # create a empty vlc media player
        stream = "http://shoutcast.rtl.it:3010/stream/1/"
        option = "--extraintf=http"  # enable web interface
        self.media = self.instance.media_new(stream, option)  # create the media
        self.player.set_media(self.media)

        self.info_0 = None  # this variable always before set_meta_data call is None
        self.timer_check = QtCore.QTimer()
        self.connect(self.timer_check, QtCore.SIGNAL("timeout()"), self.set_meta_data)  # polling every second

        self.my_dict = {}
開發者ID:19po,項目名稱:rtl102.5-playlist,代碼行數:33,代碼來源:SystemTray.py

示例9: TestPlayList

class TestPlayList(unittest.TestCase):

    def setUp(self):
        self.song1 = Song("a", "b", "ab", "2:00")
        self.song2 = Song("aa", "b", "ab", "3:00")
        self.song3 = Song("aa", "bb", "aabb", "2:00")
        self.pl = Playlist("Mine")

    def test_equal_song(self):
        self.assertNotEqual(self.song1, self.song2)

    def test_add_song(self):
        self.pl.add_song(self.song1)
        self.assertEqual(len(self.pl.songs), 1)
        #self.assertEqual(self.pl.add_song(self.song2), "Fail !")
        self.assertEqual(self.song1._length,self.song3._length)
開發者ID:gbalabanov,項目名稱:Hack_BG_101,代碼行數:16,代碼來源:test_playlist.py

示例10: setUp

 def setUp(self):
     self.testplaylist = Playlist("Test Playlist")
     self.song = Song("Title", "Artist", "Album", 5, 20, 120)
     self.song1 = Song("Title1", "Artist", "Album1", 1, 20, 50)
     self.song2 = Song("Title2", "Artist1", "Album1", 1, 20, 100)
     self.testplaylist.add_song(self.song)
     self.testplaylist.add_song(self.song1)
     self.testplaylist.add_song(self.song2)
開發者ID:VasilVasilev93,項目名稱:HackBulgaria,代碼行數:8,代碼來源:Playlist_test.py

示例11: process

def process(file):

    pls_file = file

    m3u_file = re.sub(r".pls$", ".m3u", pls_file)

    in_playlist = Playlist(pls_file)

    pls_entries = in_playlist.get_entries()

    output = ["#EXTM3U\n"]
    for entry in pls_entries:
        output.append("#EXTINF:%s, %s\n%s\n" % (entry[3], entry[2], entry[1]))

    print "Converting %s to %s" % (pls_file, m3u_file)
    handle = open(m3u_file, "w")
    handle.writelines(output)
    handle.close
開發者ID:Hugin0,項目名稱:PLS2M3U,代碼行數:18,代碼來源:pls2m3u.py

示例12: __init__

 def __init__(self):
     self.Playlist = Playlist()
     self.name = ""
     self.playlistPosition = 0
     self.showTimeOffset = 0
     self.lastAccessTime = 0
     self.totalTimePlayed = 0
     self.fileName = ""
     self.isPaused = False
     self.isValid = False
     self.mode = 0
開發者ID:kyotocafe,項目名稱:XBMC-PseudoTV,代碼行數:11,代碼來源:Channel.py

示例13: serve

def serve(request):

    c = Collection()
    p = Playlist()
    player = Player()

    doc = CGI.httpHeaders()
    doc += CGI.htmlHead({"style": ["../playlist.css"]})

    if request.command == "POST":
        form = request.form
        if form.has_key("addSongs"):
            for e in makeList(form.getvalue("song")):
                if e is not None:
                    doc += addSong(p, c, e)
        elif form.has_key("addAlbums"):
            for e in makeList(form.getvalue("album")):
                if e is not None:
                    doc += addAlbum(p, c, e)
        elif form.has_key("clear"):
            p.clear()
        elif form.has_key("clearAndStop"):
            p.clear()
            request.state.stop()
            player.stop()

    f = p.update()
    doc += playlistToHtml(f, p)
    doc += CGI.htmlTail()

    request.serve_string(doc)
開發者ID:BackupTheBerlios,項目名稱:amarok-jukebox-svn,代碼行數:31,代碼來源:Playlist.py

示例14: serve

def serve(request):

    p = Playlist()
    player = Player()

    doc = CGI.httpHeaders()
    doc += CGI.htmlHead({ 'style':['../playlist.css'] })

    if request.command == "POST":
        form = request.form
        if form.has_key('addSongs'):
            for e in makeList(form.getvalue('song')):
                if e is not None:
                    doc += addSong(p, e)
        elif form.has_key('addAlbums'):
            for e in makeList(form.getvalue('album')):
                if e is not None:
                    doc += addAlbum(p, e)
        elif form.has_key('clear'):
            p.clear()
        elif form.has_key('clearAndStop'):
            p.clear()
            request.state.stop()
            player.stop()

    f = p.update()
    doc += playlistToHtml(f, p)
    doc += CGI.htmlTail()

    request.serve_string(doc)
開發者ID:BackupTheBerlios,項目名稱:amarok-jukebox-svn,代碼行數:30,代碼來源:playlist.py

示例15: main

def main():

    form = cgi.FieldStorage()

    c = Collection()
    p = Playlist()
    player = Player()

    CGI.httpHeaders()

    CGI.htmlHead({ 'style':['../playlist.css'] })
        
    if os.environ['REQUEST_METHOD'] == "POST":
        if form.has_key('addSongs'):
            for e in makeList(form.getvalue('song')):
                if e is not None:
                    addSong(p, c, e)
        elif form.has_key('addAlbums'):
            for e in makeList(form.getvalue('album')):
                if e is not None:
                    addAlbum(p, c, e)
        elif form.has_key('clear'):
            p.clear()
        elif form.has_key('clearAndStop'):
            p.clear()
            player.stop()

    f = p.update()
    playlistToHtml(f, p)
    CGI.htmlTail()
開發者ID:BackupTheBerlios,項目名稱:amarok-jukebox-svn,代碼行數:30,代碼來源:playlist.py


注:本文中的Playlist.Playlist類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。