hi, i made a music player it opens almost all the songs but while opening some songs it gives this error :

 A:/Chrome Downloads/Jhalla_Wallah_(Remix)_-_(MusicTub.Com).mp3 
Error 277 for "open "A:Chrome DownloadsJhalla_Wallah_(Remix)_-_(MusicTub.Com).mp3" alias mp3_0.878022650438": A problem occurred in initializing MCI. 
Error 263 for "set mp3_0.878022650438 time format milliseconds": The specified device is not open or is not recognized by MCI. 
Error 263 for "status mp3_0.878022650438 length": The specified device is not open or is not recognized by MCI. 
Exception in Tkinter callback 
Traceback (most recent call last): 
  File "A:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ 
    return self.func(*args) 
  File "A:\Python26\EmoPlayer.py", line 120, in open_file 
    self.music = mp3play.load(self.filename.get()) 
  File "A:\Python26\mp3play\__init__.py", line 10, in load 
    return AudioClip(filename) 
  File "A:\Python26\mp3play\__init__.py", line 17, in __init__ 
    self._clip = _PlatformSpecificAudioClip(filename) 
  File "A:\Python26\mp3play\windows.py", line 43, in __init__ 
    self._length_ms = int(buf) 
ValueError: invalid literal for int() with base 10: 'The specified device is not open or is not recognized by MCI.'  

here is my code:

from Tkinter import *
import mp3play
import tkFileDialog
import Tkinter
import tkFont
import Tkinter as tk

class musicplay:
    def __init__(self):

        open('Paths.txt', 'w').close()

        self.music = None
        #self.music_mood = None
        self.play_list = []
        #self.play_list_mood = []
        self.trackLocations = []
        #self.trackLocations_mood = []

        self.root = tk.Tk()
        self.root.title("EmoPlayer")

        self.root.configure(background='Black')
        self.root.geometry('345x350+376+169')

        self.filename = Tkinter.StringVar()
        self.name = Tkinter.StringVar()
        self.play_list = Tkinter.StringVar()

        menubar = Menu(self.root)
        filemenu = Menu(menubar, tearoff=0, bg="black", fg="Orange")
        menubar.add_cascade(label='File', menu = filemenu)
        filemenu.add_command(label='Open', command = self.open_file)
        filemenu.add_separator()
        filemenu.add_command(label='Exit', command = self.Exit)
        self.root.config(menu=menubar)

        #images
        play=PhotoImage(file='A:\Python26\images\play.gif')
        pause=PhotoImage(file='A:\Python26\images\pause.gif')
        stop=PhotoImage(file='A:\Python26\images\stop.gif')
        mood=PhotoImage(file='A:\Python26\images\mood.gif')

        #buttons
        mood_button = Button(self.root, width = 90, height = 40,image=mood)
        mood_button.image=mood
        mood_button.grid(row=0, column=4)

        play_button = Button(self.root, width = 40, height = 40, command = self.play, image=play)
        play_button.image=play
        play_button.grid(row=0, column=0, sticky = W)

        stop_button = Button(self.root, width = 40, height = 40, command = self.stop, image=stop)
        stop_button.image=stop
        stop_button.grid(row=0, column=1, sticky = W)

        pause_button = Button(self.root, width = 40, height = 40, command = self.pause, image=pause)
        pause_button.image=pause
        pause_button.grid(row=0, column=2)

        #generate_button = Button(self.root, width = 7, height = 2, text='Generate',
                              #fg='Orange', command = self.generate , bg="black")
        #generate_button.grid(row=0, column=4)

        self.volume_slider = Scale(self.root, label='Volume',
                              orient = 'horizontal', fg = 'black', 
                              command = self.vol, bg="VioletRed2")
        self.volume_slider.grid(row=0, column=6)

        file_name_label = Label(self.root, font=('Comic Sans', 8),
                                fg = 'Orange', wraplength = 300,
                                textvariable=self.name, bg="black")
        file_name_label.grid(row=4, column=0, columnspan=12)


        #PLAYLIST
        play_list_window = Label(self.root, height = 150, width = 100)
       # play_list_window.title("Playlist")
        self.play_list_display = Listbox(play_list_window, selectmode=EXTENDED,
                                    width = 50, bg="gainsboro",
                                    fg="Orange")

        self.play_list_display.bind("<Double-Button-1>", self.tune_changed)
        self.play_list_display.pack()
        play_list_window.grid(row=5, column=0, columnspan=12)


        #MOODYLIST
        play_list_window_mood = Toplevel(self.root, height = 700, width = 250)
        play_list_window_mood.title("MoodyList")
        self.play_list_display_mood = Listbox(play_list_window_mood, selectmode=EXTENDED,
                                    width = 50, bg="gainsboro",
                                    fg="Orange")

        #self.play_list_display_mood.bind("<Double-Button-1>", self.tune_changed_play)
        self.play_list_display_mood.pack()

        play_list_window_mood.mainloop()
        play_list_window.mainloop()


        self.root.mainloop()        

    def open_file(self):                                
        """
        Opens a dialog box to open .mp3 filemusic,
        then sends filename to file_name_label.
        """
        try:
            self.filename.set(tkFileDialog.askopenfilename(
            defaultextension = ".mp3",
            filetypes=[("All Types", ".*"), ("MP3", ".mp3")]))
            self.playlist = self.filename.get()
            playlist_pieces = self.playlist.split("/")
            self.play_list.set (playlist_pieces[-1])
            playl = self.play_list.get()
            self.play_list_display.insert(END, playl)
            print self.filename.get()
            try:
                self.music = mp3play.load(self.filename.get())
            finally:
                pieces = self.filename.get().split("/")
                self.trackLocations += [self.filename.get()]
                self.name.set(pieces[-1])
        except IOError:
            pass
        try:
            # This tries to open an existing file but creates a new file if necessary.
            logfile = open("Paths.txt", "a")
            try:
                logfile.write("\n" + self.filename.get())
                #logfile.write(self.filename.get())
            finally:
                logfile.close()
        except IOError:
            pass




    def play(self):
        """Plays the .mp3 file"""
        self.music.play()

    def stop(self):
        """Stops the .mp3 file"""
        self.music.stop()                

    def pause(self):
        """Pauses or unpauses the .mp3 file"""
        if self.music.ispaused():
            self.music.unpause()
        else:
            self.music.pause()

    #def mood(self):



    def vol(self, event):
        """Allows volume to be changed with the slider"""
        v = Scale.get(self.volume_slider)
        try:
            self.music.volume(v)
        except:
            pass

    def tune_changed(self, event):
        idx = event.widget.curselection()[0]
        self.music = mp3play.load(self.trackLocations[int(idx)])
        print ("Now playing %s" % event.widget.get(idx))

    #def tune_changed_play(self,event):
       # idx = event.widget.curselection()[0]
       # self.music_mood = mp3play.load(self.trackLocations_mood[int(idx)])
       # print ("Now playing %s" % event.widget.get(idx))

    #def generate(self):
     #   self.playlist_mood = 'A:/Chrome Downloads/Mind'
      #  playlist_pieces_mood = self.playlist_mood.split("/")
       # self.play_list.set (playlist_pieces_mood[-1])
        #playl_mood = self.play_list.get()
        #self.play_list_display_mood.insert(END, playl_mood)
        #print self.filename.get()
        #self.music = mp3play.load(self.playlist_mood)
        #pieces_mood = self.playlist_mood.split("/")
        #self.trackLocations_mood += [self.playlist_mood]

        #self.name.set(pieces_mood[-1])

        #self.playlist_mood = 'A:\Chrome Downloads\Flo_Rida_-_Whistle_(www.freshmp3music.ru)'
        #self.trackLocations_mood += [self.playlist_mood]
        #playlist_pieces_mood = self.playlist_mood.split("/")
        #self.play_list.set (playlist_pieces_mood[-1])
        #playl = self.play_list.get()
      #  self.play_list_display_mood.insert(END, playl)
       # print ("Generated ")

    def Exit(self):
        exit()

if __name__ == "__main__":
    musicplay()

The path in the error message

Error 277 for "open "A:Chrome DownloadsJhalla_Wallah_(Remix)-(MusicTub.Com).mp3

looks strange. You may have to use something like

path = r"A:\Chrome Downloads\Jhalla_Wallah_(Remix)_-_(MusicTub.Com).mp3"

Some programs have problems with spaces in path names.

but i did not specify path names in my code . the player has file menu from where it can open mp3 file stored anywhere in drive.
most of the songs layed but for few songs it gives this error ... how can i solve it ??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.