cheofusi / just_playback

A small library for playing audio files in python, with essential playback functionality.
MIT License
64 stars 7 forks source link

How to ensure that audio files with diacritics in the file path are played #30

Closed RxoMTH closed 6 months ago

RxoMTH commented 9 months ago

When I run this code:

import os

from just_playback import Playback

path = r'C:\Romeo Quiñones - Deep in my heart.mp3'
print(os.path.isfile(path))
file = Playback(path)
file.play()

It gives me the following output:

True
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\play audio.py", line 7, in <module>
    file = Playback(path)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\just_playback\playback.py", line 34, in __init__
    self.load_file(path_to_file)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\just_playback\playback.py", line 53, in load_file
    self.__bind(lib.load_file(self.__ma_attrs, path_to_file.encode('utf-8')))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\just_playback\playback.py", line 235, in __bind
    raise MiniaudioError(MA_RESULT_STR[ma_res])
just_playback.ma_result.MiniaudioError: MA_DOES_NOT_EXIST

However, when I go to the file itself, change the ñ to n in the file name, and update the path variable to r'C:\Romeo Quinones - Deep in my heart.mp3', it successfully runs and gives this output:

True

How can I ensure that my audio file with an ñ will be successfully read?

Specifications Python version: 3.10 just_playback version: 0.1.7 Platform: Windows 10 Pro

PrajwalVandana commented 9 months ago

Hmm ... it works on my Mac, wondering if it's an OS-specific issue? Sorry I can't be of more help

cheofusi commented 9 months ago

Hi @RxoMTH,

just-playback currently uses UTF-8 encoding for all file names. This becomes a problem when dealing with multibyte characters, such as ñ, one a platform like Windows which operates natively in UTF-16. This would be addressed in the next release.