Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Needed playing MP3s
#1
Newish guy here wanting to use a headless RPi3B running MXRPi to play a list of MP3s randomly. This will be my first attempt to play MP3s using RPi and Python.

First order was to determine what Python player works best on a MXRPi RPi3B+. What I found confused me some.

I tried python-vlc, playsound & pygames. When they ran from Thonny, the playback was very undesirably slooooow. I couldn't tell from the documentation that there was something to pass to speed up the playback. Also when attempting to run the programs from the terminal, there was no sound at all (no errors, took a moment to complete, but no sound).

Lastly, I can successfully play these mp3s using both the music and the multimedia players that come with MXRPi but I can't run them headlesly (at least I don't think so).

What must I do to get any one of these to play back, and at normal speed when run from terminal, so I can decide on which one I want to continue to work with?

Here are the 3 programs:

import vlc
song = vlc.MediaPlayer("file.mp3'")
song.play()
import playsound
playsound.playsound('file.mp3')
import pygame
pygame.mixer.init()
pygame.mixer.music.load('file.mp3')
pygame.mixer.music.play()
Reply
#2
If the music is not in the same folder as the script, use the full path.

'/path/to/file.mp3'
Reply
#3
I originally thought the problem was a Python issue, but, it turns out that it is a MX Linux or MXRPI issue. I reported my findings on the MX Linux forum, and they are looking into it.

After failure using MXRPI, i tried the same code on RPIOS and it worked!

Seems MXRPI has an issue recognizing the headphones port on the RPI3B+ hardware.

In testing with RPiOS, seems python-vlc is my better choice for playing MP3s on a RPi3B+ .

I have much more code to write before I am finished with this project so I may need more help in the near future.

For now, please consider this issue closed
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  azure TTS from text files to mp3s mutantGOD 2 1,725 Jan-17-2023, 03:20 AM
Last Post: mutantGOD

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020