def __init__(self, opts, episode_media_container, season): super(EpisodeItem, self).__init__(opts, episode_media_container) media_element = self.video.find("Media") self.media_items = [ MediaItem(self.opts, self, media_element) for media_element in self.video.findall("Media") ] self.season = season self.show = season.show self.key = self.video.attrib['key'] self.type = self.video.get('type', "") self.title = self.video.get('title', "") self.summary = self.video.get('summary', "") self.index = self.video.get('index', "") self.parent_index = self.video.get('parentIndex', "") self.rating = self.video.get('rating', "0") self.thumb = self.video.get('thumb', "") self.originally_available_at = self.video.get('originallyAvailableAt', "") self.writer_names = self.array_of_attributes_with_key_from_child_elements_with_name( self.video, "Writer", "tag") self.writers = ', '.join(self.writer_names) self.director_names = self.array_of_attributes_with_key_from_child_elements_with_name( self.video, "Director", "tag") self.directors = ', '.join(self.director_names)
def __init__(self, opts, movie_media_container): super(MovieItem, self).__init__(opts, movie_media_container) self.media_items = [MediaItem(self.opts, self, media_element) for media_element in self.video.findall("Media")] self.key = self.video.attrib['key'] self.studio = self.video.get('studio', "") self.type = self.video.get('type', "") self.title = self.video.get('title', "") self.content_rating = self.video.get('contentRating', "") #PG-13, etc. self.summary = self.video.get('summary', "") self.rating = self.video.get('rating', "0") self.year = self.video.get('year', "") self.tagline = self.video.get('tagline', "") self.thumb = self.video.get('thumb', "") self.originally_available_at = self.video.get('originallyAvailableAt', "") self.genre_names = self.array_of_attributes_with_key_from_child_elements_with_name(self.video, "Genre", "tag") if len(self.genre_names) > 0: self.genre = self.genre_names[0] else: self.genre = '' self.genres = ', '.join(self.genre_names) self.writer_names = self.array_of_attributes_with_key_from_child_elements_with_name(self.video, "Writer", "tag") self.writers = ', '.join(self.writer_names) self.director_names = self.array_of_attributes_with_key_from_child_elements_with_name(self.video, "Director", "tag") self.directors = ', '.join(self.director_names) self.cast_names = self.array_of_attributes_with_key_from_child_elements_with_name(self.video, "Role", "tag") self.cast = ', '.join(self.cast_names)
def loadLog(self, s=''): ls = s.split("|") item = MediaItem.MediaItem() item.index = ls[0] item.fileName = ls[1] item.url = ls[2] item.length = ls[3] self.addItem(item)
def playMedia(self, url, filename): #print SPrint.encodeFromSystem( u"播放文件: " ) , SPrint.encodeFromSystem(url) ; if self.media.Load(url) != True: return self.item = MediaItem.MediaItem() self.item.fileName = filename self.item.url = url self.SetTitle(filename) self.SetStatusText(filename, 1)
def test(self): item = MediaItem.MediaItem() item.index = 0 item.fileName = '123' item.length = '123' item.url = '123' self.list.append(item) item2 = MediaItem.MediaItem() item2.index = 1 item2.fileName = '1234' item2.length = '1234' item2.url = '1234' self.list.append(item2) item3 = MediaItem.MediaItem() item3.index = 2 item3.fileName = '12345' item3.length = '12345' item3.url = '12345' self.list.append(item3)
def __init__(self): wx.Frame.__init__(self, None, wx.NewId(), u"媒体播放器", pos=wx.DefaultPosition, size=(500, 500)) self.media = '' try: self.media = wx.media.MediaCtrl( self, style=wx.SIMPLE_BORDER, #szBackend=wx.media.MEDIABACKEND_DIRECTSHOW #szBackend=wx.media.MEDIABACKEND_QUICKTIME #szBackend=wx.media.MEDIABACKEND_WMP10 ) self.media.Bind(wx.media.EVT_MEDIA_LOADED, self.mediaLoaded) self.media.Bind(wx.media.EVT_MEDIA_STATECHANGED, self.mediaStateChange) except NotImplementedError: self.Destroy() raise self.listView = '' self.item = MediaItem.MediaItem() self.sb = mediaStateBar.MediaStateBar(self) self.SetStatusBar(self.sb) self.log = SaveLog.SaveLog() #self.log.test(); self.menu = wx.Menu() self.openMenu = self.menu.Append(wx.NewId(), u"打开文件") self.Bind(wx.EVT_MENU, self._openFile, self.openMenu) self.quitMenu = self.menu.Append(wx.NewId(), u"退出") self.Bind(wx.EVT_MENU, self.quit, self.quitMenu) self.viewMenu = wx.Menu() self.listMenu = self.viewMenu.Append(wx.NewId(), u"打开播放列表") self.Bind(wx.EVT_MENU, self.openList, self.listMenu) self.loadListMenu = self.viewMenu.Append(wx.NewId(), u"加载播放列表") self.Bind(wx.EVT_MENU, self.loadMediaList, self.loadListMenu) self.saveListMenu = self.viewMenu.Append(wx.NewId(), u"保存播放列表") self.Bind(wx.EVT_MENU, self.saveMediaList, self.saveListMenu) menuBar = wx.MenuBar() menuBar.Append(self.menu, u"文件") menuBar.Append(self.viewMenu, u"播放列表") self.SetMenuBar(menuBar) self.slider = wx.Slider(self, wx.NewId(), 0, 0, 100) self.Bind(wx.EVT_SLIDER, self.onSeek, self.slider) self.btnGroupSizer = wx.BoxSizer(wx.HORIZONTAL) self.btnGroupSizer.Add((5, 5), 0) self.playBtn = self.createButton("./pic/play.png", self.playMp3, u"播放") self.playBtn.Disable() self.btnGroupSizer.Add(self.playBtn) self.btnGroupSizer.Add((5, 5), 0) self.pauseBtn = self.createButton("./pic/pause.png", self.pauseMp3, u"暂停") self.pauseBtn.Disable() self.btnGroupSizer.Add(self.pauseBtn) self.btnGroupSizer.Add((5, 5), 0) self.stopBtn = self.createButton("./pic/stop.png", self.stopMp3, u"停止") self.stopBtn.Disable() self.btnGroupSizer.Add(self.stopBtn) self.btnGroupSizer.Add((5, 5), 0) self.preBtn = self.createButton("./pic/pre.png", self.preMp3, u"前一个") self.preBtn.Disable() self.btnGroupSizer.Add(self.preBtn) self.btnGroupSizer.Add((5, 5), 0) self.nextBtn = self.createButton("./pic/next.png", self.nextMp3, u"下一个") self.nextBtn.Disable() self.btnGroupSizer.Add(self.nextBtn) self.btnGroupSizer.Add((5, 5), 0) self.openBtn = self.createButton("./pic/media.png", self._openFile, u"打开文件") #self.openBtn.Disable() self.btnGroupSizer.Add(self.openBtn) self.btnGroupSizer.Add((5, 5), 0) self.listBtn = self.createButton("./pic/list.png", self.openList, u"打开列表") #self.listBtn.Disable() self.btnGroupSizer.Add(self.listBtn) self.btnGroupSizer.Add((5, 5), 0) self.volSlider = wx.Slider(self, wx.NewId(), 0, 0, 100) self.Bind(wx.EVT_SLIDER, self.volumeSeek, self.volSlider) self.btnGroupSizer.Add(self.volSlider) self.btnGroupSizer.Add((5, 5), 0) self.volTxt = wx.StaticText(self, wx.NewId(), "") self.btnGroupSizer.Add(self.volTxt) self.btnGroupSizer.Add((5, 5), 0) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.media, 1, wx.EXPAND | wx.ALL, 5) #mainSizer.Add((5,5),0) mainSizer.Add(self.slider, 0, wx.EXPAND | wx.ALL, 5) #mainSizer.Add((2,2),0) mainSizer.Add(self.btnGroupSizer, 0, wx.EXPAND | wx.ALL, 5) #mainSizer.Add((2,2),0) self.SetSizer(mainSizer) self.Layout() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) self.timer.Start(200)