Luke Hansford Luke Hansford - 6 months ago 60
Python Question

Is it possible to play FLAC files in Phonon?

I'm trying to play some .flac files using PySide's Phonon module (on Mac if it makes a difference) but it's not an available mimetype for playback. Is there a way to enable this or a plugin I need to install?

Answer

Phonon does not directly support audio formats but uses the underlying OS capabilities. The answer therefore depends on if there is a service registered for the mime type audio/flac. For me there is and here is a short example script to find out:

from PySide import QtCore
from PySide.phonon import Phonon

if __name__ == '__main__':
    app = QtCore.QCoreApplication([])
    app.setApplicationName('test')

    mime_types = Phonon.BackendCapabilities.availableMimeTypes()
    print(mime_types)

    app.quit()