研究了半天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)
阅读(1050) | 评论(0) | 转发(0) |