Question

I need help in creating an MP3 Player GUI program in python. It should show information...

I need help in creating an MP3 Player GUI program in python. It should show information on the file that is playing like its's name,length,amount of play time in minutes and seconds and a feature that allows to create a playlist

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import tkinter as tk
from tkinter import ttk

import mp3play


def format_duration(ms):
    total_s = ms / 1000
    total_min = total_s / 60
    remain_s = total_s % 60
    return "%0d:%02d" % (total_min, remain_s)

class SimplePlayer(tk.Tk):

    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        # Variables we use to dynamically update the text of the labels
        self.music_title = tk.StringVar()
        self.music_progress = tk.StringVar()

        self.fr=ttk.Frame()
        self.fr.pack(expand=True, fill=tk.BOTH, side=tk.TOP)

        # Label to display the song title
        self.title_lbl = ttk.Label(self.fr, textvariable = self.music_title)
        self.title_lbl.pack()

        # Playback progress bar
        self.progress_bar = ttk.Progressbar(self.fr, orient='horizontal', mode='determinate', length=500)
        self.progress_bar.pack()

        # Shows the progress numerically
        self.progress_lbl = ttk.Label(self.fr, textvariable = self.music_progress)
        self.progress_lbl.pack()


    def start(self, music_file):
        self.music = mp3play.load(music_file)

        # Update the title
        self.music_title.set(music_file)

        # Start playback
        self.music.play()

        # Start periodically updating the progress bar and progress label
        self.update_progress()

    def update_progress(self):
        pos_ms = self.music.current_position()
        total_ms = self.music.milliseconds()
        progress_percent = pos_ms / float(total_ms) * 100

        # Update the label
        label_text = "%s / %s   (%0.2f %%)" % (format_duration(pos_ms), format_duration(total_ms), progress_percent)
        self.music_progress.set(label_text)

        # Update the progress bar
        self.progress_bar["value"] = progress_percent

        # Schedule next update in 100ms        
        self.after(100, self.update_progress)

app = SimplePlayer()

app.start('test.mp3')
app.mainloop()
Add a comment
Know the answer?
Add Answer to:
I need help in creating an MP3 Player GUI program in python. It should show information...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You will be designing and creating a Java GUI-based course application. Create a “Student” class. You...

    You will be designing and creating a Java GUI-based course application. Create a “Student” class. You need to have at least 3 instance variables (student characteristics like name,…), at least 2 constructors (1 should be a no-arg constructor), set and get methods. Create a “Course” class that consists of 2 instance variables: the course name and an array of Students (using your Student class). Design and create a JavaFX-based GUI interface that allows you to : INPUT information for Course...

  • I want to make a really simple maze game in Python. I need to use tkinter and GUI to make this ha...

    I want to make a really simple maze game in Python. I need to use tkinter and GUI to make this happened. Under you can see the description of the task, but i need help to getting startet. If there is an other easier way I'm just happy for the help!! task Description: You have to create a maze game. The goal of the game is to get out of the maze. The game should read The maze from a...

  • Need help with this problem using Python programming as soon as possible, thank you! Write a...

    Need help with this problem using Python programming as soon as possible, thank you! Write a GUI-based program that implements an image browser for your computer’s file system. The file dialog should filter for GIF image files, and create and open a PhotoImage when a file is accessed.

  • I need to create a Tic Tac Toe program in C++. These are the requirements Write...

    I need to create a Tic Tac Toe program in C++. These are the requirements Write a program that allows the computer to play TicTacToe against a human player or allow two human players to play one another. Implement the following conditions: The player that wins the current game goes first in the next round, and their symbol is X. The other player will be O. Keep track of the number of games played, wins, and draws for each player....

  • I need help with this python programming exercise, please! thanks in advance Create a Python script...

    I need help with this python programming exercise, please! thanks in advance Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...

  • For Python-3 I need help with First creating a text file named "items.txt" that has the...

    For Python-3 I need help with First creating a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots. Write a python program that 1. Puts this as the first line... import os 2. Creates an empty list 3. Defines main() function that performs the tasks listed below when called. 4. Put these two lines at the top of the main function... if os.path.exists("costlist.txt"): os.remove("costlist.txt") Note: This removes the "costlist.txt" file, if it exists. 5....

  • I need help building code in python for this: Create a program that: Creates a sales...

    I need help building code in python for this: Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file...

  • Python: def combo(): play = True while play: x = int(input('How many people\'s information would you...

    Python: def combo(): play = True while play: x = int(input('How many people\'s information would you like to see: ')) print()    for num in range(x): name() age() hobby() job() phone() print()       answer = input("Would you like to try again?(Enter Yes or No): ").lower()    while True: if answer == 'yes': play = True break elif answer == 'no': play = False break else: answer = input('Incorrect option. Type "YES" to try again or "NO" to leave": ').lower()...

  • need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data...

    need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data file – It has: player ID, player first name, middle initial, last name soccer.txt – Player information file – It has: player ID, goals scored, number of penalties, jersey number output file - formatted according to the example provided later in this assignment a) Define a struct to hold the information for a person storing first name, middle initial, and   last name). b) Define...

  • Need help on following Java GUI problem: Write a program that lets a user display and...

    Need help on following Java GUI problem: Write a program that lets a user display and modify pictures. Create a window. Add four buttons so that clicking a particular button will shift the image by a small amount in the north, south, east or west direction inside the window. Add a menu bar with two menus: File and Image. The File menu should contain an Open menu item that the user can select to display JPEG and PNG files from...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT