m4myo / python-mplayer

Automatically exported from code.google.com/p/python-mplayer
GNU Lesser General Public License v3.0
0 stars 0 forks source link

mplayer audio not playing #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I try to implement a audio player using the library. Somehow I cannot get the 
audio to load

No error message is displayed. 

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

but no file seems loaded

import pygame
import os
import subprocess
import sys
import time
import mpylayer
import subprocess

from mplayer import *

audiofile = "/mp3/80er/A\ Flock\ of\ Seagulls\ -\ I\ Ran.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

Original issue reported on code.google.com by sebastia...@gmail.com on 31 Oct 2014 at 12:37

GoogleCodeExporter commented 9 years ago
forget it. 

p.loadfile('audiofile') -> p.loadfile(audiofile)

Original comment by sebastia...@gmail.com on 31 Oct 2014 at 5:59