From: Adam C. <ad...@dv...> - 2011-08-25 21:34:38
|
Author: adam Date: Thu Aug 25 17:44:15 2011 New Revision: 11869 Log: Add play state display to the youtube flash player. Modified: branches/rel-1/freevo/share/html/ytflashplayer.html branches/rel-1/freevo/src/video/plugins/ytflashplayer.py Modified: branches/rel-1/freevo/share/html/ytflashplayer.html ============================================================================== --- branches/rel-1/freevo/share/html/ytflashplayer.html (original) +++ branches/rel-1/freevo/share/html/ytflashplayer.html Thu Aug 25 17:44:15 2011 @@ -35,16 +35,9 @@ } } - function getCurrentTime() { + function getTimes() { if (ytplayer) { - return ytplayer.getCurrentTime() - } - return 0; - } - - function getDuration() { - if (ytplayer) { - return ytplayer.getDuration() + return [ytplayer.getCurrentTime(), ytplayer.getDuration()] } return 0; } Modified: branches/rel-1/freevo/src/video/plugins/ytflashplayer.py ============================================================================== --- branches/rel-1/freevo/src/video/plugins/ytflashplayer.py (original) +++ branches/rel-1/freevo/src/video/plugins/ytflashplayer.py Thu Aug 25 17:44:15 2011 @@ -152,12 +152,18 @@ self.stop() return self.item.eventhandler(event) + if event == TOGGLE_OSD: + dialog.show_play_state(dialog.PLAY_STATE_INFO, self.item, self.get_time_info) + return True + if event == PAUSE or event == PLAY: self.paused = not self.paused if self.paused: + dialog.show_play_state(dialog.PLAY_STATE_PAUSE, self.item, self.get_time_info) webbrowser.ipc.pauseVideo() else: + dialog.show_play_state(dialog.PLAY_STATE_PLAY, self.item, self.get_time_info) webbrowser.ipc.playVideo() return True @@ -166,6 +172,16 @@ webbrowser.ipc.seekVideo(event.arg) return True + if event == 'WEB_IPC': + if event.arg['event'] == 'error': + self.stop() + return True + if event.arg['event'] == 'state': + if event.arg['data'] == 0: + self.stop() + return True + return True + # nothing found? Try the eventhandler of the object who called us return self.item.eventhandler(event) @@ -185,11 +201,6 @@ f.close() embed = str(embed) - meta = '' - for tag in soup.findAll('meta'): - meta += str(tag) - - embed = re.sub('width="[0-9]+"', 'width="%d"' % (config.CONF.width-2), embed) embed = re.sub('height="[0-9]+"', 'height="%d"' % (config.CONF.height-2), embed) @@ -197,7 +208,7 @@ html = f.read() f.close() - return html.replace('$EMBED$', embed).replace('$META$', meta) + return html.replace('$EMBED$', embed) @@ -209,10 +220,11 @@ request.send_header('content-length', '%d' % len(html)) request.end_headers() - request.wfile.write(html) request.wfile.flush() + def get_time_info(self): + return webbrowser.ipc.getTimes() |