dart - Flutter - How to have audio play when phone screen is off
问题描述
I am building an app where there is a person is speaking, kinda like a podcast, and I would like the listener to be able to listen when the screen is off.
I am using Flutter, and the media player is complete, but if i turn the phone screen off, the media stops.
I have no idea how to treat this so when you turn off the screen, the media will still play.
解决方案
您需要使用后台服务插件。我推荐此处提供的 audio_services 插件:https ://pub.dev/packages/audio_service#-installing-tab-
推荐阅读
- react-native - 找不到变量:onClassifyPress
- python - 如何允许用户在 tkinter 上输入?
- python - 使用python将CSV文件中的值插入数据库时出现日期格式错误
- python - 带有 MultiIndex 列的 Pandas read_csv
- javascript - Vue - 通过 Event.$emit 传递数据
- terraform - 引用来自 for_each 模块的输出
- symfony - 通过将 URI 作为参数传递 PHPUnit 的 assertResponseRedirects 方法
- chef-infra - 如何在厨师食谱中传递变量
- arduino - 多次更改变量的值并在 arduino 的整个循环中保持该变量值
- android - 如何在Android中取消推送通知时发送请求