-
QuestionI use AudioRecorder to record and Audio to play the recording file. I package the test program into an apk and install it on my phone, but I can't hear my recording file. I don't know how I can solve this problem? My packaging instructions The packaging result for "flet build apk --include-packages flet_audio_recorder flet_audio" is normal. Code sampleimport flet as ft
path = "assets/talk/test-audio-file.wav"
url = path
async def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.appbar = ft.AppBar(title=ft.Text("Audio Recorder test"), center_title=True)
async def handle_start_recording(e):
await audio_rec.start_recording_async(path)
async def handle_stop_recording(e):
output_path = await audio_rec.stop_recording_async()
if page.web and output_path is not None:
await page.launch_url_async(output_path)
audio_rec = ft.AudioRecorder(
audio_encoder=ft.AudioEncoder.WAV,
)
page.overlay.append(audio_rec)
await page.update_async()
audio1 = ft.Audio(
src=url,
autoplay=False,
volume=10,
balance=0,
)
page.overlay.append(audio1)
await page.update_async()
await page.add_async(
ft.ElevatedButton("Start Audio Recorder", on_click=handle_start_recording),
ft.ElevatedButton("Stop Audio Recorder", on_click=handle_stop_recording),
ft.ElevatedButton("Play", on_click=lambda _: audio1.play()),
)
ft.app(target=main) Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I am still trying to solve this problem. In the process, I tried to package AudioRecorder and Audio into a windows app, but the windows app also failed to record and had an error message: env_openai3) PS D:\note\env_openai3\turnover2> flet build windows --include-packages flet_audio_recorder flet_audio My python version is 3.11.4 and flet version is 0.21.1 |
Beta Was this translation helpful? Give feedback.
-
Can you remove "assets" from your path as shown here and retry? Btw, does the app work locally (without packaging)? |
Beta Was this translation helpful? Give feedback.
-
I have solved this problem. The solution process is briefly explained as follows:
ft.app(target=main) I hope the above information can be helpful to people who encounter the same problem. |
Beta Was this translation helpful? Give feedback.
I have solved this problem. The solution process is briefly explained as follows:
First I updated flet to 0.21.2, then I made some changes to the program code. I removed await page.update_async() in audio1, and then used flet build apk --include-packages flet_audio_recorder flet_audio to package the program. . After this process, you can record and play the recording files on your Android phone
The entire program code is as follows:
import flet as ft
async def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.appbar = ft.AppBar(title=ft.Text("Audio Recorder"), center_title=True)