Page 1 of 1

MP3 -Dateien in Beeware abspielen

Posted: 03 Mar 2025, 22:28
by Anonymous
MP3 -Dateien in Beeware abspielt < / p>
Hallo, ich experimentiere mit Python / Beeware / Toga / Android. Ich möchte eine MP3-Datei öffnen. from toga.platform import current_platform
if current_platform == "android":
from android.content import Intent
from android.net import Uri
from java.io import File

intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_MUSIC)

await self.app._impl.intent_result(intent)
< /code>
Nach dem Aufrufen der Funktion erhalte ich die Auswahl der Anwendung, um den Sound abzuspielen. intent.setDataAndType(Uri.fromFile(File(str("resources/test.mp3"))), "application/mp3")

←[33mW/python.stderr: android.os.FileUriExposedException: file:///resources/test.mp3 exposed beyond app through Intent.getData()←[0m
< /code>
Wie definiere ich eine Datei zum Spielen? Idealerweise wäre es, eine Datei aus dem Musikverzeichnis abzuspielen.
thx