fix: audio play bug for ios safari. (#285)

* fix: audio play bug for ios safari. (WIP).

* chore: Repair and can pop up the playback prompt dialog box correctly.

* chore: add AudioContext to reduce playback delay.
This commit is contained in:
CloudWebRTC
2023-05-16 10:28:09 +08:00
committed by GitHub
parent 2b1e7f2e5f
commit 0b8aeeeba1
10 changed files with 146 additions and 6 deletions
+19
View File
@@ -20,6 +20,25 @@ extension LKExampleExt on BuildContext {
),
);
Future<bool?> showPlayAudioManuallyDialog() => showDialog<bool>(
context: this,
builder: (ctx) => AlertDialog(
title: const Text('Play Audio'),
content: const Text(
'You need to manually activate audio PlayBack for iOS Safari !'),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
child: const Text('Ignore'),
),
TextButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text('Play Audio'),
),
],
),
);
Future<bool?> showUnPublishDialog() => showDialog<bool>(
context: this,
builder: (ctx) => AlertDialog(
+9
View File
@@ -79,6 +79,15 @@ class _RoomPageState extends State<RoomPage> {
print('Failed to decode: $_');
}
context.showDataReceivedDialog(decoded);
})
..on<AudioPlaybackStatusChanged>((event) async {
if (!widget.room.canPlaybackAudio) {
print('Audio playback failed for iOS Safari ..........');
bool? yesno = await context.showPlayAudioManuallyDialog();
if (yesno == true) {
await widget.room.startAudio();
}
}
});
void _askPublish() async {