当前位置:   article > 正文

Python 音乐播放器_py播放器

py播放器

今天给大家分享的是一个音乐播放器

下面为完整代码(音乐自备)

import tkinter

from tkinter import Button

from tkinter import Label

from tkinter import Entry

from tkinter import Scale

from tkinter import Label, PhotoImage

from PIL import Image, ImageTk

from tkinter import messagebox

from tkinter import Toplevel

from pymediainfo import MediaInfo

import re

from tkinter import Message

import threading

import pygame

import time

import os

import sys

import random

from tkinter.filedialog import askopenfilename

from tkinter.filedialog import askdirectory

from tkinter import StringVar

import requests

import json

top = tkinter.Tk()

top.geometry("800x400")

top.title("**的音乐播放器")

top.state("zoomed")


 

def printsrceen(texts):

t = int(texts)

top.attributes("-alpha", t / 100)


 

screenwidth = top.winfo_screenwidth()

screenheight = top.winfo_screenheight() - 100

pygame.init()

path = StringVar()

paths = StringVar()

patht = StringVar()

v = StringVar()

v1 = StringVar()


 

def callback(): # 搜索本地文件

path_ = askopenfilename()

return path_


 

def selectPath(): # 随机播放

folder_path = "D:/音乐"

folder_list = os.listdir(folder_path) # 遍历文件夹里面每个文件

list = []

count = 0

for i in folder_list: # 将文件夹里的文件按顺序传提给变量i 此处区别os.walk()

if os.path.splitext(i)[1] == '.flac': # 提取特定后缀文件'.***'

list.append(i)

# print(type(list))

count = count + 1

# print(count)

s = random.randint(0, (count - 1)) # 获取随机数

file = list[s]

fil = folder_path + "\\" + file

pygame.mixer.music.load(fil)

pygame.mixer.music.play(1, 0)

media_info = MediaInfo.parse(fil)

data = media_info.to_json() # medio到json()这两行是获取文件的所有属性

rst = re.search('other_duration.*?(.*?)min(.*?)s.*?', data)

t = int(rst.group(0)[19:20])

r &

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号