如何使用python

时间:2019-03-22 20:17:46

标签: python python-3.x mp3

我正在pychar上使用tkinter制作具有GUI的音乐播放器。我想在mp3文件中显示嵌入式专辑封面,但是我找不到任何方法来实现

我曾尝试使用Mutagen,但由于仅打印mp3文件的标签而不是图像而失败

import tkinter.messagebox
import os,sys
from tkinter import *
from tkinter import filedialog
from pygame import mixer
import pause
import time
import threading
from mutagen.mp3 import MP3
import pygame
import bs4
import requests
from PIL import ImageTk, Image
from tkinter import ttk
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, APIC
from io import BytesIO


def browse_file():
    global filename_path
    global b
    filename_path = filedialog.askopenfilename()
    f=filename_path
    b=os.path.splitext(os.path.basename(f))[0]
    add_to_playlist(filename_path)
    track = MP3(filename_path)
    tags = ID3(filename_path)
    print("ID3 tags included in this song ------------------")
    print(tags.pprint())
    print("-------------------------------------------------")
    pict = tags.get("APIC:").data
    im = Image.open(BytesIO(pict))
    print('Picture size : ' + str(im.size))

这是音乐播放器的代码段

0 个答案:

没有答案