Chinaunix首页 | 论坛 | 博客
  • 博客访问: 536878
  • 博文数量: 146
  • 博客积分: 5030
  • 博客等级: 大校
  • 技术积分: 1820
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-16 20:57
文章分类

全部博文(146)

文章存档

2011年(1)

2010年(4)

2009年(30)

2008年(111)

我的朋友

分类: Python/Ruby

2009-03-23 01:26:17

研究了半天gstreamer,发现居然有一个pygame框架,写mp3播放器特简单,我有做了切分lrc歌词的程序,现在一个mp3播放器的雏形出来了。
最不爽的是lrc文件格式没搞懂,所以播放中学时代没问题,别的还有点问题,呵呵。
import lyric
import idv
import sys
import pygame
import time

filename = sys.argv[1]
tag = idv.ID3V1(filename)
node = tag.get_tag()
if node == None:
    print 'error'
    exit()
title = node.get_title().decode('gbk')
artist = node.get_artist().decode('gbk')
lrc = lyric.TTLyric(artist,title,'gbk')
n = lrc.search_lyric()

if n > 1:
    print lrc.get_lyric_list()
    print 'please select one'

lines = lrc.download_lyric(0)
for item in lines:
    item.print_me()

pygame.mixer.init()
pygame.mixer.music.load(filename)
pygame.mixer.music.play()
i = 0
while pygame.mixer.music.get_busy():
    m = pygame.mixer.music.get_pos()
    if i >= len(lines):
        continue
    if lines[i].milsec <= m:
        print lines[i].content
        #lines[i].print_me()
        #print m,'________'
        i = i+1
    time.sleep(0.1)
阅读(1016) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~