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 20a5260d
authored
2025-12-23 18:21:03 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ios播放测试
1 parent
a6bc5367
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
15 deletions
lib/services/player_service.dart
lib/services/player_service.dart
View file @
20a5260
...
...
@@ -2,6 +2,7 @@ import 'dart:async';
import
'dart:io'
;
import
'package:audio_session/audio_session.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter_sound/flutter_sound.dart'
;
class
PlayerService
{
...
...
@@ -32,19 +33,7 @@ class PlayerService {
// 针对iOS, 需要控制不使用听筒进行播放
if
(
Platform
.
isIOS
)
{
var
audioSession
=
await
AudioSession
.
instance
;
await
audioSession
.
configure
(
AudioSessionConfiguration
(
avAudioSessionCategory:
AVAudioSessionCategory
.
playback
,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions
.
defaultToSpeaker
,
avAudioSessionMode:
AVAudioSessionMode
.
spokenAudio
,
androidAudioAttributes:
const
AndroidAudioAttributes
(
contentType:
AndroidAudioContentType
.
speech
,
usage:
AndroidAudioUsage
.
media
,
),
androidAudioFocusGainType:
AndroidAudioFocusGainType
.
gain
,
androidWillPauseWhenDucked:
true
,
),
);
await
audioSession
.
configure
(
AudioSessionConfiguration
.
speech
());
}
final
player
=
FlutterSoundPlayer
();
...
...
@@ -93,9 +82,11 @@ class PlayerService {
// } else {
// debugPrint('还未配置音频会话');
// }
// var currentRoute = await AVAudioSession().currentRoute;
// debugPrint('当前音频路由: ${currentRoute.outputs}');
if
(
Platform
.
isIOS
)
{
var
currentRoute
=
await
AVAudioSession
().
currentRoute
;
debugPrint
(
'当前音频路由-------------------:
${currentRoute.outputs}
'
);
}
_playId
=
playId
;
...
...
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