package com.humand.demo.modules.IncomingCallMessagingService.player

import android.content.Context
import android.media.MediaPlayer
import android.media.Ringtone
import android.media.RingtoneManager
import android.net.Uri

object RingtonePlayer {
    private var mediaPlayer: MediaPlayer? = null
    private var ringtone: Ringtone? = null

    fun start(context: Context, soundUri: Uri) {
        stop()
        val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)
        ringtone = RingtoneManager.getRingtone(context, uri)
        ringtone?.play()
    }

    fun stop() {
        ringtone?.stop()
        ringtone = null
    }
}
