Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 6b074f28
authored
2025-12-23 23:26:57 +0800
by
Administrator
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ios的声音问题
1 parent
5ee2391b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
18 deletions
lib/services/player_service.dart
lib/services/player_service.dart
View file @
6b074f2
...
...
@@ -30,12 +30,14 @@ class PlayerService {
// 打开播放器
try
{
// 针对iOS, 需要控制不使用听筒进行播放
//
if (Platform.isIOS) {
//
var audioSession = await AudioSession.instance;
// await audioSession.configure(AudioSessionConfiguration.speech
());
//
}
if
(
Platform
.
isIOS
)
{
var
audioSession
=
await
AudioSession
.
instance
;
await
audioSession
.
configure
(
AudioSessionConfiguration
.
music
());
}
final
player
=
FlutterSoundPlayer
();
_player
=
(
await
player
.
openPlayer
())!;
// 播放进度回调
...
...
@@ -72,22 +74,10 @@ class PlayerService {
// 针对iOS, 需要控制不使用听筒进行播放
if
(
Platform
.
isIOS
)
{
final
session
=
await
AudioSession
.
instance
;
await
session
.
configure
(
AudioSessionConfiguration
(
avAudioSessionCategory:
AVAudioSessionCategory
.
playback
,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions
.
allowBluetooth
,
avAudioSessionMode:
AVAudioSessionMode
.
spokenAudio
,
avAudioSessionRouteSharingPolicy:
AVAudioSessionRouteSharingPolicy
.
defaultPolicy
,
avAudioSessionSetActiveOptions:
AVAudioSessionSetActiveOptions
.
notifyOthersOnDeactivation
,
androidAudioAttributes:
AndroidAudioAttributes
(
contentType:
AndroidAudioContentType
.
speech
,
flags:
AndroidAudioFlags
.
none
,
usage:
AndroidAudioUsage
.
media
,
),
androidAudioFocusGainType:
AndroidAudioFocusGainType
.
gain
,
androidWillPauseWhenDucked:
true
,
));
await
session
.
configure
(
AudioSessionConfiguration
.
music
());
}
// // 获取当前音频会话配置
// AudioSession session = await AudioSession.instance;
// if (session.isConfigured) {
...
...
@@ -111,6 +101,7 @@ class PlayerService {
// 播放速度
_player
!.
setSpeed
(
playRate
);
await
_player
!.
startPlayer
(
fromURI:
url
,
whenFinished:
()
async
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment