V
V
Vladislav_K2017-05-29 09:32:25
Python
Vladislav_K, 2017-05-29 09:32:25

Not playing mp3 through pyglet?

Good afternoon, comrades)
Please help a newbie)
I'm trying to play mp3 using the pyglet package, initially I want to write the most primitive alarm clock algorithm, don't judge strictly for the shitty code, if there is one, I'm a beginner and I'm writing from the knowledge that I have , better indicate if where I screwed up specifically)
But that's not the point, here's the code on the question:

from datetime import datetime
import time
import pyglet

hours = str(input("Enter Hours:   "))
minutes = str(input("Enter Minutes:   "))
timesum = hours + ':' + minutes

def play_song():
  song = pyglet.media.load('1.mp3')
  song.play()
  pyglet.app.run()

def clock():
  timenow = datetime.now().time()
  timeredirect = str(timenow)
  timeneed = timeredirect[0:5]
  if timesum != timeneed:
    time.sleep(1)
    return clock()
  else:
    play_song()
    return

clock()

the program works without errors, the problem is when the "else" finally works, nothing happens, the music should supposedly start, but it doesn't, the mp3 is where the source is .. what could be the problem? I don't see it, thanks!
PS Half an hour later, now another problem:
036a8551a72b423dac16012a88ab8e70.JPG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-05-29
@sanya84

Here is a link to AVbin https://avbin.github.io/AVbin/Download.html
add to the beginning of your code

import os
dll_name = os.path.join(os.path.dirname(__file__), 'avbin')
pyglet.lib.load_library(dll_name)

and don't forget to add avbin.dll to the project

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question