[TK] Reproductor de .mp3 by sokoleonardo
Página 1 de 1.
[TK] Reproductor de .mp3 by sokoleonardo
[Tienes que estar registrado y conectado para ver esa imagen]
Saludos y espero comentarios
- Código:
# -*- coding: utf-8 -*-
import tkFileDialog,mp3play,tkMessageBox
from Tkinter import *
def AYUDA():
""" Funcion que invoca a otra ventana de ayuda para el usuario."""
texto = """
Este programa solo funciona en\nSistemas Opetativos Windows (mala suerte).
Para abrir una cancion tendras que que buscar\npor los directorios con el boton ▲
Pensado y programado por Sokoleonardo
Imagen de programa: http://img585.imageshack.us/img585/7581/sencilloreproductor.png """
ventanaAyuda = Tk()
ventanaAyuda.wm_minsize(width=170,height=170)
ventanaAyuda.resizable(0,0)
ventanaAyuda.title("Ayuda sobre Reproductor")
ventanaAyuda.tk_setPalette("black")
textoAyuda = Label(ventanaAyuda,text=texto,fg="white").pack()
ventana = Tk()
ventana.wm_minsize(width=436,height=310)
ventana.resizable(0,0)
w = "white"
def Buscar():
RutaMP3 = tkFileDialog.askopenfilenames(filetypes = (("Canciones", "*.mp3"),))
if RutaMP3:
return RutaMP3
class Lista:
def __init__(self):
self.Reproduccion = [None]
self.TrackActual = 0
self.NombreMP3 = ["No hay reproduccion disponible."]
def TrackArriba(self):
maximo = len(self.Reproduccion)-1
if self.TrackActual < maximo:
detener()
self.TrackActual += 1
reproducir()
def TrackAbajo(self):
if self.TrackActual > 0:
detener()
self.TrackActual -= 1
reproducir()
lista = Lista()
def mostrarListaMP3s():
posicion = 90
numero = 0
for todos in lista.NombreMP3:
posicion += 15
numero += 1
if todos != "No hay reproduccion disponible.":
indice=str(numero)+" - "+todos+" "*110
else:
indice = todos+" "*110
texto = Label(ventana,text=indice,fg="blue")
texto.place(x=10,y=posicion)
def Presentar():
mostrarListaMP3s()
nombre = lista.NombreMP3[lista.TrackActual]
Texto = "Reproduccion: "+nombre+" "*110
TextoMusica = Label(ventana,text=Texto,fg="white").place(x=10,y=270)
def abrir():
ruta = Buscar()
if ruta != None:
try:
lista.Reproduccion.remove(None)
lista.NombreMP3.remove("No hay reproduccion disponible.")
except: pass
for LaRuta in ruta:
if len(lista.Reproduccion) <= 11:
nombre = LaRuta.split("/")[-1]
miAudio = mp3play.AudioClip(LaRuta)
lista.Reproduccion.append(miAudio)
lista.NombreMP3.append(nombre)
else:
opcion = tkMessageBox.askokcancel("Limite de reproducciones","Ya has habierto demasiadas canciones\nDesea vaciar la lista de canciones?")
if opcion == True:
lista.Reproduccion = [None]
lista.NombreMP3 = ["No hay reproduccion disponible."]
Presentar()
else:
tkMessageBox.showinfo("Aviso","No podras abrir mas de\nde las canciones que ya\nestan reproduciendo.")
break
mostrarListaMP3s()
def detener():
if lista.Reproduccion[0] != None:
lista.Reproduccion[lista.TrackActual].stop()
def reproducir():
if lista.Reproduccion[0] != None:
detener()
lista.Reproduccion[lista.TrackActual].play()
if lista.NombreMP3[0] != "No hay reproduccion disponible.":
Presentar() #estas comparaciones logicas los pongo asi porque el boton tiene que llamar a reproducir para saltar el error de Presentar
else:
Presentar()
def pausa():
if lista.Reproduccion[0] != None:
if lista.Reproduccion[lista.TrackActual].isplaying():
lista.Reproduccion[lista.TrackActual].pause()
elif lista.Reproduccion[lista.TrackActual].ispaused():
lista.Reproduccion[lista.TrackActual].unpause()
class Volumen:
def __init__(self):
self.Vol = 100
def Actualizar(self):
if lista.Reproduccion[0] != None:
lista.Reproduccion[lista.TrackActual].volume(self.Vol)
def Bajar(self):
if self.Vol >= 0:
self.Vol -= 2
self.Actualizar()
def Subir(self):
if self.Vol < 98:
self.Vol += 2
self.Actualizar()
vol = Volumen()
boton1 = Button(ventana,text="▲",width=6,height=4,fg=w,command=abrir,cursor="hand2")
boton1.place(x=4,y=4)
boton2 = Button(ventana,text="██",width=6,height=4,fg=w,command=detener,cursor="hand2")
boton2.place(x=52,y=4)
boton3 = Button(ventana,text="Vol +",width=6,height=4,fg=w,command=vol.Subir,cursor="hand2")
boton3.place(x=100,y=4)
boton4 = Button(ventana,text="Vol ˉ",width=6,height=4,fg=w,command=vol.Bajar,cursor="hand2")
boton4.place(x=148,y=4)
boton5 = Button(ventana,text="►",width=6,height=4,fg=w,command=reproducir,cursor="hand2")
boton5.place(x=196,y=4)
boton6 = Button(ventana,text="▐▐",width=6,height=4,fg=w,command=pausa,cursor="hand2")
boton6.place(x=244,y=4)
boton7 = Button(ventana,text="▐◄",width=6,height=4,fg=w,command=lista.TrackAbajo,cursor="hand2")
boton7.place(x=292,y=4)
boton8 = Button(ventana,text="►▌",width=6,height=4,fg=w,command=lista.TrackArriba,cursor="hand2")
boton8.place(x=340,y=4)
boton9 = Button(ventana,text="Ayuda!",width=6,height=2,fg=w,command=AYUDA,cursor="hand2")
boton9.place(x=388,y=4)
presentacion1 = Label(ventana,text = "♫ ♪"*22,fg="blue")
presentacion1.place(x=4,y=65)
presentacion2 = Label(ventana,text = "Lista de reproducciones:\n"+"¯"*18,fg="green")
presentacion2.place(x=4,y=80)
presentacion3 = Label(ventana,text = "♫ ♪"*25,fg="blue")
presentacion3.place(x=4,y=290)
Copyright = Label(ventana,text = "Sokoleonardo ©",fg="blue")
Copyright.place(x=300,y=80)
ventana.tk_setPalette("black")
ventana.title("Reproductor")
ventana.mainloop()
Saludos y espero comentarios
Sokoleonardo- Moderador de Seccion
- Mensajes : 52
Nivel : 138
Reputación : 4
Fecha de inscripción : 04/08/2011
Vive en : Argentina
Temas similares
» [Tkinter Python]CUH-F1Sound 1.0.0(Reproductor de *.mp3 en Python)By Sokoleonardo
» [TK] Calculadora by sokoleonardo
» Crear menus profecionales en Tkinter. by Sokoleonardo
» [TK] Calculadora by sokoleonardo
» Crear menus profecionales en Tkinter. by Sokoleonardo
Página 1 de 1.
Permisos de este foro:
No puedes responder a temas en este foro.
Vie Sep 05, 2014 6:15 pm por JAVIER_77
» Hacker nostale
Vie Jul 20, 2012 5:02 pm por Sweet_Boy
» Chrome OS 20.x pasa al canal estable
Vie Jul 13, 2012 11:15 pm por [D]ement<<<
» Disponible openSUSE 12.2 RC 1
Vie Jul 13, 2012 12:44 am por [D]ement<<<
» NitroShare, comparte archivos y carpetas entre Linux y Windows
Vie Jul 13, 2012 12:26 am por [D]ement<<<
» Linux Mint 13 KDE Release Candidate, disponible
Vie Jul 13, 2012 12:18 am por [D]ement<<<
» LibreOffice 3.5.5, más estabilidad
Vie Jul 13, 2012 12:06 am por [D]ement<<<
» File History, un Time Machine para Windows 8
Miér Jul 11, 2012 9:50 pm por [D]ement<<<
» Como habilitar el logueo automático en Windows
Miér Jul 11, 2012 9:44 pm por [D]ement<<<
» Acronis True Image 2012
Mar Jul 10, 2012 12:15 am por [D]ement<<<
» Virus Informaticos
Mar Mayo 08, 2012 7:10 am por Sokoleonardo