本文整理汇总了Python中playlist.Playlist.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.addItem方法的具体用法?Python Playlist.addItem怎么用?Python Playlist.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.addItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainPanel
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import addItem [as 别名]
#.........这里部分代码省略.........
def OnPlayUpdateFromList(self):
if self.playlist.index >= len(self.playlist.playlist):
self.playlist.index = -1
self.OnStop(None)
return
plitem, plduration = self.playlist.playlist[self.playlist.index]
if self.networkconn.playing != plitem:
for item, duration in self.playlist.playlist:
if item == self.networkconn.playing:
plitem = item
plduration = duration
if self.networkconn.playing == plitem:
# Fix the clock
self.clock = float(plduration)
if self.clockthread == None:
self.clockthread = threading.Thread(target=self.UpdateCountdown)
self.clockthread.start()
# Deselect current item
self.lstPlaylist.Select(self.lstPlaylist.GetFirstSelected(), False)
# Change the checkbox label to play selected
self.chkAuto.SetLabel('Auto-play next item')
# Load the next playlist item if requested
if self.chkAuto.Value == True:
item, duration = self.playlist.getNextItem()
self.networkconn.load(item)
self.lblLoaded.SetLabel('Please Wait...')
self.btnPlay.Enable(False)
# Update the status markers
self.StatusHighlightSet()
else:
self.lblLoaded.SetLabel("None")
self.btnPlay.Enable(False)
def OnPlay(self, event):
# Play the loaded item
self.networkconn.play()
# Update the labels
self.lblPlaying.SetLabel(self.networkconn.playing)
self.btnStop.Enable(True)
self.chkAuto.Enable(True)
# Update playing statuses from playlist
self.OnPlayUpdateFromList()
def OnStop(self, event):
self.networkconn.stop()
self.btnStop.Enable(False)
self.lblPlaying.SetLabel("None")
self.lblCountdown.Show(False)
self.clock = -1
self.chkAuto.SetLabel('Auto-play next item')
self.chkAuto.Value = False
self.chkAuto.Enable(False)
self.networkconn.setauto(False)
self.StatusHighlightSet()
def OnchkAutoChange(self, event):
try:
if self.networkconn.connected == True:
self.networkconn.setauto(self.chkAuto.Value)
if (self.networkconn.loaded == ""):
# Load the next playlist item if requested
item, duration = self.playlist.getNextItem()
self.networkconn.load(item)
self.lblLoaded.SetLabel('Please Wait...')
self.btnPlay.Enable(False)
else:
self.GetParent().OnDisconnectInstruction()
raise AttributeError
except AttributeError:
self.chkAuto.Enable(False)
self.chkAuto.Value = False
def OnAdd(self, event):
dlgAdd = dlgAddItems(self)
filelist = self.networkconn.getfilelist()
for item, duration in filelist:
dlgAdd.ddVideoList.Append(item)
if dlgAdd.ShowModal() == wx.ID_OK:
if self.lstPlaylist.SelectedItemCount > 0:
newindex = self.playlist.index
else:
newindex = -1
for item, duration in filelist:
if item == dlgAdd.ddVideoList.GetStringSelection():
self.playlist.addItem(item, int(round(duration)), )
self.PlaylistRefresh()
示例2: MainPanel
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import addItem [as 别名]
#.........这里部分代码省略.........
if self.networkconn.playing == plitem:
# Deselect current item
self.lstPlaylist.Select(self.lstPlaylist.GetFirstSelected(), False)
# Change the checkbox label to play selected
self.chkAuto.SetLabel('Auto-play next item')
# Update the status markers
self.StatusHighlightSet()
# Load next if needed
if (self.chkAuto.Value == True and self.networkconn.loaded == ""):
item, duration = self.playlist.getNextItem(advance=True)
self.networkconn.load(item)
self.lblLoaded.SetLabel('Please Wait...')
self.btnPlay.Enable(False)
else:
self.lblLoaded.SetLabel("None")
self.btnPlay.Enable(False)
def OnPlay(self, event):
# Play the loaded item
self.networkconn.play()
# Update the labels
self.lblPlaying.SetLabel(self.networkconn.playing)
self.btnStop.Enable(True)
self.chkAuto.Enable(True)
# Make sure auto state cleared on server
self.networkconn.setauto(False)
# Update playing statuses from playlist
self.OnPlayUpdateFromList()
def OnStop(self, event):
self.networkconn.stop()
self.btnStop.Enable(False)
self.lblPlaying.SetLabel("None")
self.lblCountdown.Show(False)
self.endtime = None
self.chkAuto.SetLabel('Auto-play next item')
self.chkAuto.SetValue(False)
self.chkAuto.Enable(False)
self.networkconn.setauto(False)
self.StatusHighlightSet()
def OnchkAutoChange(self, event):
try:
if self.networkconn.connected == True:
self.networkconn.setauto(self.chkAuto.Value)
if (self.chkAuto.Value == True):
# Set current selection in playlist if not set already
if (self.playlist.index == -1):
if (self.networkconn.playing != ""):
for i in range(0, len(self.playlist.playlist)):
item, duration = self.playlist.playlist[i]
if item == self.networkconn.playing:
self.playlist.index = i
break
if (self.networkconn.loaded == ""):
# Load the next playlist item if requested
item, duration = self.playlist.getNextItem(advance=True)
self.networkconn.load(item)
self.lblLoaded.SetLabel('Please Wait...')
self.btnPlay.Enable(False)
else:
self.GetParent().OnDisconnectInstruction()
raise AttributeError
except AttributeError:
self.chkAuto.Enable(False)
self.chkAuto.Value = False
def OnAdd(self, event):
dlgAdd = dlgAddItems(self)
filelist = self.networkconn.getfilelist()
if (filelist == None):
wx.MessageBox("Error getting file list, try again later")
return
for item, duration in filelist:
dlgAdd.ddVideoList.Append(item)
if dlgAdd.ShowModal() == wx.ID_OK:
if self.lstPlaylist.SelectedItemCount > 0:
newindex = self.playlist.index
else:
newindex = -1
for item, duration in filelist:
if item == dlgAdd.ddVideoList.GetStringSelection():
self.playlist.addItem(item, int(round(duration)), )
self.PlaylistRefresh()