2

I've already tried VLC library but the cpu reach 100% usage frequently during file playing, I've also the necessity to track the state of the playing so to know when the file is ended etc., Any ideas?

  • 1
    By "reproduce", do you mean that you want to play the MP3? It might be a good idea to clarify that with an edit if you can. – Aurora0001 Sep 11 '17 at 19:47
  • 2
    Yes exactly what i mean, sorry for my bad english. – Helio Sep 11 '17 at 19:48
2

You might experience better performance using omxplayer:

Omxplayer is a video player specifically made for the Raspberry Pi's GPU made by Edgar (gimli) Hucek from the XBMC/Kodi project. It relies on the OpenMAX hardware acceleration API, which is the Broadcom's VideoCore officially supported API for GPU video/audio processing.

If you're using Raspbian, omxplayer will already be installed. To output to HDMI, just run:

omxplayer -o hdmi <filename>

For further information, check the link above or use man omxplayer to read the manual page.

The Pi Zero uses a BCM2835 SoC, which supports Broadcom's proprietary media acceleration features. omxplayer can take advantage of this to gain better performance than software-accelerated playback.

To track whether playback has ended, you can use the os.system() function in Python. Presumably, when playback is complete, the function will return 0 (exit code 0 implies success, generally, on Unix systems). The call is synchronous so your script will wait until playback is complete until moving to the next line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.