# เล่นเสียงเบื้องหลัง (Background Playing)
ByteArk Player SDK for Android รองรับการเล่นเสียงต่อแม้ผู้ชมสลับไปทำงานอื่น หรือล็อกหน้าจอ ผ่าน withBackgroundPlaying() ของ ByteArkPlayerBuilder
# การเปิดใช้งาน
val playerBuilder = ByteArkPlayerBuilder.Builder()
.withContext(this)
.withControl()
.withBackgroundPlaying()
.build()
1
2
3
4
5
2
3
4
5
นอกจากนี้จำเป็นต้องประกาศ Permission FOREGROUND_SERVICE และ Service ByteArkPlayerService ใน AndroidManifest.xml
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application>
<service
android:name="com.byteark.bytearkplayercore.handler.exoplayer.service.ByteArkPlayerService"
android:enabled="true"
android:exported="true"/>
</application>
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Note
เมื่อเล่นแบบ Background Player จะแสดง Media notification เพื่อให้ผู้ชมสามารถควบคุมการเล่นได้จาก Notification panel