python-mplayer not opening mp3 file
Question: Hi Iam trying to build a small audio player, integrating mplayer into python

I thought python-mplayer could do the job but I cannot get it to work. Any
idea?

seems like p.loadfile doesnt work as ps ax shows /usr/bin/mplayer -slave -idle
-really-quiet -msglevel global=4 -input nodefault-bindings -noconfig all

    
    
    import pygame
    import os
    import subprocess
    import sys
    import time
    import subprocess
    
    from mplayer import *
    
    audiofile = "/home/user/1.mp3"
    gfx_rev_normal = pygame.image.load('rev_normal.png')
    
    pygame.init()
    screen = pygame.display.set_mode((800, 480))
    
    #background = pygame.Surface(screen.get_size())
    #background = background.convert()
    #background.fill = ((255, 255, 255))
    
    font = pygame.font.SysFont("monospace", 36)
    source_text = font.render("Audio Player", 1, (255, 255, 255))
    text_width = source_text.get_width()
    source_text_x = screen.get_width() / 2
    source_text_x = source_text_x - (text_width/2)
    source_text_y = 10
    screen.blit(source_text,(source_text_x, source_text_y))
    
    Player.exec_path="/usr/bin/mplayer"
    p = Player()
    p.loadfile('audiofile')
    #p.pause()
    p.volume=100
    
    running = True
    while running:
    
        time.sleep(0.1)
        print p.stream_pos
        screen.blit(gfx_rev_normal,(30,120))
        pygame.display.flip()
    
        for event in pygame.event.get():
    
        if event.type == pygame.QUIT:
            running = False
    
        if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            running = False
    


Answer: I'm not familiar with the mplayer API, but maybe it's just this small
oversight:

    
    
    p.loadfile('audiofile')
    

which should be

    
    
    p.loadfile(audiofile)
    

as the path of your file is in the variable audiofile, not the string
`'audiofile'`.

