Changeset 1903
- Timestamp:
- 20/11/08 19:50:01 (7 weeks ago)
- svm:headrev:
cc3e1ea1-1e01-0410-8d68-8b121e83a9d5:11185- Location:
- freevo/src/audio/plugins
- Files:
-
- 2 modified
-
lastfm2.py (modified) (7 diffs)
-
mplayervis1.py (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
-
freevo/src/audio/plugins/lastfm2.py
r1902 r1903 233 233 elif event == 'PLAY_END': 234 234 if self.feed is not None and len(self.feed.entries) > 0: 235 self.feed.entries.pop(0) 235 entry = self.feed.entries.pop(0) 236 if entry: 237 time.sleep(3) 238 from kaa.metadata.audio import eyeD3 239 try: 240 tag = eyeD3.Tag() 241 tag.link(entry.trackpath) 242 tag.header.setVersion(eyeD3.ID3_V2_3) 243 tag.setArtist(entry.artist) 244 tag.setAlbum(entry.album) 245 tag.setTitle(entry.title) 246 #tag.setGenre(entry.genre) 247 if entry.image: 248 tag.addImage(eyeD3.ImageFrame.FRONT_COVER, entry.image) 249 tag.update() 250 except Exception, why: 251 print why 236 252 self.play() 237 253 return False … … 280 296 self.location_url = entry.location_url 281 297 self.length = entry.duration 282 basename = os.path.join(config.LASTFM_DIR, self.stream_name,entry.artist, entry.album, entry.title)298 basename = os.path.join(config.LASTFM_DIR, entry.artist, entry.album, entry.title) 283 299 self.basename = basename.lower().replace(' ', '_').\ 284 300 replace('.', '').replace('\'', '').replace(':', '').replace(',', '') … … 288 304 # url is changed, to include file:// 289 305 self.url = os.path.join(self.basename + os.path.splitext(entry.location_url)[1]) 290 self.trackpath = os.path.join(self.basename + os.path.splitext(entry.location_url)[1])306 entry.trackpath = os.path.join(self.basename + os.path.splitext(entry.location_url)[1]) 291 307 if entry.image_url: 292 308 self.image = os.path.join(self.basename + os.path.splitext(entry.image_url)[1]) … … 299 315 else: 300 316 self.image = None 301 self.track_downloader = self.webservices.download(self.location_url, self.trackpath, self) 317 entry.image = self.image 318 track_downloader = self.webservices.download(self.location_url, entry.trackpath, self) 302 319 # Wait for a bit of the file to be downloaded 303 while self.track_downloader.filesize() < 1024 * 20:304 if not self.track_downloader.isrunning():320 while track_downloader.filesize() < 1024 * 20: 321 if not track_downloader.isrunning(): 305 322 raise LastFMError('Failed to download track', entry.location_url) 306 323 time.sleep(0.1) 307 324 if not self.player: 308 self.player = PlayerGUI(self, menuw)325 self.player = PlayerGUI(self, self.menuw) 309 326 error = self.player.play() 310 327 if error: … … 312 329 313 330 except LastFMError, why: 314 traceback.print_exc()315 331 _debug_('play error: %s' % (why,), DWARNING) 316 if menuw:332 if self.menuw: 317 333 AlertBox(text=str(why)).show() 318 334 rc.post_event(STOP) … … 473 489 return reply 474 490 except urllib2.HTTPError, why: 475 _debug_('%s: %s' % (url, why), DWARNING)476 491 raise LastFMError(why, url) 477 492 except Exception, why: … … 690 705 #_debug_('%s downloaded' % self.filename) 691 706 # XXX this may upset mplayer, stopping playback before the end of the track 692 if self.entry:693 time.sleep(3)694 from kaa.metadata.audio import eyeD3695 try:696 tag = eyeD3.Tag()697 tag.link(self.filename)698 tag.header.setVersion(eyeD3.ID3_V2_3)699 tag.setArtist(self.entry.artist)700 tag.setAlbum(self.entry.album)701 tag.setTitle(self.entry.title)702 #tag.setGenre(self.entry.genre)703 tag.addImage(eyeD3.ImageFrame.FRONT_COVER, self.entry.image)704 tag.update()705 except Exception, why:706 print why707 707 break 708 708 self.size += len(reply) -
freevo/src/audio/plugins/mplayervis1.py
r1796 r1903 35 35 __author__ = 'Viggo Fredriksen <viggo@katatonic.org>' 36 36 37 import os, time 37 38 try: 38 39 import pygoom … … 41 42 'or remove this plugin (http://freevo.sf.net/pygoom).') 42 43 43 44 44 # pygame modules 45 45 from pygame import Rect, image, transform, Surface 46 46 47 # kaa modules 48 from kaa import Timer 49 47 50 # freevo modules 48 import plugin, config, rc, skin, osd , time51 import plugin, config, rc, skin, osd 49 52 50 53 from event import * 51 54 from animation import render, BaseAnimation 52 from kaa import Timer 55 56 from util.benchmark import benchmark 57 benchmarking = config.DEBUG_BENCHMARKING 58 benchmarkcall = config.DEBUG_BENCHMARKCALL 59 60 if config.DEBUG_DEBUGGER: 61 import pdb, pprint, traceback 53 62 54 63 mmap_file = '/tmp/mpav' … … 64 73 coversurf = None 65 74 75 @benchmark(benchmarking, benchmarkcall) 66 76 def __init__(self, x, y, width, height, coverfile=None): 67 """ Initialise the MPlayer Visualization Goom """ 77 """ 78 Initialise the MPlayer Visualization Goom 79 """ 68 80 _debug_('MpvGoom.__init__(x=%r y=%r width=%r height=%r coverfile=%r)' % (x, y, width, height, coverfile), 1) 69 81 self.mode = config.MPLAYERVIS_MODE 70 82 self.coverfile = coverfile 83 84 if not os.path.exists(mmap_file): 85 f = open(mmap_file, 'w') 86 s = str(chr(0)) * 2064 87 f.write(s) 88 f.close() 71 89 72 90 BaseAnimation.__init__(self, (x, y, width, height), fps=100, bg_update=False, bg_redraw=False) … … 96 114 self.alpha = self.set_alpha(self.counter, 0) 97 115 98 self.running = True116 self.running = False 99 117 Timer(self.timerhandler).start(0.1) 100 118 self.last_time = 0 101 119 102 120 121 @benchmark(benchmarking, benchmarkcall) 103 122 def set_cover(self, coverfile): 104 123 """ … … 110 129 111 130 131 @benchmark(benchmarking, benchmarkcall) 112 132 def set_visual(self, visual): 113 133 """ pass the visualisation effect to pygoom """ … … 116 136 117 137 138 @benchmark(benchmarking, benchmarkcall) 118 139 def set_title(self, title): 119 140 """ pass the song title to pygoom """ … … 122 143 123 144 145 @benchmark(benchmarking, benchmarkcall) 124 146 def set_message(self, message): 125 147 """ pass the song message to pygoom """ … … 128 150 129 151 152 #@benchmark(benchmarking, benchmarkcall) 130 153 def set_alpha(self, high, low): 131 154 """ Get the alpha level for a count """ … … 137 160 138 161 162 @benchmark(benchmarking, benchmarkcall) 139 163 def set_resolution(self, x, y, width, height, cinemascope=0, clear=False): 140 164 """ Set the resolution of the pygoom window """ … … 180 204 181 205 206 @benchmark(benchmarking, benchmarkcall) 182 207 def set_fullscreen(self): 183 208 """ Set the mode to full screen """ … … 207 232 208 233 234 @benchmark(benchmarking, benchmarkcall) 209 235 def set_info(self, info, timeout=5): 210 236 """ … … 231 257 232 258 259 #@benchmark(benchmarking, benchmarkcall) 233 260 def init_state(self): 234 261 if self.counter > 0: … … 243 270 244 271 272 #@benchmark(benchmarking, benchmarkcall) 245 273 def fade_in_wait_state(self): 246 274 if self.counter > 0: … … 253 281 254 282 283 #@benchmark(benchmarking, benchmarkcall) 255 284 def fade_in_state(self): 256 285 if self.counter > 0: … … 264 293 265 294 295 #@benchmark(benchmarking, benchmarkcall) 266 296 def fade_out_wait_state(self): 267 297 if self.counter > 0: … … 274 304 275 305 306 #@benchmark(benchmarking, benchmarkcall) 276 307 def fade_out_state(self): 277 308 if self.counter > 0: … … 285 316 286 317 318 #@benchmark(benchmarking, benchmarkcall) 287 319 def timerhandler(self): 288 320 """ … … 293 325 # draw the cover 294 326 if not self.running: 295 return self.running 327 return False 328 296 329 gooms = pygoom.get_surface() 297 330 if self.coversurf: … … 304 337 gooms.blit(s, (x, y)) 305 338 339 #if not self.running: 340 # return False 341 306 342 # draw the info 307 if not self.running:308 return self.running309 343 if self.info: 310 344 s, x, y, w, h = self.info … … 334 368 self.lastmode = self.mode 335 369 336 return self.running 337 338 370 return True 371 372 373 #@benchmark(benchmarking, benchmarkcall) 339 374 def poll(self, current_time): 340 375 """ … … 389 424 detached = False 390 425 426 @benchmark(benchmarking, benchmarkcall) 391 427 def __init__(self): 392 428 """ Initialist the PluginInterface """ … … 422 458 self.view = config.MPLAYERVIS_MODE 423 459 self.view_func = [self.dock, self.fullscreen, self.noview] 424 425 460 self.initialised = False 461 462 463 @benchmark(benchmarking, benchmarkcall) 426 464 def config(self): 427 """ """ 465 """ 466 """ 428 467 return [ 429 468 ('MPLAYERVIS_MODE', 0, 'Set the initial mode of the display, 0)DOCK, 1)FULL or 2)NOVI'), … … 437 476 ('MPLAYERVIS_FULL_GEOMETRY', '%dx%d' % (config.CONF.width, config.CONF.height), 'Full screen geometry'), 438 477 ('MPLAYERVIS_FAST_FULLSCREEN', True, 'Fullscreen surface is doubled'), 439 ('MPLAYERVIS_FPS', 25, 'Max FPS of visualization') 478 ('MPLAYERVIS_FPS', 25, 'Max FPS of visualization'), 479 ('MPLAYERVIS_HAS_TRACK', False, 'Set to True if mplayer has -af track patch'), 440 480 ] 441 481 442 482 443 def play(self, command, player): 444 """ 445 Play it 446 """ 447 _debug_('play(command, player)', 1) 448 self.player = player 449 self.item = player.playerGUI.item 450 451 return command + [ "-af", "export=" + mmap_file ] 452 453 483 @benchmark(benchmarking, benchmarkcall) 454 484 def toggle_view(self): 455 485 """ … … 467 497 468 498 499 @benchmark(benchmarking, benchmarkcall) 469 500 def eventhandler(self, event=None, arg=None): 470 501 """ … … 479 510 PluginInterface.detached = False 480 511 self.start_visual() 512 elif event == PLAY_START: 513 self.start_visual() 514 elif event == PLAY_END: 515 self.pause_visual() 481 516 elif event == STOP: 482 517 PluginInterface.detached = False 518 self.stop_visual() 483 519 484 520 if event == 'CHANGE_MODE': … … 519 555 self.visual.set_info(event.arg) 520 556 return True 521 522 557 if self.passed_event: 523 558 self.passed_event = False 524 559 return False 525 526 560 self.passed_event = True 527 561 … … 532 566 533 567 568 @benchmark(benchmarking, benchmarkcall) 534 569 def item_info(self, fmt=None): 535 570 """ 536 Returns info about the current running song571 Returns info about the current playing song 537 572 """ 538 573 _debug_('item_info(fmt=%r)' % (fmt,), 1) … … 573 608 574 609 610 @benchmark(benchmarking, benchmarkcall) 575 611 def dock(self): 576 612 _debug_('dock()', 1) … … 603 639 604 640 641 @benchmark(benchmarking, benchmarkcall) 605 642 def fullscreen(self): 606 643 _debug_('fullscreen()', 1) … … 616 653 617 654 655 @benchmark(benchmarking, benchmarkcall) 618 656 def noview(self): 619 657 _debug_('noview()', 1) … … 631 669 632 670 671 @benchmark(benchmarking, benchmarkcall) 633 672 def start_visual(self): 634 673 _debug_('start_visual()', 1) 635 if self.vi sual or self.view == NOVI:674 if self.view == NOVI: 636 675 return 637 676 677 if self.visual: 678 if self.visual.running: 679 return 680 638 681 if rc.app() == self.player.eventhandler: 639 682 #if self.visual is None: 683 # self.visual = MpvGoom(300, 300, 150, 150, self.item.image) 640 684 self.visual = MpvGoom(300, 300, 150, 150, self.item.image) 641 685 … … 644 688 645 689 self.view_func[self.view]() 690 self.visual.running = True 646 691 self.visual.start() 647 692 648 693 694 @benchmark(benchmarking, benchmarkcall) 695 def pause_visual(self): 696 _debug_('pause_visual()', 1) 697 if self.visual: 698 self.visual.running = False 699 700 701 @benchmark(benchmarking, benchmarkcall) 649 702 def stop_visual(self): 650 703 _debug_('stop_visual()', 1) … … 657 710 658 711 712 @benchmark(benchmarking, benchmarkcall) 713 def play(self, command, player): 714 """ 715 Play the track 716 @param command: mplayer command 717 @param player: the player object 718 """ 719 _debug_('play(command=%r, player=%r)' % (command, player), 1) 720 self.player = player 721 self.item = player.playerGUI.item 722 723 if config.MPLAYERVIS_HAS_TRACK: 724 return command + [ '-af', 'export=%s' % mmap_file + ',track=5:1500' ] 725 return command + [ '-af', 'export=%s' % mmap_file ] 726 727 728 @benchmark(benchmarking, benchmarkcall) 659 729 def stop(self): 660 730 _debug_('stop()', 1) 661 self.stop_visual() 662 663 731 if self.visual: 732 self.visual.running = False 733 734 735 #@benchmark(benchmarking, benchmarkcall) 664 736 def stdout(self, line): 665 737 """ … … 670 742 """ 671 743 #_debug_('stdout(line=%r)' % (line), 1) 672 if self.visual: 673 return 744 memory_mapped = False 745 if line.find('[export] Memory mapped to file: ' + mmap_file) == 0: 746 memory_mapped = True 747 _debug_("Detected MPlayer 'export' audio filter! Using MPAV.") 674 748 675 749 if PluginInterface.detached: 676 750 return 677 751 678 if line.find("[export] Memory mapped to file: " + mmap_file) == 0: 679 _debug_("Detected MPlayer 'export' audio filter! Using MPAV.") 752 if memory_mapped: 680 753 self.start_visual() 754 if self.visual: 755 self.visual.running = True
