Step 3: Play

On successful preparation, call play() method to play Mastercard Sonic Feedback.

Note:Mastercard Sonic Branding Sound and/or Animation play process is divided into two steps as mentioned below: 1). prepare()

2). play() sonicController.play must be followed by sonicController.prepare call.

//import statements
import android.util.Log
import com.mastercard.sonic.listeners.OnCompleteListener

//Create private fun to play sonic
    private fun playSonic() {
        sonicController.play(
        sonicView,
        object : OnCompleteListener {
            override fun onComplete(statusCode: Int) {
                Log.d("SonicFragment", "SonicView is played successfully, statusCode=$statusCode")
            }
        })
    }

Note: In case of sound only, SonicView can be passed as null.

For complete list of StatusCode, click here.

Last updated