| | |
My first program (Mp3 player)
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
Hi, I have recently started trying to teach myself python, I've watched a few video tutorials and am reading "Learning Python".
I have been making an Mp3 player and have hit a point that I cant work my way past so was hoping some kind person here could help me work it out.
The problem is I want to go from only opening one mp3 file and playing it to a playlist system but I cant work out how.
Here is my current code Using (Python 2.6 with Tkinter and mp3play).
{Edit}Just thought I should put a bit more detail in as to what I have tried so far.
basically I have tried using askopenfilenames to get the names of the files and put them in a list, but I have no idea what to do after that
. Hope I am making some sense.
Thanks
I have been making an Mp3 player and have hit a point that I cant work my way past so was hoping some kind person here could help me work it out.
The problem is I want to go from only opening one mp3 file and playing it to a playlist system but I cant work out how.
Here is my current code Using (Python 2.6 with Tkinter and mp3play).
{Edit}Just thought I should put a bit more detail in as to what I have tried so far.
basically I have tried using askopenfilenames to get the names of the files and put them in a list, but I have no idea what to do after that
. Hope I am making some sense. Python Syntax (Toggle Plain Text)
from Tkinter import * import mp3play import tkFileDialog import Tkinter def open_file(): #Opens a dialog box to open .mp3 file global music #then sends filename to file_name_label. global mp3 global play_list filename.set (tkFileDialog.askopenfilename(defaultextension = ".mp3", filetypes=[("All Types", ".*"), ("MP3", ".mp3")])) playlist = filename.get() playlist_pieces = playlist.split("/") play_list.set (playlist_pieces[-1]) playl = play_list.get() play_list_display.insert(END, playl) mp3 = filename.get() print mp3 music = mp3play.load(mp3) pieces = mp3.split("/") name.set (pieces[-1]) def play(): #Plays the .mp3 file music.play() def stop(): #Stops the .mp3 file music.stop() def pause(): #Pauses or unpauses the .mp3 file if music.ispaused() == True: music.unpause() elif music.ispaused() == False: music.pause() def vol(event): #Allows volume to be changed with the slider v = Scale.get(volume_slider) music.volume(v) def Exit(): exit() root = Tk() root.title("Ickle Music Player") root.geometry('300x100+250+100') filename = Tkinter.StringVar() name = Tkinter.StringVar() play_list = Tkinter.StringVar() menubar = Menu(root) filemenu = Menu(menubar, tearoff=0) menubar.add_cascade(label='File', menu = filemenu) filemenu.add_command(label='Open', command = open_file) filemenu.add_separator() filemenu.add_command(label='Exit', command = Exit) root.config(menu=menubar) open_file = Button(root, width = 6, height = 1, text = 'Open file', command = open_file) open_file.grid(row=0, column=3) play_button = Button(root, width = 5, height = 1, text='Play', command = play) play_button.grid(row=0, column=0, sticky = W) stop_button = Button(root, width = 5, height = 1, text='Stop', command = stop) stop_button.grid(row=0, column=1, sticky = W) pause_button = Button(root, width = 5, height = 1, text='Pause', command = pause) pause_button.grid(row=0, column=2) volume_slider = Scale(root, label='Volume', orient = 'horizontal', fg = 'black', command = vol) volume_slider.grid(row=0, column=4) file_name_label = Label(root, font=('Verdana', 8), fg = 'black', wraplength = 300, textvariable=name ) file_name_label.grid(row=3, column=0, columnspan=8) play_list_window = Toplevel(root, height = 150, width = 100) play_list_window.title("Playlist") play_list_display = Listbox(play_list_window, width = 50) play_list_display.pack() play_list_window.mainloop() root.mainloop()
Thanks
Last edited by Icklebitt; Jul 20th, 2009 at 8:12 am. Reason: More info
![]() |
Similar Threads
- length in mp3 player (C#)
- yet another mp3 player problem (Cellphones, PDAs and Handheld Devices)
- mp3 player utilities 3.57 (IT Professionals' Lounge)
- Ebay MP3 Player problem (Cellphones, PDAs and Handheld Devices)
- .cab files? drivers? ('MOSMP028'- ministry of sound mp3 player) (Windows 95 / 98 / Me)
- MP3 Player (C)
Other Threads in the Python Forum
- Previous Thread: How to save to HTML file in Python?
- Next Thread: String formatting problem.
Views: 532 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied address ansi backend beginner changecolor class code conversion coordinates copy curves customdialog dan08 dictionary directory dynamic edit examples excel feet file float font format ftp function generator getvalue gui halp homework i/o images import info input ip java line linux list lists loop mouse mysql newb number numbers output panel parsing path port prime print program programming projects py2exe pygame pyqt python queue random rational recursion recursive schedule screensaverloopinactive scrolledtext searchingfile server ssh stamp statictext string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial type ubuntu unicode url urllib urllib2 variable whileloop windows write wxpython





