# การแสดงผล Error (Display Error)
เมื่อเกิด Error ระหว่างการเล่นวิดีโอ ByteArk Player จะส่ง Callback onPlaybackError(error) ผ่าน ByteArkPlayerListener มาให้แอปจัดการแสดงผล Error ตามที่ต้องการได้
# การรับ Error
final listener = ByteArkPlayerListener(
onPlaybackError: (ByteArkPlayerPlaybackErrorData error) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("ไม่สามารถเล่นวิดีโอได้"),
content: Text(error.message ?? "Unknown error"),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text("ปิด"),
),
],
),
);
},
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# แนวทางการแสดงผล Error
- แสดง Error ที่ผู้ชมเข้าใจได้ — แทนที่จะแสดง
error.messageดิบจาก SDK โดยตรง แนะนำให้แปลงเป็นข้อความที่ผู้ชมทั่วไปเข้าใจ - เปิดทางให้ลองใหม่ — สำหรับ Error ประเภทเครือข่ายหรือ Source ควรเปิดทางให้ผู้ชมกดลองใหม่
- Log เพื่อการวิเคราะห์ — Log
error.codeและerror.messageไว้สำหรับ Debug
สำหรับรายละเอียดของประเภท Error ดูที่ Errors Reference